Skip to content
Permalink
Browse files

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 10, 2010
1 parent 79d1739 commit e70089891d77091e6e348294ca8d1768ba2be975
Showing with 8 additions and 4 deletions.
  1. +2 −0 cake/console/libs/shell.php
  2. +6 −4 cake/tests/cases/console/libs/shell.test.php
@@ -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);
}
@@ -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')) {
@@ -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.
You can’t perform that action at this time.