mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
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:
parent
79d1739778
commit
e70089891d
2 changed files with 8 additions and 4 deletions
|
@ -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')) {
|
||||
|
|
|
@ -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'));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue