From 4f37b1a8d42efabfda751d32a8a7320ffd1c98aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCck?= Date: Thu, 6 Jul 2023 09:58:33 +0200 Subject: [PATCH] Update test suite to avoid unhandled promise rejections --- composer.json | 8 +++++++- tests/CoroutineTest.php | 6 ++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index e208dd3..633cce6 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ "require": { "php": ">=7.1", "react/event-loop": "^1.2", - "react/promise": "^3.0 || ^2.8 || ^1.2.1" + "react/promise": "dev-report-unhandled as 3.0.0" }, "require-dev": { "phpstan/phpstan": "1.10.18 || 1.4.10", @@ -41,5 +41,11 @@ }, "autoload-dev": { "psr-4": { "React\\Tests\\Async\\": "tests/" } + }, + "repositories": { + "clue": { + "type": "vcs", + "url": "https://github.com/clue-labs/promise" + } } } diff --git a/tests/CoroutineTest.php b/tests/CoroutineTest.php index c9b7439..2c674c5 100644 --- a/tests/CoroutineTest.php +++ b/tests/CoroutineTest.php @@ -193,6 +193,8 @@ public function testCoroutineShouldNotCreateAnyGarbageReferencesForPromiseReject }); }); + $promise->then(null, $this->expectCallableOnce()); // avoid reporting unhandled rejection + unset($promise); $this->assertEquals(0, gc_collect_cycles()); @@ -232,6 +234,8 @@ public function testCoroutineShouldNotCreateAnyGarbageReferencesWhenGeneratorThr yield; // @phpstan-ignore-line }); + $promise->then(null, $this->expectCallableOnce()); // avoid reporting unhandled rejection + unset($promise); $this->assertEquals(0, gc_collect_cycles()); @@ -249,6 +253,8 @@ public function testCoroutineShouldNotCreateAnyGarbageReferencesWhenGeneratorYie yield 42; }); + $promise->then(null, $this->expectCallableOnce()); // avoid reporting unhandled rejection + unset($promise); $this->assertEquals(0, gc_collect_cycles());