1
1
<?php
2
2
3
3
use Clue \React \Shell \ProcessLauncher ;
4
- use React \Stream \ReadableStream ;
5
4
6
5
class ProcessLauncherTest extends TestCase
7
6
{
@@ -30,9 +29,12 @@ public function testProcessWillBeStarted()
30
29
public function testClosingStreamTerminatesRunningProcess ()
31
30
{
32
31
$ process = $ this ->getMockBuilder ('React\ChildProcess\Process ' )->disableOriginalConstructor ()->getMock ();
33
- $ process ->stdout = new ReadableStream ();
32
+ $ process ->stdout = $ this -> getMockBuilder ( ' React\Stream\ReadableStreamInterface ' )-> getMock ();
34
33
$ process ->stdin = $ this ->getMockBuilder ('React\Stream\WritableStreamInterface ' )->getMock ();
35
34
35
+ $ process ->stdout ->expects ($ this ->any ())->method ('isReadable ' )->willReturn (true );
36
+ $ process ->stdin ->expects ($ this ->any ())->method ('isWritable ' )->willReturn (true );
37
+
36
38
$ process ->expects ($ this ->once ())->method ('isRunning ' )->will ($ this ->returnValue (true ));
37
39
$ process ->expects ($ this ->once ())->method ('terminate ' )->with ($ this ->equalTo (SIGKILL ));
38
40
@@ -44,9 +46,12 @@ public function testClosingStreamTerminatesRunningProcess()
44
46
public function testClosingStreamOfNonRunningProcessWillNotTerminate ()
45
47
{
46
48
$ process = $ this ->getMockBuilder ('React\ChildProcess\Process ' )->disableOriginalConstructor ()->getMock ();
47
- $ process ->stdout = new ReadableStream ();
49
+ $ process ->stdout = $ this -> getMockBuilder ( ' React\Stream\ReadableStreamInterface ' )-> getMock ();
48
50
$ process ->stdin = $ this ->getMockBuilder ('React\Stream\WritableStreamInterface ' )->getMock ();
49
51
52
+ $ process ->stdout ->expects ($ this ->any ())->method ('isReadable ' )->willReturn (true );
53
+ $ process ->stdin ->expects ($ this ->any ())->method ('isWritable ' )->willReturn (true );
54
+
50
55
$ process ->expects ($ this ->once ())->method ('isRunning ' )->will ($ this ->returnValue (false ));
51
56
$ process ->expects ($ this ->never ())->method ('terminate ' );
52
57
0 commit comments