Skip to content

Commit

Permalink
Merge 37c59d1 into 840959c
Browse files Browse the repository at this point in the history
  • Loading branch information
trowski committed Jan 29, 2020
2 parents 840959c + 37c59d1 commit 2f95c2b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/AsyncTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ final public function runAsyncTest(...$args)
$invoked = true;
$exception = $error;
$returnValue = $value;

if ($exception) {
Loop::unreference(Loop::delay(1000, function () use ($exception) {
Loop::stop();
$this->fail(
'An exception was thrown from the test method or promise returned from test method failed),'
. 'but the event loop continued to run; ' . $exception
);
}));
}
});
});

Expand Down
9 changes: 9 additions & 0 deletions test/AsyncTestCaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,13 @@ public function testCreateCallback()

$this->assertSame(2, $mock(1));
}

public function testIssue8()
{
$this->expectException(AssertionFailedError::class);
$this->expectExceptionMessage('the event loop continued to run');

Loop::repeat(1000, static function () {});
throw new \Exception('Test exception');
}
}

0 comments on commit 2f95c2b

Please sign in to comment.