| Total Complexity | 4 |
| Total Lines | 28 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 12 | final class NotFoundHandlerTest extends TestCase |
||
| 13 | { |
||
| 14 | /** |
||
| 15 | * @test |
||
| 16 | */ |
||
| 17 | public function shouldReturnCode404() |
||
| 18 | { |
||
| 19 | $response = $this->createHandler()->handle($this->createRequest()); |
||
| 20 | $this->assertEquals(404, $response->getStatusCode()); |
||
| 21 | } |
||
| 22 | |||
| 23 | /** |
||
| 24 | * @test |
||
| 25 | */ |
||
| 26 | public function shouldReturnCorrectErrorInBody() |
||
| 27 | { |
||
| 28 | $response = $this->createHandler()->handle($this->createRequest('http://site.com/test/path?param=1')); |
||
| 29 | $this->assertEquals('We were unable to find the page /test/path.', (string)$response->getBody()); |
||
| 30 | } |
||
| 31 | |||
| 32 | private function createHandler(): NotFoundHandler |
||
| 33 | { |
||
| 34 | return new NotFoundHandler(new Psr17Factory()); |
||
| 35 | } |
||
| 36 | |||
| 37 | private function createRequest(string $uri = '/'): ServerRequestInterface |
||
| 40 | } |
||
| 41 | } |
||
| 42 |