public function testProcessReinvokesItselfIfRouteDoesNotMatchAtABoundary()
{
// e.g., if route is "/foo", but path is "/foobar", no match
$done = function ($req, $res, $err = null) {
Assert::fail('Should not have hit the done handler, but did');
};
$request = $this->request->withUri(new Uri('http://local.example.com/foobar'));
$response = $this->prophesize(ResponseInterface::class)->reveal();
$first = $this->prophesize(ServerMiddlewareInterface::class);
$first->process($request, Argument::type(Next::class))->will(function () {
// This one should be skipped
Assert::fail('Route should not be invoked if path does not match');
});
$this->queue->enqueue(new Route('/foo', $first->reveal()));
$second = $this->prophesize(ServerMiddlewareInterface::class);
$second->process(Argument::type(RequestInterface::class), Argument::type(Next::class))->willReturn($response);
$this->queue->enqueue(new Route('/foobar', $second->reveal()));
$next = new Next($this->queue, $done);
$next->setResponsePrototype($response);
$this->assertSame($response, $next->process($request));
}