|
@@ 77-98 (lines=22) @@
|
| 74 |
|
$this->handle($request, $response)->shouldBe($response); |
| 75 |
|
} |
| 76 |
|
|
| 77 |
|
function it_returns_a_406_response_if_request_not_accepted( |
| 78 |
|
ServerRequestInterface $request, |
| 79 |
|
ResponseInterface $response, |
| 80 |
|
RouterContainer $routerContainer, |
| 81 |
|
Matcher $matcher |
| 82 |
|
) { |
| 83 |
|
$routerContainer->getMatcher()->willReturn($matcher); |
| 84 |
|
$matcher->match($request)->willReturn(null); |
| 85 |
|
$failRoute = new Route(); |
| 86 |
|
$failRoute->failedRule('Aura\Router\Rule\Accepts'); |
| 87 |
|
$matcher->getFailedRoute()->willReturn($failRoute); |
| 88 |
|
|
| 89 |
|
$request->withAttribute('route', null) |
| 90 |
|
->willReturn($request); |
| 91 |
|
|
| 92 |
|
$response->withStatus(406) |
| 93 |
|
->shouldBeCalled() |
| 94 |
|
->willReturn($response); |
| 95 |
|
|
| 96 |
|
$this->beConstructedWith($routerContainer); |
| 97 |
|
$this->handle($request, $response)->shouldBe($response); |
| 98 |
|
} |
| 99 |
|
|
| 100 |
|
function it_returns_a_404_response_for_all_other_failed_routes( |
| 101 |
|
ServerRequestInterface $request, |
|
@@ 100-121 (lines=22) @@
|
| 97 |
|
$this->handle($request, $response)->shouldBe($response); |
| 98 |
|
} |
| 99 |
|
|
| 100 |
|
function it_returns_a_404_response_for_all_other_failed_routes( |
| 101 |
|
ServerRequestInterface $request, |
| 102 |
|
ResponseInterface $response, |
| 103 |
|
RouterContainer $routerContainer, |
| 104 |
|
Matcher $matcher |
| 105 |
|
) { |
| 106 |
|
$routerContainer->getMatcher()->willReturn($matcher); |
| 107 |
|
$matcher->match($request)->willReturn(null); |
| 108 |
|
$failRoute = new Route(); |
| 109 |
|
$failRoute->failedRule('other'); |
| 110 |
|
$matcher->getFailedRoute()->willReturn($failRoute); |
| 111 |
|
|
| 112 |
|
$request->withAttribute('route', null) |
| 113 |
|
->willReturn($request); |
| 114 |
|
|
| 115 |
|
$response->withStatus(404) |
| 116 |
|
->shouldBeCalled() |
| 117 |
|
->willReturn($response); |
| 118 |
|
|
| 119 |
|
$this->beConstructedWith($routerContainer); |
| 120 |
|
$this->handle($request, $response)->shouldBe($response); |
| 121 |
|
} |
| 122 |
|
} |
| 123 |
|
|