/** * @test */ public function renderReplacesErrorMessageMarker() { $mockRequest = $this->getMock('\\TYPO3\\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()); }
/** * Processes a generic request and fills the response with the default view * * @param \TYPO3\FLOW3\Mvc\RequestInterface $request The request object * @param \TYPO3\FLOW3\Mvc\ResponseInterface $response The response, modified by this handler * @return void * @api */ public function processRequest(\TYPO3\FLOW3\Mvc\RequestInterface $request, \TYPO3\FLOW3\Mvc\ResponseInterface $response) { $this->initializeController($request, $response); $this->notFoundView->setControllerContext($this->controllerContext); if ($this->exception !== NULL) { $this->notFoundView->assign('errorMessage', $this->exception->getMessage()); } switch (get_class($request)) { case 'TYPO3\\FLOW3\\Mvc\\ActionRequest': $response->setStatus(404); $response->setContent($this->notFoundView->render()); break; default: $response->setContent("\nUnknown command\n\n"); } }