/** * 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 renderReplacesErrorMessageMarker() { $mockRequest = $this->getMock('\\F3\\FLOW3\\MVC\\RequestInterface'); $this->controllerContext->expects($this->any())->method('getRequest')->will($this->returnValue($mockRequest)); $templateUrl = \vfsStream::url('testDirectory') . '/template.html'; file_put_contents($templateUrl, 'error message: ###ERROR_MESSAGE###'); $this->view->expects($this->once())->method('getTemplatePathAndFilename')->will($this->returnValue($templateUrl)); $this->view->assign('errorMessage', 'some error message'); $this->assertSame('error message: some error message', $this->view->render()); }