File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -25,12 +25,15 @@ public function __construct(LoopInterface $loop)
2525 * If the command prints output to STDERR, make sure to redirect it to
2626 * STDOUT by appending " 2>&1".
2727 *
28- * @param string $ command
28+ * @param string|Process $process accepts either a command string to execute or a Process instance
2929 * @return DeferredShell
3030 */
31- public function createDeferredShell ($ command )
31+ public function createDeferredShell ($ process )
3232 {
33- $ process = new Process ($ command );
33+ if (!($ process instanceof Process)) {
34+ $ process = new Process ($ process );
35+ }
36+
3437 $ process ->start ($ this ->loop );
3538
3639 $ 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