File tree Expand file tree Collapse file tree 2 files changed +34
-3
lines changed Expand file tree Collapse file tree 2 files changed +34
-3
lines changed Original file line number Diff line number Diff line change @@ -25,12 +25,15 @@ public function __construct(LoopInterface $loop)
25
25
* If the command prints output to STDERR, make sure to redirect it to
26
26
* STDOUT by appending " 2>&1".
27
27
*
28
- * @param string $ command
28
+ * @param string|Process $process accepts either a command string to execute or a Process instance
29
29
* @return DeferredShell
30
30
*/
31
- public function createDeferredShell ($ command )
31
+ public function createDeferredShell ($ process )
32
32
{
33
- $ process = new Process ($ command );
33
+ if (!($ process instanceof Process)) {
34
+ $ process = new Process ($ process );
35
+ }
36
+
34
37
$ process ->start ($ this ->loop );
35
38
36
39
$ stream = new CompositeStream ($ process ->stdout , $ process ->stdin );
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ use Clue \React \Shell \ProcessLauncher ;
4
+
5
+ class ProcessLauncherTest extends TestCase
6
+ {
7
+ private $ loop ;
8
+ private $ processLauncher ;
9
+
10
+ public function setUp ()
11
+ {
12
+ $ this ->loop = $ this ->getMock ('React\EventLoop\LoopInterface ' );
13
+ $ this ->processLauncher = new ProcessLauncher ($ this ->loop );
14
+ }
15
+
16
+ public function testProcessWillBeStarted ()
17
+ {
18
+ $ process = $ this ->getMockBuilder ('React\ChildProcess\Process ' )->disableOriginalConstructor ()->getMock ();
19
+ $ process ->stdout = $ this ->getMock ('React\Stream\ReadableStreamInterface ' );
20
+ $ process ->stdin = $ this ->getMock ('React\Stream\WritableStreamInterface ' );
21
+
22
+ $ process ->expects ($ this ->once ())->method ('start ' );
23
+
24
+ $ shell = $ this ->processLauncher ->createDeferredShell ($ process );
25
+
26
+ $ this ->assertInstanceOf ('Clue\React\Shell\DeferredShell ' , $ shell );
27
+ }
28
+ }
You can’t perform that action at this time.
0 commit comments