RouteMap::dispatch calls $next even on failure
This commit is contained in:
parent
c1a104af4f
commit
9470f90ee2
|
|
@ -85,7 +85,7 @@ class RouteMap implements RouteMapInterface
|
|||
}
|
||||
|
||||
// If no route exists, set the status code of the response to 404.
|
||||
return $response->withStatus(404);
|
||||
return $next($request, $response->withStatus(404));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -201,4 +201,22 @@ class RouteMapTest extends \PHPUnit_Framework_TestCase
|
|||
$this->routeMap->dispatch($this->request->reveal(), $this->response->reveal(), $this->next);
|
||||
$this->response->withStatus(404)->shouldHaveBeenCalled();
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::dispatch
|
||||
* @covers ::getStaticRoute
|
||||
* @covers ::getPrefixRoute
|
||||
*/
|
||||
public function testCallsNextWhenNoRouteMatches()
|
||||
{
|
||||
$calledNext = false;
|
||||
$next = function ($request, $response) use (&$calledNext) {
|
||||
$calledNext = true;
|
||||
return $response;
|
||||
};
|
||||
|
||||
$this->response->withStatus(Argument::any())->willReturn($this->response->reveal());
|
||||
$this->routeMap->dispatch($this->request->reveal(), $this->response->reveal(), $next);
|
||||
$this->assertTrue($calledNext);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue