diff --git a/src/AsyncTestCase.php b/src/AsyncTestCase.php index 4a352b3..56601c2 100644 --- a/src/AsyncTestCase.php +++ b/src/AsyncTestCase.php @@ -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 + ); + })); + } }); }); diff --git a/test/AsyncTestCaseTest.php b/test/AsyncTestCaseTest.php index b03eefa..cf40068 100644 --- a/test/AsyncTestCaseTest.php +++ b/test/AsyncTestCaseTest.php @@ -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'); + } }