33namespace WyriHaximus \React \Tests \Parallel ;
44
55use React \EventLoop \Factory ;
6+ use React \Promise \ExtendedPromiseInterface ;
67use WyriHaximus \AsyncTestUtilities \AsyncTestCase ;
78use WyriHaximus \React \Parallel \FutureToPromiseConverter ;
89use WyriHaximus \React \Parallel \Runtime ;
@@ -18,12 +19,17 @@ public function testConvertSuccess(): void
1819 $ loop = Factory::create ();
1920 $ runtime = new Runtime (new FutureToPromiseConverter ($ loop ), \dirname (__DIR__ ) . '/vendor/autoload.php ' );
2021
22+ /** @var ExtendedPromiseInterface $promise */
2123 $ promise = $ runtime ->run (function () {
2224 sleep (3 );
2325
2426 return 3 ;
2527 });
2628
29+ $ promise ->always (function () use ($ runtime ): void {
30+ $ runtime ->close ();
31+ });
32+
2733 $ loop ->run ();
2834 $ three = $ this ->await ($ promise , $ loop , 3.3 );
2935
@@ -38,12 +44,17 @@ public function testConvertFailure(): void
3844 $ loop = Factory::create ();
3945 $ runtime = new Runtime (new FutureToPromiseConverter ($ loop ), \dirname (__DIR__ ) . '/vendor/autoload.php ' );
4046
47+ /** @var ExtendedPromiseInterface $promise */
4148 $ promise = $ runtime ->run (function (): void {
4249 sleep (3 );
4350
4451 throw new \Exception ('Rethrow exception ' );
4552 });
4653
54+ $ promise ->always (function () use ($ runtime ): void {
55+ $ runtime ->close ();
56+ });
57+
4758 $ loop ->run ();
4859 $ three = $ this ->await ($ promise , $ loop , 3.3 );
4960
0 commit comments