/** * Sets up this test case * * @return void */ protected function setUp() { $this->singletonInstances = GeneralUtility::getSingletonInstances(); $this->view = $this->getAccessibleMock(\TYPO3\CMS\Fluid\View\StandaloneView::class, array('testFileExistence', 'buildParserConfiguration', 'getOrParseAndStoreTemplate'), array(), '', false); $this->mockConfigurationManager = $this->getMock(ConfigurationManagerInterface::class); $this->mockObjectManager = $this->getMock(\TYPO3\CMS\Extbase\Object\ObjectManager::class); $this->mockObjectManager->expects($this->any())->method('get')->will($this->returnCallback(array($this, 'objectManagerCallback'))); $this->mockRequest = $this->getMock(Request::class); $this->mockUriBuilder = $this->getMock(UriBuilder::class); $this->mockContentObject = $this->getMock(\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class); $this->mockControllerContext = $this->getMock(ControllerContext::class); $this->mockControllerContext->expects($this->any())->method('getRequest')->will($this->returnValue($this->mockRequest)); $this->mockTemplatePaths = $this->getMock(TemplatePaths::class); $this->mockViewHelperVariableContainer = $this->getMock(ViewHelperVariableContainer::class); $this->mockRenderingContext = $this->getMock(\TYPO3\CMS\Fluid\Tests\Unit\Core\Rendering\RenderingContextFixture::class); $this->mockRenderingContext->expects($this->any())->method('getControllerContext')->will($this->returnValue($this->mockControllerContext)); $this->mockRenderingContext->expects($this->any())->method('getViewHelperVariableContainer')->will($this->returnValue($this->mockViewHelperVariableContainer)); $this->mockRenderingContext->expects($this->any())->method('getVariableProvider')->willReturn($this->mockVariableProvider); $this->mockRenderingContext->expects($this->any())->method('getTemplatePaths')->willReturn($this->mockTemplatePaths); $this->view->_set('objectManager', $this->mockObjectManager); $this->view->_set('baseRenderingContext', $this->mockRenderingContext); $this->view->_set('controllerContext', $this->mockControllerContext); $this->view->expects($this->any())->method('getOrParseAndStoreTemplate')->willReturn($this->mockParsedTemplate); GeneralUtility::setSingletonInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class, $this->mockObjectManager); GeneralUtility::addInstance(\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class, $this->mockContentObject); $this->mockCacheManager = $this->getMock(\TYPO3\CMS\Core\Cache\CacheManager::class, array(), array(), '', false); $mockCache = $this->getMock(\TYPO3Fluid\Fluid\Core\Cache\FluidCacheInterface::class, array(), array(), '', false); $this->mockCacheManager->expects($this->any())->method('getCache')->will($this->returnValue($mockCache)); GeneralUtility::setSingletonInstance(\TYPO3\CMS\Core\Cache\CacheManager::class, $this->mockCacheManager); }
/** * @test */ public function renderCallsStandardWrapOnResultStringIfGivenInConfiguration() { $this->addMockViewToSubject(); $configuration = array('stdWrap.' => array('foo' => 'bar')); $this->standaloneView->expects($this->any())->method('render')->will($this->returnValue('baz')); $this->contentObjectRenderer->expects($this->once())->method('stdWrap')->with('baz', array('foo' => 'bar')); $this->subject->render($configuration); }
/** * @test */ public function getLayoutPathAndFilenameWalksStringKeysInReversedOrder() { $this->view->setLayoutRootPaths(array('default' => 'some/Default/Directory', 'specific' => 'specific/Layout', 'verySpecific' => 'evenMore/Specific/Layout')); $this->mockRequest->expects($this->any())->method('getFormat')->will($this->returnValue('html')); $this->view->expects($this->at(0))->method('testFileExistence')->with('evenMore/Specific/Layout/Default.html')->will($this->returnValue(FALSE)); $this->view->expects($this->at(1))->method('testFileExistence')->with('evenMore/Specific/Layout/Default')->will($this->returnValue(FALSE)); $this->view->expects($this->at(2))->method('testFileExistence')->with('specific/Layout/Default.html')->will($this->returnValue(FALSE)); $this->view->expects($this->at(3))->method('testFileExistence')->with('specific/Layout/Default')->will($this->returnValue(FALSE)); $this->view->expects($this->at(4))->method('testFileExistence')->with('some/Default/Directory/Default.html')->will($this->returnValue(FALSE)); $this->view->expects($this->at(5))->method('testFileExistence')->with('some/Default/Directory/Default')->will($this->returnValue(TRUE)); $this->assertEquals('some/Default/Directory/Default', $this->view->_call('getLayoutPathAndFilename')); }
/** * @test */ public function setTemplateWalksStringKeysInReversedOrder() { $this->view->setTemplateRootPaths(array('default' => 'some/Default/Directory', 'specific' => 'specific/Templates', 'verySpecific' => 'evenMore/Specific/Templates')); $this->mockRequest->expects($this->any())->method('getFormat')->will($this->returnValue('html')); $this->view->expects($this->at(0))->method('testFileExistence')->with(PATH_site . 'evenMore/Specific/Templates/Template.html')->will($this->returnValue(false)); $this->view->expects($this->at(1))->method('testFileExistence')->with(PATH_site . 'evenMore/Specific/Templates/Template')->will($this->returnValue(false)); $this->view->expects($this->at(2))->method('testFileExistence')->with(PATH_site . 'specific/Templates/Template.html')->will($this->returnValue(false)); $this->view->expects($this->at(3))->method('testFileExistence')->with(PATH_site . 'specific/Templates/Template')->will($this->returnValue(false)); $this->view->expects($this->at(4))->method('testFileExistence')->with(PATH_site . 'some/Default/Directory/Template.html')->will($this->returnValue(false)); $this->view->expects($this->at(5))->method('testFileExistence')->with(PATH_site . 'some/Default/Directory/Template')->will($this->returnValue(true)); $this->view->setTemplate('Template'); $this->assertEquals(PATH_site . 'some/Default/Directory/Template', $this->view->getTemplatePathAndFilename()); }