1717
1818class DummyExecute extends Execute
1919{
20+ private function getMockProcess ($ cmd )
21+ {
22+ $ process = \Mockery::mock ('Symfony\Component\Process\Process ' );
23+ $ process ->shouldReceive (
24+ 'setTimeout ' ,
25+ 'run ' ,
26+ 'wait ' ,
27+ 'stop ' ,
28+ 'getExitCode ' ,
29+ 'getExitCodeText ' ,
30+ 'getWorkingDirectory ' ,
31+ 'isOutputDisabled ' ,
32+ 'getErrorOutput '
33+ );
34+
35+ $ process ->shouldReceive ('isSuccessful ' )->andReturn (true );
36+ $ process ->shouldReceive ('getOutput ' )->andReturn ('' );
37+ $ process ->shouldReceive ('getCommandLine ' )->andReturn ($ cmd );
38+
39+ return $ process ;
40+ }
41+
2042 public function run ($ cmd , $ error = null )
2143 {
2244 if ($ cmd instanceof Process) {
2345 // Get the command line from process.
2446 $ cmd = $ cmd ->getCommandLine ();
2547 }
26- $ cmd = new DummyProcess ($ cmd );
2748
28- return $ this ->helper ->run ($ this ->output , $ cmd , $ error );
49+ return $ this ->helper ->run ($ this ->output , $ this -> getMockProcess ( $ cmd) , $ error );
2950 }
3051
3152 public function mustRun ($ cmd , $ error = null )
@@ -34,9 +55,8 @@ public function mustRun($cmd, $error = null)
3455 // Get the command line from process.
3556 $ cmd = $ cmd ->getCommandLine ();
3657 }
37- $ cmd = new DummyProcess ($ cmd );
3858
39- return $ this ->helper ->mustRun ($ this ->output , $ cmd , $ error );
59+ return $ this ->helper ->mustRun ($ this ->output , $ this -> getMockProcess ( $ cmd) , $ error );
4060 }
4161
4262 public function runAll ($ processes )
@@ -51,15 +71,15 @@ public function mustRunAll($processes)
5171
5272 public function passThrough ($ commandline , $ cwd = null , $ timeout = null )
5373 {
54- return $ this ->passThroughProcess (new DummyProcess ($ commandline, $ cwd , null , null , $ timeout ));
74+ return $ this ->passThroughProcess ($ this -> getMockProcess ($ commandline ));
5575 }
5676
5777 public function passThroughProcess (Process $ process )
5878 {
59- if ($ process instanceof DummyProcess ) {
79+ if ($ process instanceof \ Mockery \MockInterface ) {
6080 return $ process ;
6181 }
6282
63- return new DummyProcess ( $ process -> getCommandLine (), $ process ->getWorkingDirectory (), null , null , $ process -> getTimeout ());
83+ return $ this -> getMockProcess ( $ process ->getCommandLine ());
6484 }
6585}
0 commit comments