mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-03-12 20:49:50 +00:00
Fix issue where missing command would exit as success.
This commit is contained in:
parent
aa7448e3ed
commit
042e817e1b
2 changed files with 12 additions and 5 deletions
|
@ -351,7 +351,8 @@ class Shell extends Object {
|
|||
$this->OptionParser = $this->getOptionParser();
|
||||
list($this->params, $this->args) = $this->OptionParser->parse($argv, $command);
|
||||
} catch (ConsoleException $e) {
|
||||
return $this->out($this->OptionParser->help($command));
|
||||
$this->out($this->OptionParser->help($command));
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->command = $command;
|
||||
|
@ -373,7 +374,8 @@ class Shell extends Object {
|
|||
if ($isMain) {
|
||||
return $this->main();
|
||||
}
|
||||
return $this->out($this->OptionParser->help($command));
|
||||
$this->out($this->OptionParser->help($command));
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -747,6 +747,7 @@ class ShellTest extends CakeTestCase {
|
|||
|
||||
|
||||
$result = $Mock->runCommand('idontexist', array());
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -777,14 +778,18 @@ class ShellTest extends CakeTestCase {
|
|||
public function testRunCommandHittingTask() {
|
||||
$Shell = $this->getMock('Shell', array('hasTask', 'startup'), array(), '', false);
|
||||
$task = $this->getMock('Shell', array('execute', 'runCommand'), array(), '', false);
|
||||
$task->expects($this->any())->method('runCommand')
|
||||
$task->expects($this->any())
|
||||
->method('runCommand')
|
||||
->with('execute', array('one', 'value'));
|
||||
|
||||
$Shell->expects($this->once())->method('startup');
|
||||
$Shell->expects($this->any())->method('hasTask')->will($this->returnValue(true));
|
||||
$Shell->expects($this->any())
|
||||
->method('hasTask')
|
||||
->will($this->returnValue(true));
|
||||
|
||||
$Shell->RunCommand = $task;
|
||||
|
||||
$Shell->runCommand('run_command', array('run_command', 'one', 'value'));
|
||||
$result = $Shell->runCommand('run_command', array('run_command', 'one', 'value'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue