/** * @return void */ public function setUp() { $this->viewHelperVariableContainer = $this->createMock(\TYPO3Fluid\Fluid\Core\ViewHelper\ViewHelperVariableContainer::class); $this->viewHelperVariableContainer->expects($this->any())->method('exists')->will($this->returnCallback(array($this, 'viewHelperVariableContainerExistsCallback'))); $this->viewHelperVariableContainer->expects($this->any())->method('get')->will($this->returnCallback(array($this, 'viewHelperVariableContainerGetCallback'))); $this->templateVariableContainer = $this->createMock(TemplateVariableContainer::class); $this->uriBuilder = $this->createMock(\Neos\Flow\Mvc\Routing\UriBuilder::class); $this->uriBuilder->expects($this->any())->method('reset')->will($this->returnValue($this->uriBuilder)); $this->uriBuilder->expects($this->any())->method('setArguments')->will($this->returnValue($this->uriBuilder)); $this->uriBuilder->expects($this->any())->method('setSection')->will($this->returnValue($this->uriBuilder)); $this->uriBuilder->expects($this->any())->method('setFormat')->will($this->returnValue($this->uriBuilder)); $this->uriBuilder->expects($this->any())->method('setCreateAbsoluteUri')->will($this->returnValue($this->uriBuilder)); $this->uriBuilder->expects($this->any())->method('setAddQueryString')->will($this->returnValue($this->uriBuilder)); $this->uriBuilder->expects($this->any())->method('setArgumentsToBeExcludedFromQueryString')->will($this->returnValue($this->uriBuilder)); // BACKPORTER TOKEN #1 $httpRequest = \Neos\Flow\Http\Request::create(new \Neos\Flow\Http\Uri('http://localhost/foo')); $this->request = $this->getMockBuilder(\Neos\Flow\Mvc\ActionRequest::class)->setConstructorArgs(array($httpRequest))->getMock(); $this->request->expects($this->any())->method('isMainRequest')->will($this->returnValue(true)); $this->controllerContext = $this->getMockBuilder(\Neos\Flow\Mvc\Controller\ControllerContext::class)->disableOriginalConstructor()->getMock(); $this->controllerContext->expects($this->any())->method('getUriBuilder')->will($this->returnValue($this->uriBuilder)); $this->controllerContext->expects($this->any())->method('getRequest')->will($this->returnValue($this->request)); $this->tagBuilder = $this->createMock(TagBuilder::class); $this->arguments = array(); $this->renderingContext = new \Neos\FluidAdaptor\Core\Rendering\RenderingContext(new StandaloneView(), []); $this->renderingContext->setVariableProvider($this->templateVariableContainer); $this->renderingContext->setViewHelperVariableContainer($this->viewHelperVariableContainer); $this->renderingContext->setControllerContext($this->controllerContext); }
/** * @test */ public function callingRenderAssignsVariablesCorrectlyToUriBuilder() { $this->uriBuilder->expects($this->once())->method('setSection')->with('section')->will($this->returnSelf()); $this->uriBuilder->expects($this->once())->method('setArguments')->with(array('additionalParams'))->will($this->returnSelf()); $this->uriBuilder->expects($this->once())->method('setArgumentsToBeExcludedFromQueryString')->with(array('argumentsToBeExcludedFromQueryString'))->will($this->returnSelf()); $this->uriBuilder->expects($this->once())->method('setFormat')->with('format')->will($this->returnSelf()); $expectedModifiedArguments = array('module' => 'the/path', 'moduleArguments' => array('arguments', '@action' => 'action')); $this->uriBuilder->expects($this->once())->method('uriFor')->with('index', $expectedModifiedArguments); // fallback for the method chaining of the URI builder $this->uriBuilder->expects($this->any())->method($this->anything())->will($this->returnValue($this->uriBuilder)); $this->viewHelper->render('the/path', 'action', array('arguments'), 'section', 'format', array('additionalParams'), true, array('argumentsToBeExcludedFromQueryString')); }