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