diff --git a/cake/console/libs/shell.php b/cake/console/libs/shell.php index 3b9fe1304..0f9b113c3 100644 --- a/cake/console/libs/shell.php +++ b/cake/console/libs/shell.php @@ -331,6 +331,7 @@ class Shell extends Object { public function runCommand($command, $argv) { if (!empty($command) && $this->hasTask($command)) { $command = Inflector::camelize($command); + array_shift($argv); return $this->{$command}->runCommand('execute', $argv); } @@ -340,6 +341,7 @@ class Shell extends Object { return $this->out($this->parser->help()); } if ($this->hasMethod($command)) { + array_shift($argv); return $this->{$command}(); } if ($this->hasMethod('main')) { diff --git a/cake/tests/cases/console/libs/shell.test.php b/cake/tests/cases/console/libs/shell.test.php index f57650d6e..c28b8d8d4 100644 --- a/cake/tests/cases/console/libs/shell.test.php +++ b/cake/tests/cases/console/libs/shell.test.php @@ -658,11 +658,13 @@ class ShellTest extends CakeTestCase { */ function testRunCommandHittingTask() { $Shell = $this->getMock('Shell', array('hasTask'), array(), '', false); - $task = $this->getMock('Shell', array('execute'), array(), '', false); - $Shell->tasks = array('RunCommand'); - $Shell->expects($this->once())->method('hasTask')->will($this->returnValue(true)); + $task = $this->getMock('Shell', array('execute', 'runCommand'), array(), '', false); + $task->expects($this->any())->method('runCommand') + ->with('execute', array('one', 'value')); + + $Shell->expects($this->any())->method('hasTask')->will($this->returnValue(true)); $Shell->RunCommand = $task; - $Shell->runCommand('run_command', array()); + $Shell->runCommand('run_command', array('run_command', 'one', 'value')); } }