/**
  * Test invalid method returns the correct code and content type
  *
  * @dataProvider notFoundProvider
  */
 public function testNotFound($contentType, $startOfBody)
 {
     $notAllowed = new NotFound();
     /** @var Response $res */
     $res = $notAllowed->__invoke($this->getRequest('GET', $contentType), new Response(), ['POST', 'PUT']);
     $this->assertSame(404, $res->getStatusCode());
     $this->assertSame($contentType, $res->getHeaderLine('Content-Type'));
     $this->assertEquals(0, strpos((string) $res->getBody(), $startOfBody));
 }
 /**
  * {inheritdoc}
  */
 protected function renderHtmlNotFoundOutput(ServerRequestInterface $request, ResponseInterface $response)
 {
     if (is_null($this->view)) {
         return parent::renderHtmlNotFoundOutput($request, $response);
     }
     $title = 'Page Not Found';
     $desc = 'The page you are looking for could not be found. Check the address bar to ensure your URL is spelled correctly. If all else fails, you can visit our home page at the link below.';
     $homeUrl = (string) $request->getUri()->withPath('')->withQuery('')->withFragment('');
     $this->view->addData(compact('title', 'desc', 'homeUrl'));
     return $this->view->render('error-404');
 }
Beispiel #3
0
 public function __invoke(ServerRequestInterface $request, ResponseInterface $response)
 {
     parent::__invoke($request, $response);
     $this->view->render($response, '404.html');
     return $response->withStatus(404);
 }