Skip to content

Commit e700898

Browse files
committed
Adding some more array_unshift. These fix issues where tasks would receive their name in the argv which is not correct.
1 parent 79d1739 commit e700898

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

cake/console/libs/shell.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ public function hasMethod($name) {
331331
public function runCommand($command, $argv) {
332332
if (!empty($command) && $this->hasTask($command)) {
333333
$command = Inflector::camelize($command);
334+
array_shift($argv);
334335
return $this->{$command}->runCommand('execute', $argv);
335336
}
336337

@@ -340,6 +341,7 @@ public function runCommand($command, $argv) {
340341
return $this->out($this->parser->help());
341342
}
342343
if ($this->hasMethod($command)) {
344+
array_shift($argv);
343345
return $this->{$command}();
344346
}
345347
if ($this->hasMethod('main')) {

cake/tests/cases/console/libs/shell.test.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -658,11 +658,13 @@ function testRunCommandTriggeringHelp() {
658658
*/
659659
function testRunCommandHittingTask() {
660660
$Shell = $this->getMock('Shell', array('hasTask'), array(), '', false);
661-
$task = $this->getMock('Shell', array('execute'), array(), '', false);
662-
$Shell->tasks = array('RunCommand');
663-
$Shell->expects($this->once())->method('hasTask')->will($this->returnValue(true));
661+
$task = $this->getMock('Shell', array('execute', 'runCommand'), array(), '', false);
662+
$task->expects($this->any())->method('runCommand')
663+
->with('execute', array('one', 'value'));
664+
665+
$Shell->expects($this->any())->method('hasTask')->will($this->returnValue(true));
664666
$Shell->RunCommand = $task;
665667

666-
$Shell->runCommand('run_command', array());
668+
$Shell->runCommand('run_command', array('run_command', 'one', 'value'));
667669
}
668670
}

0 commit comments

Comments
 (0)