File tree 2 files changed +38
-1
lines changed
2 files changed +38
-1
lines changed Original file line number Diff line number Diff line change @@ -27,11 +27,21 @@ public function exec($command)
27
27
$ command = implode (' ' , array_filter ($ command ));
28
28
}
29
29
30
- $ command = $ this ->executable . ' ' . trim ( ltrim ( $ command , $ this ->executable ) );
30
+ $ command = $ this ->executable . ' ' . $ this ->stripExecutableFromCommand ( $ command );
31
31
array_push ($ this ->exec , trim ($ command ));
32
32
return $ this ;
33
33
}
34
34
35
+ protected function stripExecutableFromCommand ($ command )
36
+ {
37
+ $ command = trim ($ command );
38
+ $ executable = $ this ->executable . ' ' ;
39
+ if (strpos ($ command , $ executable ) === 0 ) {
40
+ $ command = substr ($ command , strlen ($ executable ));
41
+ }
42
+ return $ command ;
43
+ }
44
+
35
45
public function run ()
36
46
{
37
47
if (empty ($ this ->exec )) {
Original file line number Diff line number Diff line change
1
+ <?php
2
+ use Codeception \Util \Stub ;
3
+
4
+ class CommandStackTest extends \Codeception \TestCase \Test
5
+ {
6
+ public function testExecStackExecutableIsTrimmedFromCommand ()
7
+ {
8
+ $ commandStack = Stub::make ('Robo\Task\Shared\CommandStack ' , array (
9
+ 'executable ' => 'some-executable '
10
+ ));
11
+ verify ($ commandStack
12
+ ->exec ('some-executable status ' )
13
+ ->getCommand ()
14
+ )->equals ('some-executable status ' );
15
+ }
16
+
17
+ public function testExecStackCommandIsNotTrimmedIfHavingSameCharsAsExecutable ()
18
+ {
19
+ $ commandStack = Stub::make ('Robo\Task\Shared\CommandStack ' , array (
20
+ 'executable ' => 'some-executable '
21
+ ));
22
+ verify ($ commandStack
23
+ ->exec ('status ' )
24
+ ->getCommand ()
25
+ )->equals ('some-executable status ' );
26
+ }
27
+ }
You can’t perform that action at this time.
0 commit comments