Skip to content

Commit

Permalink
Fix issue where missing command would exit as success.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Oct 4, 2011
1 parent aa7448e commit 042e817
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
6 changes: 4 additions & 2 deletions lib/Cake/Console/Shell.php
Expand Up @@ -351,7 +351,8 @@ public function runCommand($command, $argv) {
$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;
Expand All @@ -373,7 +374,8 @@ public function runCommand($command, $argv) {
if ($isMain) {
return $this->main();
}
return $this->out($this->OptionParser->help($command));
$this->out($this->OptionParser->help($command));
return false;
}

/**
Expand Down
11 changes: 8 additions & 3 deletions lib/Cake/Test/Case/Console/Command/ShellTest.php
Expand Up @@ -747,6 +747,7 @@ public function testRunCommandMissingMethod() {


$result = $Mock->runCommand('idontexist', array());
$this->assertFalse($result);
}

/**
Expand Down Expand Up @@ -777,14 +778,18 @@ public function testRunCommandTriggeringHelp() {
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'));
}

/**
Expand Down

0 comments on commit 042e817

Please sign in to comment.