diff --git a/src/Routing/RouteMap.php b/src/Routing/RouteMap.php index 4c76327..4575195 100644 --- a/src/Routing/RouteMap.php +++ b/src/Routing/RouteMap.php @@ -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)); } /** diff --git a/test/tests/unit/Routing/RouteMapTest.php b/test/tests/unit/Routing/RouteMapTest.php index ff632a4..dc867cd 100644 --- a/test/tests/unit/Routing/RouteMapTest.php +++ b/test/tests/unit/Routing/RouteMapTest.php @@ -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); + } }