Skip to content

Commit

Permalink
Test Short Circuiting the Middlware Runner
Browse files Browse the repository at this point in the history
  • Loading branch information
WyriHaximus committed Jul 8, 2018
1 parent 23194ef commit 5889dde
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/MiddlewareRunnerTest.php
Expand Up @@ -24,4 +24,21 @@ function (ServerRequestInterface $request) {
self::assertInstanceOf(ResponseInterface::class, $response);
self::assertSame(999, $response->getStatusCode());
}

public function testShortCircuit()
{
$runner = new MiddlewareRunner(function (ServerRequestInterface $request) {
return new Response(666);
});
/** @var ResponseInterface $response */
$response = $this->await($runner(
$this->prophesize(ServerRequestInterface::class)->reveal(),
function (ServerRequestInterface $request) {
return new Response(999);
}
));

self::assertInstanceOf(ResponseInterface::class, $response);
self::assertSame(666, $response->getStatusCode());
}
}

0 comments on commit 5889dde

Please sign in to comment.