public function testMiddlewareReturningResponseShortcircuits()
{
$phpunit = $this;
$route1 = new Route('/foo', function ($req, $res, $next) {
return $res;
});
$route2 = new Route('/foo/bar', function ($req, $res, $next) use($phpunit) {
$next($req, $res);
$phpunit->fail('Should not hit route2 handler');
});
$route3 = new Route('/foo/baz', function ($req, $res, $next) use($phpunit) {
$next($req, $res);
$phpunit->fail('Should not hit route3 handler');
});
$this->queue->enqueue($route1);
$this->queue->enqueue($route2);
$this->queue->enqueue($route3);
$done = function ($req, $res, $err) use($phpunit) {
$phpunit->fail('Should not hit final handler');
};
$request = $this->request->withUri(new Uri('http://example.com/foo/bar/baz'));
$next = new Next($this->queue, $done);
$result = $next($request, $this->response);
$this->assertSame($this->response, $result);
}