/** * Add a variable to $this->variables. * Can be chained, so $this->view->assign(..., ...)->assign(..., ...); is possible, * * @param string $key Key of variable * @param object $value Value of object * @return \F3\FLOW3\MVC\View\ViewInterface an instance of $this, to enable chaining. * @author Christopher Hlubek <*****@*****.**> * @api */ public function assign($key, $value) { if ($key === 'result') { // TODO throw up if response is not a Ext Direct response $this->controllerContext->getResponse()->setResult($value); } elseif ($key === 'success') { // TODO throw up if response is not a Ext Direct response $this->controllerContext->getResponse()->setSuccess($value); } return $this; }
/** * @test * @author Bastian Waidelich <*****@*****.**> */ public function renderReturnsContentOfTemplateAndReplacesBaseUriMarkerIfRequestIsNoWebRequest() { $mockRequest = $this->getMock('\\F3\\FLOW3\\MVC\\RequestInterface'); $mockRequest->expects($this->never())->method('getBaseUri'); $this->controllerContext->expects($this->any())->method('getRequest')->will($this->returnValue($mockRequest)); $templateContent = file_get_contents(FLOW3_PATH_FLOW3 . 'Resources/Private/MVC/StandardView_Template.html'); $this->assertSame($templateContent, $this->view->render()); $this->assertContains('###BASEURI###', $templateContent); }
/** * @test * @author Bastian Waidelich <*****@*****.**> */ public function renderDoesNotReplaceBaseUriMarkerIfRequestIsNoWebRequest() { $mockRequest = $this->getMock('\\F3\\FLOW3\\MVC\\RequestInterface'); $mockRequest->expects($this->never())->method('getBaseUri'); $this->controllerContext->expects($this->any())->method('getRequest')->will($this->returnValue($mockRequest)); $templateUrl = \vfsStream::url('testDirectory') . '/template.html'; file_put_contents($templateUrl, 'base URI: ###BASEURI###'); $this->view->expects($this->once())->method('getTemplatePathAndFilename')->will($this->returnValue($templateUrl)); $this->assertSame('base URI: ###BASEURI###', $this->view->render()); }
/** * @return void * @author Sebastian Kurfürst <*****@*****.**> */ public function setUp() { $this->viewHelperVariableContainer = $this->getMock('F3\\Fluid\\Core\\ViewHelper\\ViewHelperVariableContainer'); $this->templateVariableContainer = $this->getMock('F3\\Fluid\\Core\\ViewHelper\\TemplateVariableContainer'); $this->uriBuilder = $this->getMock('F3\\FLOW3\\MVC\\Web\\Routing\\UriBuilder'); $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 $this->request = $this->getMock('F3\\FLOW3\\MVC\\Web\\Request'); $this->controllerContext = $this->getMock('F3\\FLOW3\\MVC\\Controller\\Context', array(), array(), '', FALSE); $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->getMock('F3\\Fluid\\Core\\ViewHelper\\TagBuilder'); $this->arguments = $this->getMock('F3\\Fluid\\Core\\ViewHelper\\Arguments', array(), array(), '', FALSE); }