Skip to content
Permalink
Browse files

Fix: Avoid displaying help messages in red

See #11179
  • Loading branch information...
rchavik committed Sep 14, 2017
1 parent ccb3ef3 commit fb0a94b41c4fe53bb2a503afaf933d08f5665dfb
Showing with 22 additions and 11 deletions.
  1. +1 −1 src/Console/Shell.php
  2. +21 −10 tests/TestCase/Console/ShellTest.php
@@ -509,7 +509,7 @@ public function runCommand($argv, $autoMethod = false, $extra = [])
}
$this->err('No subcommand provided. Choose one of the available subcommands.', 2);
$this->err($this->OptionParser->help($command));
$this->_io->err($this->OptionParser->help($command));
return false;
}
@@ -1049,11 +1049,14 @@ public function testRunCommandWithMissingMethodInSubcommands()
public function testRunCommandBaseClassMethod()
{
$shell = $this->getMockBuilder('Cake\Console\Shell')
->setMethods(['startup', 'getOptionParser', 'err', 'hr'])
->setMethods(['startup', 'getOptionParser', 'hr'])
->disableOriginalConstructor()
->getMock();
$shell->io($this->getMockBuilder('Cake\Console\ConsoleIo')->getMock());
$shell->io(
$this->getMockBuilder('Cake\Console\ConsoleIo')
->setMethods(['err'])
->getMock()
);
$parser = $this->getMockBuilder('Cake\Console\ConsoleOptionParser')
->disableOriginalConstructor()
->getMock();
@@ -1062,7 +1065,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->_io->expects($this->exactly(2))->method('err');
$shell->runCommand(['hr']);
}
@@ -1075,18 +1078,22 @@ public function testRunCommandBaseClassMethod()
public function testRunCommandMissingMethod()
{
$shell = $this->getMockBuilder('Cake\Console\Shell')
->setMethods(['startup', 'getOptionParser', 'err', 'hr'])
->setMethods(['startup', 'getOptionParser', 'hr'])
->disableOriginalConstructor()
->getMock();
$shell->io($this->getMockBuilder('Cake\Console\ConsoleIo')->getMock());
$shell->io(
$this->getMockBuilder('Cake\Console\ConsoleIo')
->setMethods(['err'])
->getMock()
);
$parser = $this->getMockBuilder('Cake\Console\ConsoleOptionParser')
->disableOriginalConstructor()
->getMock();
$parser->expects($this->once())->method('help');
$shell->expects($this->once())->method('getOptionParser')
->will($this->returnValue($parser));
$shell->expects($this->once())->method('err');
$shell->_io->expects($this->exactly(2))->method('err');
$result = $shell->runCommand(['idontexist']);
$this->assertFalse($result);
@@ -1127,10 +1134,14 @@ public function testRunCommandTriggeringHelp()
public function testRunCommandNotCallUnexposedTask()
{
$shell = $this->getMockBuilder('Cake\Console\Shell')
->setMethods(['startup', 'hasTask', 'err'])
->setMethods(['startup', 'hasTask'])
->disableOriginalConstructor()
->getMock();
$shell->io($this->getMockBuilder('Cake\Console\ConsoleIo')->getMock());
$shell->io(
$this->getMockBuilder('Cake\Console\ConsoleIo')
->setMethods(['err'])
->getMock()
);
$task = $this->getMockBuilder('Cake\Console\Shell')
->setMethods(['runCommand'])
->disableOriginalConstructor()
@@ -1143,7 +1154,7 @@ public function testRunCommandNotCallUnexposedTask()
->method('hasTask')
->will($this->returnValue(true));
$shell->expects($this->never())->method('startup');
$shell->expects($this->once())->method('err');
$shell->_io->expects($this->exactly(2))->method('err');
$shell->RunCommand = $task;
$result = $shell->runCommand(['run_command', 'one']);

0 comments on commit fb0a94b

Please sign in to comment.
You can’t perform that action at this time.