File tree Expand file tree Collapse file tree 3 files changed +90
-0
lines changed Expand file tree Collapse file tree 3 files changed +90
-0
lines changed Original file line number Diff line number Diff line change 22
33namespace React \Tests \Filesystem \ChildProcess ;
44
5+ use React \EventLoop \Factory ;
56use React \Filesystem \ChildProcess \Adapter ;
67use React \Filesystem \Filesystem ;
78use React \Filesystem \Node \NodeInterface ;
@@ -324,4 +325,17 @@ public function testLs()
324325 ]);
325326 $ this ->assertTrue ($ calledOnData );
326327 }
328+
329+ public function testErrorFromPool ()
330+ {
331+ $ this ->setExpectedException ('\Exception ' , 'oops ' );
332+
333+ $ loop = Factory::create ();
334+ $ adapter = new Adapter ($ loop , [
335+ 'pool ' => [
336+ 'class ' => 'React\Tests\Filesystem\ChildProcess\PoolRpcErrorMockFactory ' ,
337+ ],
338+ ]);
339+ $ this ->await ($ adapter ->touch ('foo.bar ' ), $ loop , 1 );
340+ }
327341}
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace React \Tests \Filesystem \ChildProcess ;
4+
5+ use Evenement \EventEmitter ;
6+ use React \EventLoop \LoopInterface ;
7+ use React \Promise \FulfilledPromise ;
8+ use React \Promise \RejectedPromise ;
9+ use WyriHaximus \React \ChildProcess \Messenger \Messages \Message ;
10+ use WyriHaximus \React \ChildProcess \Messenger \Messages \Rpc ;
11+ use WyriHaximus \React \ChildProcess \Pool \PoolInterface ;
12+ use WyriHaximus \React \ChildProcess \Pool \ProcessCollectionInterface ;
13+
14+ final class PoolRpcErrorMock extends EventEmitter implements PoolInterface
15+ {
16+ public function __construct (ProcessCollectionInterface $ processCollection , LoopInterface $ loop , array $ options = [])
17+ {
18+ // void
19+ }
20+
21+ public function rpc (Rpc $ message )
22+ {
23+ return new RejectedPromise ([
24+ 'error ' => [
25+ 'message ' => 'oops ' ,
26+ ],
27+ ]);
28+ }
29+
30+ public function message (Message $ message )
31+ {
32+ return new FulfilledPromise ();
33+ }
34+
35+ public function terminate (Message $ message , $ timeout = 5 , $ signal = null )
36+ {
37+ return new FulfilledPromise ();
38+ }
39+
40+ public function info ()
41+ {
42+ return [];
43+ }
44+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace React \Tests \Filesystem \ChildProcess ;
4+
5+ use React \ChildProcess \Process ;
6+ use React \EventLoop \Factory ;
7+ use React \EventLoop \LoopInterface ;
8+ use React \Promise \FulfilledPromise ;
9+ use WyriHaximus \React \ChildProcess \Pool \PoolFactoryInterface ;
10+ use WyriHaximus \React \ChildProcess \Pool \ProcessCollection \Single ;
11+
12+ final class PoolRpcErrorMockFactory implements PoolFactoryInterface
13+ {
14+ public static function create (Process $ childProcess , LoopInterface $ loop , array $ options = [])
15+ {
16+ return new FulfilledPromise (new PoolRpcErrorMock (
17+ new Single (function () {}),
18+ Factory::create (),
19+ []
20+ ));
21+ }
22+
23+ public static function createFromClass ($ class , LoopInterface $ loop , array $ options = [])
24+ {
25+ return new FulfilledPromise (new PoolRpcErrorMock (
26+ new Single (function () {}),
27+ Factory::create (),
28+ []
29+ ));
30+ }
31+
32+ }
You can’t perform that action at this time.
0 commit comments