Skip to content

Commit

Permalink
Display help message with out instead of err when missing method
Browse files Browse the repository at this point in the history
  • Loading branch information
littleylv committed Sep 13, 2017
1 parent 6829ddd commit d8a4ff8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Console/Shell.php
Expand Up @@ -508,7 +508,7 @@ public function runCommand($argv, $autoMethod = false, $extra = [])
return $this->main(...$this->args);
}

$this->err($this->OptionParser->help($command));
$this->out($this->OptionParser->help($command));

return false;
}
Expand Down
12 changes: 6 additions & 6 deletions tests/TestCase/Console/ShellTest.php
Expand Up @@ -1049,7 +1049,7 @@ public function testRunCommandWithMissingMethodInSubcommands()
public function testRunCommandBaseClassMethod()
{
$shell = $this->getMockBuilder('Cake\Console\Shell')
->setMethods(['startup', 'getOptionParser', 'err', 'hr'])
->setMethods(['startup', 'getOptionParser', 'out', 'hr'])
->disableOriginalConstructor()
->getMock();

Expand All @@ -1062,7 +1062,7 @@ public function testRunCommandBaseClassMethod()
$shell->expects($this->once())->method('getOptionParser')
->will($this->returnValue($parser));
$shell->expects($this->never())->method('hr');
$shell->expects($this->once())->method('err');
$shell->expects($this->once())->method('out');

$shell->runCommand(['hr']);
}
Expand All @@ -1075,7 +1075,7 @@ public function testRunCommandBaseClassMethod()
public function testRunCommandMissingMethod()
{
$shell = $this->getMockBuilder('Cake\Console\Shell')
->setMethods(['startup', 'getOptionParser', 'err', 'hr'])
->setMethods(['startup', 'getOptionParser', 'out', 'hr'])
->disableOriginalConstructor()
->getMock();
$shell->io($this->getMockBuilder('Cake\Console\ConsoleIo')->getMock());
Expand All @@ -1086,7 +1086,7 @@ public function testRunCommandMissingMethod()
$parser->expects($this->once())->method('help');
$shell->expects($this->once())->method('getOptionParser')
->will($this->returnValue($parser));
$shell->expects($this->once())->method('err');
$shell->expects($this->once())->method('out');

$result = $shell->runCommand(['idontexist']);
$this->assertFalse($result);
Expand Down Expand Up @@ -1127,7 +1127,7 @@ public function testRunCommandTriggeringHelp()
public function testRunCommandNotCallUnexposedTask()
{
$shell = $this->getMockBuilder('Cake\Console\Shell')
->setMethods(['startup', 'hasTask', 'err'])
->setMethods(['startup', 'hasTask', 'out'])
->disableOriginalConstructor()
->getMock();
$shell->io($this->getMockBuilder('Cake\Console\ConsoleIo')->getMock());
Expand All @@ -1143,7 +1143,7 @@ public function testRunCommandNotCallUnexposedTask()
->method('hasTask')
->will($this->returnValue(true));
$shell->expects($this->never())->method('startup');
$shell->expects($this->once())->method('err');
$shell->expects($this->once())->method('out');
$shell->RunCommand = $task;

$result = $shell->runCommand(['run_command', 'one']);
Expand Down

0 comments on commit d8a4ff8

Please sign in to comment.