/**
  * 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));
 }
예제 #2
0
 public function __invoke(ServerRequestInterface $request, ResponseInterface $response)
 {
     parent::__invoke($request, $response);
     $this->view->render($response, '404.html');
     return $response->withStatus(404);
 }
예제 #3
0
 /**
  * {inheritdoc}
  */
 public function __invoke(ServerRequestInterface $request, ResponseInterface $response)
 {
     $this->logger->warning('Not found', [$request->getMethod() => (string) $request->getUri()]);
     return parent::__invoke($request, $response);
 }