public function testInvocationWillSetResponsePrototypeIfNotAlreadySet()
{
$response = $this->prophesize(ResponseInterface::class)->reveal();
$request = $this->request->withUri(new Uri('http://local.example.com/foo'));
$route = new Route('/foo', function ($req, $res, $next) {
return $res;
});
$this->queue->enqueue($route);
$next = new Next($this->queue, function () {
Assert::fail('Done argument called, when it should not have been');
});
$this->assertSame($response, $next($request, $response));
$this->assertAttributeSame($response, 'responsePrototype', $next);
$r = new ReflectionProperty($next, 'dispatch');
$r->setAccessible(true);
$dispatch = $r->getValue($next);
$this->assertAttributeSame($response, 'responsePrototype', $dispatch);
}