3
3
namespace WyriHaximus \React \Tests \Parallel ;
4
4
5
5
use React \EventLoop \Factory ;
6
+ use React \Promise \ExtendedPromiseInterface ;
6
7
use WyriHaximus \AsyncTestUtilities \AsyncTestCase ;
7
8
use WyriHaximus \React \Parallel \FutureToPromiseConverter ;
8
9
use WyriHaximus \React \Parallel \Runtime ;
@@ -18,12 +19,17 @@ public function testConvertSuccess(): void
18
19
$ loop = Factory::create ();
19
20
$ runtime = new Runtime (new FutureToPromiseConverter ($ loop ), \dirname (__DIR__ ) . '/vendor/autoload.php ' );
20
21
22
+ /** @var ExtendedPromiseInterface $promise */
21
23
$ promise = $ runtime ->run (function () {
22
24
sleep (3 );
23
25
24
26
return 3 ;
25
27
});
26
28
29
+ $ promise ->always (function () use ($ runtime ): void {
30
+ $ runtime ->close ();
31
+ });
32
+
27
33
$ loop ->run ();
28
34
$ three = $ this ->await ($ promise , $ loop , 3.3 );
29
35
@@ -38,12 +44,17 @@ public function testConvertFailure(): void
38
44
$ loop = Factory::create ();
39
45
$ runtime = new Runtime (new FutureToPromiseConverter ($ loop ), \dirname (__DIR__ ) . '/vendor/autoload.php ' );
40
46
47
+ /** @var ExtendedPromiseInterface $promise */
41
48
$ promise = $ runtime ->run (function (): void {
42
49
sleep (3 );
43
50
44
51
throw new \Exception ('Rethrow exception ' );
45
52
});
46
53
54
+ $ promise ->always (function () use ($ runtime ): void {
55
+ $ runtime ->close ();
56
+ });
57
+
47
58
$ loop ->run ();
48
59
$ three = $ this ->await ($ promise , $ loop , 3.3 );
49
60
0 commit comments