Skip to content

Commit 4f37b1a

Browse files
committed
Update test suite to avoid unhandled promise rejections
1 parent b51cc55 commit 4f37b1a

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

composer.json

+7-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"require": {
2929
"php": ">=7.1",
3030
"react/event-loop": "^1.2",
31-
"react/promise": "^3.0 || ^2.8 || ^1.2.1"
31+
"react/promise": "dev-report-unhandled as 3.0.0"
3232
},
3333
"require-dev": {
3434
"phpstan/phpstan": "1.10.18 || 1.4.10",
@@ -41,5 +41,11 @@
4141
},
4242
"autoload-dev": {
4343
"psr-4": { "React\\Tests\\Async\\": "tests/" }
44+
},
45+
"repositories": {
46+
"clue": {
47+
"type": "vcs",
48+
"url": "https://github.com/clue-labs/promise"
49+
}
4450
}
4551
}

tests/CoroutineTest.php

+6
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,8 @@ public function testCoroutineShouldNotCreateAnyGarbageReferencesForPromiseReject
193193
});
194194
});
195195

196+
$promise->then(null, $this->expectCallableOnce()); // avoid reporting unhandled rejection
197+
196198
unset($promise);
197199

198200
$this->assertEquals(0, gc_collect_cycles());
@@ -232,6 +234,8 @@ public function testCoroutineShouldNotCreateAnyGarbageReferencesWhenGeneratorThr
232234
yield; // @phpstan-ignore-line
233235
});
234236

237+
$promise->then(null, $this->expectCallableOnce()); // avoid reporting unhandled rejection
238+
235239
unset($promise);
236240

237241
$this->assertEquals(0, gc_collect_cycles());
@@ -249,6 +253,8 @@ public function testCoroutineShouldNotCreateAnyGarbageReferencesWhenGeneratorYie
249253
yield 42;
250254
});
251255

256+
$promise->then(null, $this->expectCallableOnce()); // avoid reporting unhandled rejection
257+
252258
unset($promise);
253259

254260
$this->assertEquals(0, gc_collect_cycles());

0 commit comments

Comments
 (0)