RouteMap::dispatch calls $next even on failure

This commit is contained in:
PJ Dietz 2015-05-09 20:20:06 -04:00
parent c1a104af4f
commit 9470f90ee2
2 changed files with 19 additions and 1 deletions

View File

@ -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));
}
/**

View File

@ -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);
}
}