/** * @test */ public function getPartialSourceReturnsContentOfDefaultPartialFileIfNoPartialExistsForTheSpecifiedFormat() { $partialRootPath = __DIR__ . '/Fixtures'; $this->view->setPartialRootPath($partialRootPath); $this->mockRequest->expects($this->once())->method('getFormat')->will($this->returnValue('foo')); $expectedResult = file_get_contents($partialRootPath . '/LayoutFixture'); $actualResult = $this->view->_call('getPartialSource', 'LayoutFixture'); $this->assertEquals($expectedResult, $actualResult); }
/** * @test */ public function buildBackendUriCreatesAbsoluteUrisIfSpecified() { \TYPO3\CMS\Core\Utility\GeneralUtility::_GETset(array('M' => 'moduleKey')); $this->mockRequest->expects($this->any())->method('getBaseUri')->will($this->returnValue('http://baseuri/' . TYPO3_mainDir)); $this->uriBuilder->setCreateAbsoluteUri(TRUE); $expectedResult = 'http://baseuri/' . TYPO3_mainDir . 'mod.php?M=moduleKey&moduleToken=dummyToken'; $actualResult = $this->uriBuilder->buildBackendUri(); $this->assertSame($expectedResult, $actualResult); }
/** * @test */ public function buildSetsDefaultActionNameIfSpecifiedActionIsNotAllowedAndCallDefaultActionIfActionCantBeResolvedIsSet() { $this->configuration['mvc']['callDefaultActionIfActionCantBeResolved'] = 1; $this->injectDependencies(); $this->requestBuilder->_set('extensionService', $this->mockExtensionService); $_GET = array('tx_myextension_pi1' => array('controller' => 'TheThirdController', 'action' => 'someInvalidAction')); $this->mockRequest->expects($this->once())->method('setControllerName')->with('TheThirdController'); $this->mockRequest->expects($this->once())->method('setControllerActionName')->with('delete'); $this->requestBuilder->build(); }
/** * @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()); }
/** * @test */ public function buildTypolinkConfigurationResolvesPageTypeFromFormat() { $this->uriBuilder->setTargetPageUid(123); $this->uriBuilder->setFormat('txt'); $this->mockRequest->expects($this->once())->method('getControllerExtensionName')->will($this->returnValue('SomeExtensionNameFromRequest')); $mockConfigurationManager = $this->getMock(ConfigurationManager::class); $mockConfigurationManager->expects($this->any())->method('getConfiguration')->will($this->returnValue(array('view' => array('formatToPageTypeMapping' => array('txt' => 2))))); $this->uriBuilder->_set('configurationManager', $mockConfigurationManager); $this->mockExtensionService->expects($this->any())->method('getTargetPageTypeByFormat')->with('SomeExtensionNameFromRequest', 'txt')->will($this->returnValue(2)); $expectedConfiguration = array('parameter' => '123,2', 'useCacheHash' => 1); $actualConfiguration = $this->uriBuilder->_call('buildTypolinkConfiguration'); $this->assertEquals($expectedConfiguration, $actualConfiguration); }
/** * @test */ public function initiateSubRequestBuildsRequestProperly() { $controller = $this->getMock(\TYPO3\CMS\Fluid\Core\Widget\AbstractWidgetController::class, array(), array(), '', FALSE); $this->viewHelper->_set('controller', $controller); // Initial Setup $widgetRequest = $this->getMock(\TYPO3\CMS\Fluid\Core\Widget\WidgetRequest::class); $response = $this->getMock(\TYPO3\CMS\Extbase\Mvc\Web\Response::class); $this->objectManager->expects($this->at(0))->method('get')->with(\TYPO3\CMS\Fluid\Core\Widget\WidgetRequest::class)->will($this->returnValue($widgetRequest)); $this->objectManager->expects($this->at(1))->method('get')->with(\TYPO3\CMS\Extbase\Mvc\Web\Response::class)->will($this->returnValue($response)); // Widget Context is set $widgetRequest->expects($this->once())->method('setWidgetContext')->with($this->widgetContext); // The namespaced arguments are passed to the sub-request // and the action name is exctracted from the namespace. $this->controllerContext->expects($this->once())->method('getRequest')->will($this->returnValue($this->request)); $this->widgetContext->expects($this->once())->method('getWidgetIdentifier')->will($this->returnValue('widget-1')); $this->request->expects($this->once())->method('getArguments')->will($this->returnValue(array('k1' => 'k2', 'widget-1' => array('arg1' => 'val1', 'arg2' => 'val2', 'action' => 'myAction')))); $widgetRequest->expects($this->once())->method('setArguments')->with(array('arg1' => 'val1', 'arg2' => 'val2')); $widgetRequest->expects($this->once())->method('setControllerActionName')->with('myAction'); // Controller is called $controller->expects($this->once())->method('processRequest')->with($widgetRequest, $response); $output = $this->viewHelper->_call('initiateSubRequest'); // SubResponse is returned $this->assertSame($response, $output); }
/** * @test */ public function setFormatSetsRequestFormat() { $this->mockRequest->expects($this->once())->method('setFormat')->with('xml'); $this->view->setFormat('xml'); }