Skip to content

Commit

Permalink
Ensure the running method outputs are tested
Browse files Browse the repository at this point in the history
  • Loading branch information
WyriHaximus committed Mar 4, 2017
1 parent 510e2eb commit 86dac9e
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions tests/MiddlewareRunnerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Psr7\Response;
use Phake;
use React\EventLoop\Factory;
use Throwable;
use function Clue\React\Block\await;
use function React\Promise\reject;
use function React\Promise\resolve;
Expand All @@ -17,6 +19,7 @@ class MiddlewareRunnerTest extends TestCase
{
public function testAll()
{
$loop = Factory::create();
$request = new Request('GET', 'https://example.com/');
$response = new Response(200);
$exception = new Exception();
Expand Down Expand Up @@ -48,9 +51,13 @@ public function testAll()
];

$executioner = new MiddlewareRunner(...$args);
$executioner->pre($request);
$executioner->post($response);
$executioner->error($exception);
self::assertSame($request, await($executioner->pre($request), $loop));
self::assertSame($response, await($executioner->post($response), $loop));
try {
await($executioner->error($exception), $loop);
} catch (Throwable $throwable) {
self::assertSame($exception, $throwable);
}

Phake::inOrder(
Phake::verify($middlewareOne)->pre($request, $options),
Expand Down

0 comments on commit 86dac9e

Please sign in to comment.