diff --git a/src/Routing/Router.php b/src/Routing/Router.php index bfc7bf2..86c6b6d 100644 --- a/src/Routing/Router.php +++ b/src/Routing/Router.php @@ -83,9 +83,8 @@ class Router implements RouterInterface } } - // If no route exists, set the status code of the response to 404 and - // return the response without propagating. - return $response->withStatus(404); + // If no route exists, delegate to the next middleware. + return $next($request, $response); } /** diff --git a/test/tests/unit/Routing/RouterTest.php b/test/tests/unit/Routing/RouterTest.php index 5f51feb..cbf7913 100644 --- a/test/tests/unit/Routing/RouterTest.php +++ b/test/tests/unit/Routing/RouterTest.php @@ -129,7 +129,6 @@ class RouterTest extends TestCase $this->route->__invoke($this->request, $this->response, $this->next)->shouldHaveBeenCalled(); } - /** @coversNothing */ public function testDispatchesStaticRouteBeforePrefixRoute() { $staticRoute = $this->prophesize('WellRESTed\Routing\Route\RouteInterface'); @@ -357,28 +356,10 @@ class RouterTest extends TestCase )->shouldHaveBeenCalled(); } - // ------------------------------------------------------------------------ - // No Matching Routes - - public function testResponds404WhenNoRouteMatches() - { - $this->request = $this->request->withRequestTarget("/no/match"); - $response = $this->router->__invoke($this->request, $this->response, $this->next); - $this->assertEquals(404, $response->getStatusCode()); - } - - public function testStopsPropagatingWhenNoRouteMatches() + public function testPropagatesToNextMiddlewareWhenNoRouteMatches() { $this->request = $this->request->withRequestTarget("/no/match"); $this->router->__invoke($this->request, $this->response, $this->next); - $this->assertFalse($this->next->called); - } - - public function testRegisterIsFluid() - { - $router = $this->router - ->register("GET", "/", "middleware") - ->register("POST", "/", "middleware"); - $this->assertSame($this->router, $router); + $this->assertTrue($this->next->called); } }