Router delegates on failure and does not return 404
This commit is contained in:
parent
f016b74c38
commit
29cad3687e
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue