diff --git a/src/core/class_map/Hyperf/Coroutine/Coroutine.php b/src/core/class_map/Hyperf/Coroutine/Coroutine.php index 5c3680e3..73349821 100644 --- a/src/core/class_map/Hyperf/Coroutine/Coroutine.php +++ b/src/core/class_map/Hyperf/Coroutine/Coroutine.php @@ -138,6 +138,14 @@ public static function list(): iterable return Co::list(); } + /** + * Flush after created callbacks. + */ + public static function flushAfterCreated(): void + { + static::$afterCreatedCallbacks = []; + } + private static function printLog(Throwable $throwable): void { if (ApplicationContext::hasContainer()) { diff --git a/src/foundation/src/Testing/TestCase.php b/src/foundation/src/Testing/TestCase.php index 0361d5b6..04c3bea8 100644 --- a/src/foundation/src/Testing/TestCase.php +++ b/src/foundation/src/Testing/TestCase.php @@ -121,6 +121,8 @@ protected function tearDown(): void fn () => $this->callBeforeApplicationDestroyedCallbacks() ); $this->flushApplication(); + /* @phpstan-ignore-next-line */ + Coroutine::flushAfterCreated(); } $this->afterApplicationCreatedCallbacks = [];