Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Adding some more array_unshift. These fix issues where tasks would re…
…ceive their name in the argv which is not correct.
  • Loading branch information
markstory committed Oct 14, 2010
1 parent 79d1739 commit e700898
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 2 additions & 0 deletions cake/console/libs/shell.php
Expand Up @@ -331,6 +331,7 @@ public function hasMethod($name) {
public function runCommand($command, $argv) {
if (!empty($command) && $this->hasTask($command)) {
$command = Inflector::camelize($command);
array_shift($argv);
return $this->{$command}->runCommand('execute', $argv);
}

Expand All @@ -340,6 +341,7 @@ public function runCommand($command, $argv) {
return $this->out($this->parser->help());
}
if ($this->hasMethod($command)) {
array_shift($argv);
return $this->{$command}();
}
if ($this->hasMethod('main')) {
Expand Down
10 changes: 6 additions & 4 deletions cake/tests/cases/console/libs/shell.test.php
Expand Up @@ -658,11 +658,13 @@ function testRunCommandTriggeringHelp() {
*/
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'));
}
}

0 comments on commit e700898

Please sign in to comment.