Adding some more array_unshift. These fix issues where tasks would receive their name in the argv which is not correct.

This commit is contained in:
mark_story 2010-10-09 23:42:38 -04:00
parent 79d1739778
commit e70089891d
2 changed files with 8 additions and 4 deletions

View file

@ -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')) {

View file

@ -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'));
}
}