TYPO3 CMS  TYPO3_6-2
StandaloneViewTest.php
Go to the documentation of this file.
1 <?php
3 
4 /* *
5  * This script is backported from the FLOW3 package "TYPO3.Fluid". *
6  * *
7  * It is free software; you can redistribute it and/or modify it under *
8  * the terms of the GNU Lesser General Public License, either version 3 *
9  * of the License, or (at your option) any later version. *
10  * *
11  * *
12  * This script is distributed in the hope that it will be useful, but *
13  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
14  * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser *
15  * General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU Lesser General Public *
18  * License along with the script. *
19  * If not, see http://www.gnu.org/licenses/lgpl.html *
20  * *
21  * The TYPO3 project - inspiring people to share! *
22  * */
23 
27 
32 
36  protected $singletonInstances = array();
37 
41  protected $view;
42 
47 
52 
57 
62 
66  protected $mockObjectManager;
67 
71  protected $mockRequest;
72 
76  protected $mockUriBuilder;
77 
82 
87 
92 
96  protected $mockContentObject;
97 
102 
108  public function setUp() {
109  $this->singletonInstances = GeneralUtility::getSingletonInstances();
110  $this->view = $this->getAccessibleMock('TYPO3\\CMS\\Fluid\\View\\StandaloneView', array('testFileExistence', 'buildParserConfiguration'), array(), '', FALSE);
111  $this->mockTemplateParser = $this->getMock('TYPO3\\CMS\\Fluid\\Core\\Parser\\TemplateParser');
112  $this->mockParsedTemplate = $this->getMock('TYPO3\\CMS\\Fluid\\Core\\Parser\\ParsedTemplateInterface');
113  $this->mockTemplateParser->expects($this->any())->method('parse')->will($this->returnValue($this->mockParsedTemplate));
114  $this->mockConfigurationManager = $this->getMock('TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManagerInterface');
115  $this->mockObjectManager = $this->getMock('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
116  $this->mockObjectManager->expects($this->any())->method('get')->will($this->returnCallback(array($this, 'objectManagerCallback')));
117  $this->mockRequest = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\Web\\Request');
118  $this->mockUriBuilder = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\Web\\Routing\\UriBuilder');
119  $this->mockFlashMessageContainer = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\Controller\\FlashMessageContainer');
120  $this->mockContentObject = $this->getMock('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer');
121  $this->mockControllerContext = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\Controller\\ControllerContext');
122  $this->mockControllerContext->expects($this->any())->method('getRequest')->will($this->returnValue($this->mockRequest));
123  $this->mockViewHelperVariableContainer = $this->getMock('TYPO3\\CMS\\Fluid\\Core\\ViewHelper\\ViewHelperVariableContainer');
124  $this->mockRenderingContext = $this->getMock('TYPO3\\CMS\\Fluid\\Core\\Rendering\\RenderingContext');
125  $this->mockRenderingContext->expects($this->any())->method('getControllerContext')->will($this->returnValue($this->mockControllerContext));
126  $this->mockRenderingContext->expects($this->any())->method('getViewHelperVariableContainer')->will($this->returnValue($this->mockViewHelperVariableContainer));
127  $this->view->_set('templateParser', $this->mockTemplateParser);
128  $this->view->_set('objectManager', $this->mockObjectManager);
129  $this->view->setRenderingContext($this->mockRenderingContext);
130  $this->mockTemplateCompiler = $this->getMock('TYPO3\\CMS\\Fluid\\Core\\Compiler\\TemplateCompiler');
131  $this->view->_set('templateCompiler', $this->mockTemplateCompiler);
132  GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager', $this->mockObjectManager);
133  GeneralUtility::addInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer', $this->mockContentObject);
134 
136  $mockCacheManager = $this->getMock('TYPO3\\CMS\\Core\\Cache\\CacheManager', array(), array(), '', FALSE);
137  $mockCache = $this->getMock('TYPO3\\CMS\\Core\\Cache\\Frontend\\PhpFrontend', array(), array(), '', FALSE);
138  $mockCacheManager->expects($this->any())->method('getCache')->will($this->returnValue($mockCache));
139  GeneralUtility::setSingletonInstance('TYPO3\\CMS\\Core\\Cache\\CacheManager', $mockCacheManager);
140  }
141 
145  public function tearDown() {
147  GeneralUtility::resetSingletonInstances($this->singletonInstances);
148  parent::tearDown();
149  }
150 
155  public function objectManagerCallback($className) {
156  switch ($className) {
157  case 'TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManagerInterface':
159  case 'TYPO3\\CMS\\Fluid\\Core\\Parser\\TemplateParser':
161  case 'TYPO3\\CMS\\Fluid\\Core\\Rendering\\RenderingContext':
163  case 'TYPO3\\CMS\\Extbase\\Mvc\\Web\\Request':
164  return $this->mockRequest;
165  case 'TYPO3\\CMS\\Extbase\\Mvc\\Web\\Routing\\UriBuilder':
166  return $this->mockUriBuilder;
167  case 'TYPO3\\CMS\\Extbase\\Mvc\\Controller\\ControllerContext':
169  case 'TYPO3\\CMS\\Extbase\\Mvc\\Controller\\FlashMessageContainer':
171  case 'TYPO3\\CMS\\Fluid\\Core\\Compiler\\TemplateCompiler':
173  }
174  throw new \InvalidArgumentException('objectManagerCallback cannot handle class "' . $className . '". Looks like incomplete mocking in the tests.', 1417105493);
175  }
176 
180  public function constructorSetsSpecifiedContentObject() {
182  $mockContentObject = $this->getMock('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer');
183  $this->mockConfigurationManager->expects($this->once())->method('setContentObject')->with($this->identicalTo($mockContentObject));
185  }
186 
191  $this->mockConfigurationManager->expects($this->once())->method('setContentObject')->with($this->identicalTo($this->mockContentObject));
192  new StandaloneView();
193  }
194 
198  public function constructorSetsRequestUri() {
199  $expectedRequestUri = GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL');
200  $this->mockRequest->expects($this->once())->method('setRequestURI')->with($expectedRequestUri);
201  new StandaloneView();
202  }
203 
207  public function constructorSetsBaseUri() {
208  $expectedBaseUri = GeneralUtility::getIndpEnv('TYPO3_SITE_URL');
209  $this->mockRequest->expects($this->once())->method('setBaseURI')->with($expectedBaseUri);
210  new StandaloneView();
211  }
212 
217  $this->mockUriBuilder->expects($this->once())->method('setRequest')->with($this->mockRequest);
218  new StandaloneView();
219  }
220 
225  $this->mockControllerContext->expects($this->once())->method('setRequest')->with($this->mockRequest);
226  new StandaloneView();
227  }
228 
233  $this->mockControllerContext->expects($this->once())->method('setUriBuilder')->with($this->mockUriBuilder);
234  new StandaloneView();
235  }
236 
242  $this->view->render();
243  }
244 
249  $this->view->setTemplateSource('The Template Source');
250  $this->mockTemplateParser->expects($this->once())->method('parse')->with('The Template Source');
251  $this->view->render();
252  }
253 
258  $templatePathAndFilename = GeneralUtility::fixWindowsFilePath(__DIR__) . '/Fixtures/StandaloneViewFixture.html';
259  $expectedResult = file_get_contents($templatePathAndFilename);
260  $this->view->setTemplatePathAndFilename($templatePathAndFilename);
261  $this->mockTemplateParser->expects($this->once())->method('parse')->with($expectedResult);
262  $this->view->render();
263  }
264 
270  $this->view->setTemplatePathAndFilename('NonExistingTemplatePath');
271  @$this->view->render();
272  }
273 
277  public function setFormatSetsRequestFormat() {
278  $this->mockRequest->expects($this->once())->method('setFormat')->with('xml');
279  $this->view->setFormat('xml');
280  }
281 
287  $this->view->getLayoutRootPath();
288  }
289 
295  $this->view->getLayoutRootPaths();
296  }
297 
302  $templatePathAndFilename = 'some/template/RootPath/SomeTemplate.html';
303  $layoutRootPath = 'some/layout/RootPath';
304  $this->view->setTemplatePathAndFilename($templatePathAndFilename);
305  $this->view->setLayoutRootPath($layoutRootPath);
306  $actualResult = $this->view->getLayoutRootPath();
307  $this->assertEquals($layoutRootPath, $actualResult);
308  }
309 
314  $templatePathAndFilename = 'some/template/RootPath/SomeTemplate.html';
315  $layoutRootPaths = array(
316  'some/layout/RootPath'
317  );
318  $this->view->setTemplatePathAndFilename($templatePathAndFilename);
319  $this->view->setLayoutRootPaths($layoutRootPaths);
320  $actualResult = $this->view->getLayoutRootPaths();
321  $this->assertEquals($layoutRootPaths, $actualResult);
322  }
323 
328  $templatePathAndFilename = 'some/template/RootPath/SomeTemplate.html';
329  $this->view->setTemplatePathAndFilename($templatePathAndFilename);
330  $expectedResult = 'some/template/RootPath/Layouts';
331  $actualResult = $this->view->getLayoutRootPath();
332  $this->assertEquals($expectedResult, $actualResult);
333  }
334 
339  $templatePathAndFilename = 'some/template/RootPath/SomeTemplate.html';
340  $this->view->setTemplatePathAndFilename($templatePathAndFilename);
341  $expectedResult = array('some/template/RootPath/Layouts');
342  $actualResult = $this->view->getLayoutRootPaths();
343  $this->assertEquals($expectedResult, $actualResult);
344  }
345 
351  $this->view->setLayoutRootPath('some/non/existing/Path');
352  $this->view->_call('getLayoutSource');
353  }
354 
360  $this->view->setLayoutRootPaths(array('some/non/existing/Path'));
361  $this->view->_call('getLayoutSource');
362  }
363 
369  $layoutRootPath = __DIR__ . '/Fixtures';
370  $this->view->setLayoutRootPaths(array($layoutRootPath));
371  $this->view->_call('getLayoutSource', 'NonExistingLayout');
372  }
373 
378  $layoutRootPath = GeneralUtility::fixWindowsFilePath(__DIR__) . '/Fixtures';
379  $this->view->setLayoutRootPath($layoutRootPath);
380  $this->mockRequest->expects($this->once())->method('getFormat')->will($this->returnValue('html'));
381  $this->view->expects($this->once())->method('testFileExistence')->with($layoutRootPath . '/LayoutFixture.html')->will($this->returnValue(TRUE));
382  $expectedResult = file_get_contents($layoutRootPath . '/LayoutFixture.html');
383  $actualResult = $this->view->_call('getLayoutSource', 'LayoutFixture');
384  $this->assertEquals($expectedResult, $actualResult);
385  }
386 
391  $layoutRootPath = GeneralUtility::fixWindowsFilePath(__DIR__) . '/Fixtures';
392  $this->view->setLayoutRootPath($layoutRootPath);
393  $this->mockRequest->expects($this->once())->method('getFormat')->will($this->returnValue('xml'));
394  $this->view->expects($this->once())->method('testFileExistence')->with($layoutRootPath . '/LayoutFixture.xml')->will($this->returnValue(TRUE));
395  $expectedResult = file_get_contents($layoutRootPath . '/LayoutFixture.xml');
396  $actualResult = $this->view->_call('getLayoutSource', 'LayoutFixture');
397  $this->assertEquals($expectedResult, $actualResult);
398  }
399 
404  $layoutRootPath = GeneralUtility::fixWindowsFilePath(__DIR__) . '/Fixtures';
405  $this->view->setLayoutRootPath($layoutRootPath);
406  $this->mockRequest->expects($this->once())->method('getFormat')->will($this->returnValue('foo'));
407  $this->view->expects($this->at(0))->method('testFileExistence')->with($layoutRootPath . '/LayoutFixture.foo')->will($this->returnValue(FALSE));
408  $this->view->expects($this->at(1))->method('testFileExistence')->with($layoutRootPath . '/LayoutFixture')->will($this->returnValue(TRUE));
409  $expectedResult = file_get_contents($layoutRootPath . '/LayoutFixture');
410  $actualResult = $this->view->_call('getLayoutSource', 'LayoutFixture');
411  $this->assertEquals($expectedResult, $actualResult);
412  }
413 
419  $this->view->getPartialRootPath();
420  }
421 
426  $templatePathAndFilename = 'some/template/RootPath/SomeTemplate.html';
427  $partialRootPath = 'some/partial/RootPath';
428  $this->view->setTemplatePathAndFilename($templatePathAndFilename);
429  $this->view->setPartialRootPath($partialRootPath);
430  $actualResult = $this->view->getPartialRootPath();
431  $this->assertEquals($partialRootPath, $actualResult);
432  }
433 
438  $templatePathAndFilename = 'some/template/RootPath/SomeTemplate.html';
439  $this->view->setTemplatePathAndFilename($templatePathAndFilename);
440  $expectedResult = 'some/template/RootPath/Partials';
441  $actualResult = $this->view->getPartialRootPath();
442  $this->assertEquals($expectedResult, $actualResult);
443  }
444 
450  $this->view->setPartialRootPath('some/non/existing/Path');
451  $this->view->_call('getPartialSource', 'SomePartial');
452  }
453 
459  $partialRootPath = __DIR__ . '/Fixtures';
460  $this->view->setPartialRootPath($partialRootPath);
461  $this->view->_call('getPartialSource', 'NonExistingPartial');
462  }
463 
468  $partialRootPath = __DIR__ . '/Fixtures';
469  $this->view->setPartialRootPath($partialRootPath);
470  $this->mockRequest->expects($this->once())->method('getFormat')->will($this->returnValue('html'));
471  $this->view->expects($this->once())->method('testFileExistence')->will($this->returnValue(TRUE));
472  $expectedResult = file_get_contents($partialRootPath . '/LayoutFixture.html');
473  $actualResult = $this->view->_call('getPartialSource', 'LayoutFixture');
474  $this->assertEquals($expectedResult, $actualResult);
475  }
476 
481  $partialRootPath = __DIR__ . '/Fixtures';
482  $this->view->setPartialRootPath($partialRootPath);
483  $this->mockRequest->expects($this->once())->method('getFormat')->will($this->returnValue('xml'));
484  $this->view->expects($this->once())->method('testFileExistence')->will($this->returnValue(TRUE));
485  $expectedResult = file_get_contents($partialRootPath . '/LayoutFixture.xml');
486  $actualResult = $this->view->_call('getPartialSource', 'LayoutFixture');
487  $this->assertEquals($expectedResult, $actualResult);
488  }
489 
494  $partialRootPath = __DIR__ . '/Fixtures';
495  $this->view->setPartialRootPath($partialRootPath);
496  $this->mockRequest->expects($this->once())->method('getFormat')->will($this->returnValue('foo'));
497  $this->view->expects($this->at(1))->method('testFileExistence')->will($this->returnValue(TRUE));
498  $expectedResult = file_get_contents($partialRootPath . '/LayoutFixture');
499  $actualResult = $this->view->_call('getPartialSource', 'LayoutFixture');
500  $this->assertEquals($expectedResult, $actualResult);
501  }
502 
507  $this->view->setPartialRootPath('/foo/bar');
508  $this->view->setPartialRootPaths(array('/overruled/path'));
509  $expected = array('/overruled/path');
510  $actual = $this->view->_call('getPartialRootPaths');
511  $this->assertEquals($expected, $actual, 'A set partial root path was not returned correctly.');
512  }
513 
518  $this->view->setLayoutRootPath('/foo/bar');
519  $this->view->setLayoutRootPaths(array('/overruled/path'));
520  $expected = array('/overruled/path');
521  $actual = $this->view->_call('getLayoutRootPaths');
522  $this->assertEquals($expected, $actual, 'A set layout root path was not returned correctly.');
523  }
524 
529  $this->view->setLayoutRootPaths(array('some/Default/Directory'));
530  $this->mockRequest->expects($this->any())->method('getFormat')->will($this->returnValue('html'));
531  $this->view->expects($this->at(0))->method('testFileExistence')->with('some/Default/Directory/LayoutName.html')->willReturn(FALSE);
532  $this->view->expects($this->at(1))->method('testFileExistence')->with('some/Default/Directory/LayoutName')->willReturn(FALSE);
533  $this->view->expects($this->at(2))->method('testFileExistence')->with('some/Default/Directory/layoutName.html')->willReturn(TRUE);
534  $this->assertSame('some/Default/Directory/layoutName.html', $this->view->_call('getLayoutPathAndFilename', 'layoutName'));
535  }
536 
541  $this->view->setLayoutRootPaths(array('some/Default/Directory'));
542  $this->mockRequest->expects($this->any())->method('getFormat')->will($this->returnValue('html'));
543  $this->view->expects($this->at(0))->method('testFileExistence')->with('some/Default/Directory/LayoutName.html')->willReturn(TRUE);
544  $this->assertSame('some/Default/Directory/LayoutName.html', $this->view->_call('getLayoutPathAndFilename', 'layoutName'));
545  }
546 
551  $this->view->setLayoutRootPaths(array(
552  'default' => 'some/Default/Directory',
553  'specific' => 'specific/Layouts',
554  ));
555  $this->mockRequest->expects($this->any())->method('getFormat')->will($this->returnValue('html'));
556  $this->view->expects($this->once())->method('testFileExistence')->with('specific/Layouts/Default.html')->will($this->returnValue(TRUE));
557  $this->assertEquals('specific/Layouts/Default.html', $this->view->_call('getLayoutPathAndFilename'));
558  }
559 
564  $this->view->setLayoutRootPaths(array(
565  'default' => 'some/Default/Directory',
566  'specific' => 'specific/Layouts',
567  ));
568  $this->mockRequest->expects($this->any())->method('getFormat')->will($this->returnValue('html'));
569  $this->view->expects($this->at(2))->method('testFileExistence')->with('some/Default/Directory/Default.html')->will($this->returnValue(TRUE));
570  $this->assertEquals('some/Default/Directory/Default.html', $this->view->_call('getLayoutPathAndFilename'));
571  }
572 
577  $this->view->setLayoutRootPaths(array(
578  '10' => 'some/Default/Directory',
579  '25' => 'evenMore/Specific/Layouts',
580  '17' => 'specific/Layouts',
581  ));
582  $this->mockRequest->expects($this->any())->method('getFormat')->will($this->returnValue('html'));
583  $this->view->expects($this->at(2))->method('testFileExistence')->with('specific/Layouts/Default.html')->will($this->returnValue(TRUE));
584  $this->assertEquals('specific/Layouts/Default.html', $this->view->_call('getLayoutPathAndFilename'));
585  }
586 
591  $this->view->setLayoutRootPaths(array(
592  '10' => 'some/Default/Directory',
593  '25' => 'evenMore/Specific/Layouts',
594  '17' => 'specific/Layouts',
595  ));
596  $this->mockRequest->expects($this->any())->method('getFormat')->will($this->returnValue('html'));
597  $this->view->expects($this->at(4))->method('testFileExistence')->with('some/Default/Directory/Default.html')->will($this->returnValue(TRUE));
598  $this->assertEquals('some/Default/Directory/Default.html', $this->view->_call('getLayoutPathAndFilename'));
599  }
600 
607  $this->view->setLayoutRootPaths(array(
608  '10' => 'some/Default/Directory',
609  '25' => 'evenMore/Specific/Layouts',
610  '17' => 'specific/Layouts',
611  ));
612  $this->view->expects($this->any())->method('testFileExistence')->will($this->returnValue(FALSE));
613  $this->view->_call('getLayoutPathAndFilename');
614 
615  }
616 
621  $this->view->setPartialRootPaths(array('some/Default/Directory'));
622  $this->mockRequest->expects($this->any())->method('getFormat')->will($this->returnValue('html'));
623  $this->view->expects($this->at(0))->method('testFileExistence')->with('some/Default/Directory/PartialName.html')->willReturn(FALSE);
624  $this->view->expects($this->at(1))->method('testFileExistence')->with('some/Default/Directory/PartialName')->willReturn(FALSE);
625  $this->view->expects($this->at(2))->method('testFileExistence')->with('some/Default/Directory/partialName.html')->willReturn(TRUE);
626  $this->assertSame('some/Default/Directory/partialName.html', $this->view->_call('getPartialPathAndFilename', 'partialName'));
627  }
628 
633  $this->view->setPartialRootPaths(array('some/Default/Directory'));
634  $this->mockRequest->expects($this->any())->method('getFormat')->will($this->returnValue('html'));
635  $this->view->expects($this->at(0))->method('testFileExistence')->with('some/Default/Directory/PartialName.html')->willReturn(TRUE);
636  $this->assertSame('some/Default/Directory/PartialName.html', $this->view->_call('getPartialPathAndFilename', 'partialName'));
637  }
638 
643  $this->view->setPartialRootPaths(array(
644  'default' => 'some/Default/Directory',
645  'specific' => 'specific/Partials',
646  ));
647  $this->mockRequest->expects($this->any())->method('getFormat')->will($this->returnValue('html'));
648  $this->view->expects($this->once())->method('testFileExistence')->with('specific/Partials/Partial.html')->will($this->returnValue(TRUE));
649  $this->assertEquals('specific/Partials/Partial.html', $this->view->_call('getPartialPathAndFilename', 'Partial'));
650  }
651 
656  $this->view->setPartialRootPaths(array(
657  'default' => 'some/Default/Directory',
658  'specific' => 'specific/Partials',
659  ));
660  $this->mockRequest->expects($this->any())->method('getFormat')->will($this->returnValue('html'));
661  $this->view->expects($this->at(2))->method('testFileExistence')->with('some/Default/Directory/Partial.html')->will($this->returnValue(TRUE));
662  $this->assertEquals('some/Default/Directory/Partial.html', $this->view->_call('getPartialPathAndFilename', 'Partial'));
663  }
664 
669  $this->view->setPartialRootPaths(array(
670  '10' => 'some/Default/Directory',
671  '25' => 'evenMore/Specific/Partials',
672  '17' => 'specific/Partials',
673  ));
674  $this->mockRequest->expects($this->any())->method('getFormat')->will($this->returnValue('html'));
675  $this->view->expects($this->at(2))->method('testFileExistence')->with('specific/Partials/Partial.html')->will($this->returnValue(TRUE));
676  $this->assertEquals('specific/Partials/Partial.html', $this->view->_call('getPartialPathAndFilename', 'Partial'));
677  }
678 
683  $this->view->setPartialRootPaths(array(
684  '10' => 'some/Default/Directory',
685  '25' => 'evenMore/Specific/Partials',
686  '17' => 'specific/Partials',
687  ));
688  $this->mockRequest->expects($this->any())->method('getFormat')->will($this->returnValue('html'));
689  $this->view->expects($this->at(4))->method('testFileExistence')->with('some/Default/Directory/Partial.html')->will($this->returnValue(TRUE));
690  $this->assertEquals('some/Default/Directory/Partial.html', $this->view->_call('getPartialPathAndFilename', 'Partial'));
691  }
692 
699  $this->view->setPartialRootPaths(array(
700  '10' => 'some/Default/Directory',
701  '25' => 'evenMore/Specific/Partials',
702  '17' => 'specific/Partials',
703  ));
704  $this->view->expects($this->any())->method('testFileExistence')->will($this->returnValue(FALSE));
705  $this->view->_call('getPartialPathAndFilename', 'Partial');
706  }
707 
712  $this->view->setPartialRootPaths(array(
713  '10' => 'some/Default/Directory',
714  '25' => 'evenMore/Specific/Partials',
715  '17' => 'specific/Partials',
716  ));
717  $this->mockRequest->expects($this->any())->method('getFormat')->will($this->returnValue('html'));
718  $this->view->expects($this->at(0))->method('testFileExistence')->with('evenMore/Specific/Partials/Partial.html')->will($this->returnValue(FALSE));
719  $this->view->expects($this->at(1))->method('testFileExistence')->with('evenMore/Specific/Partials/Partial')->will($this->returnValue(FALSE));
720  $this->view->expects($this->at(2))->method('testFileExistence')->with('specific/Partials/Partial.html')->will($this->returnValue(FALSE));
721  $this->view->expects($this->at(3))->method('testFileExistence')->with('specific/Partials/Partial')->will($this->returnValue(FALSE));
722  $this->view->expects($this->at(4))->method('testFileExistence')->with('some/Default/Directory/Partial.html')->will($this->returnValue(FALSE));
723  $this->view->expects($this->at(5))->method('testFileExistence')->with('some/Default/Directory/Partial')->will($this->returnValue(TRUE));
724  $this->assertEquals('some/Default/Directory/Partial', $this->view->_call('getPartialPathAndFilename', 'Partial'));
725  }
726 
731  $this->view->setLayoutRootPaths(array(
732  '10' => 'some/Default/Directory',
733  '25' => 'evenMore/Specific/Layouts',
734  '17' => 'specific/Layouts',
735  ));
736  $this->mockRequest->expects($this->any())->method('getFormat')->will($this->returnValue('html'));
737  $this->view->expects($this->at(0))->method('testFileExistence')->with('evenMore/Specific/Layouts/Default.html')->will($this->returnValue(FALSE));
738  $this->view->expects($this->at(1))->method('testFileExistence')->with('evenMore/Specific/Layouts/Default')->will($this->returnValue(FALSE));
739  $this->view->expects($this->at(2))->method('testFileExistence')->with('specific/Layouts/Default.html')->will($this->returnValue(FALSE));
740  $this->view->expects($this->at(3))->method('testFileExistence')->with('specific/Layouts/Default')->will($this->returnValue(FALSE));
741  $this->view->expects($this->at(4))->method('testFileExistence')->with('some/Default/Directory/Default.html')->will($this->returnValue(FALSE));
742  $this->view->expects($this->at(5))->method('testFileExistence')->with('some/Default/Directory/Default')->will($this->returnValue(TRUE));
743  $this->assertEquals('some/Default/Directory/Default', $this->view->_call('getLayoutPathAndFilename'));
744  }
745 
750  $this->view->setPartialRootPaths(array(
751  'default' => 'some/Default/Directory',
752  'specific' => 'specific/Partials',
753  'verySpecific' => 'evenMore/Specific/Partials',
754  ));
755  $this->mockRequest->expects($this->any())->method('getFormat')->will($this->returnValue('html'));
756  $this->view->expects($this->at(0))->method('testFileExistence')->with('evenMore/Specific/Partials/Partial.html')->will($this->returnValue(FALSE));
757  $this->view->expects($this->at(1))->method('testFileExistence')->with('evenMore/Specific/Partials/Partial')->will($this->returnValue(FALSE));
758  $this->view->expects($this->at(2))->method('testFileExistence')->with('specific/Partials/Partial.html')->will($this->returnValue(FALSE));
759  $this->view->expects($this->at(3))->method('testFileExistence')->with('specific/Partials/Partial')->will($this->returnValue(FALSE));
760  $this->view->expects($this->at(4))->method('testFileExistence')->with('some/Default/Directory/Partial.html')->will($this->returnValue(FALSE));
761  $this->view->expects($this->at(5))->method('testFileExistence')->with('some/Default/Directory/Partial')->will($this->returnValue(TRUE));
762  $this->assertEquals('some/Default/Directory/Partial', $this->view->_call('getPartialPathAndFilename', 'Partial'));
763  }
764 
769  $this->view->setLayoutRootPaths(array(
770  'default' => 'some/Default/Directory',
771  'specific' => 'specific/Layout',
772  'verySpecific' => 'evenMore/Specific/Layout',
773  ));
774  $this->mockRequest->expects($this->any())->method('getFormat')->will($this->returnValue('html'));
775  $this->view->expects($this->at(0))->method('testFileExistence')->with('evenMore/Specific/Layout/Default.html')->will($this->returnValue(FALSE));
776  $this->view->expects($this->at(1))->method('testFileExistence')->with('evenMore/Specific/Layout/Default')->will($this->returnValue(FALSE));
777  $this->view->expects($this->at(2))->method('testFileExistence')->with('specific/Layout/Default.html')->will($this->returnValue(FALSE));
778  $this->view->expects($this->at(3))->method('testFileExistence')->with('specific/Layout/Default')->will($this->returnValue(FALSE));
779  $this->view->expects($this->at(4))->method('testFileExistence')->with('some/Default/Directory/Default.html')->will($this->returnValue(FALSE));
780  $this->view->expects($this->at(5))->method('testFileExistence')->with('some/Default/Directory/Default')->will($this->returnValue(TRUE));
781  $this->assertEquals('some/Default/Directory/Default', $this->view->_call('getLayoutPathAndFilename'));
782  }
783 
784 }
static setSingletonInstance($className, \TYPO3\CMS\Core\SingletonInterface $instance)
static addInstance($className, $instance)
static resetSingletonInstances(array $newSingletonInstances)
getAccessibleMock( $originalClassName, array $methods=array(), array $arguments=array(), $mockClassName='', $callOriginalConstructor=TRUE, $callOriginalClone=TRUE, $callAutoload=TRUE)