/** * Processes a generic request and fills the response with the default view * * @param \F3\FLOW3\MVC\RequestInterface $request The request * @param \F3\FLOW3\MVC\ResponseInterface $response The response * @return void * @author Robert Lemke <*****@*****.**> * @author Karsten Dambekalns <*****@*****.**> * @api */ public function processRequest(\F3\FLOW3\MVC\RequestInterface $request, \F3\FLOW3\MVC\ResponseInterface $response) { parent::processRequest($request, $response); $this->notFoundView->setControllerContext($this->controllerContext); if ($this->exception !== NULL) { $this->notFoundView->assign('errorMessage', $this->exception->getMessage()); } switch (get_class($request)) { case 'F3\\FLOW3\\MVC\\Web\\Request': $response->setStatus(404); $response->setContent($this->notFoundView->render()); break; default: $response->setContent("\n404 Not Found\n\n" . "No controller could be resolved which would match your request.\n"); } }
/** * @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()); }