Skip to content

Commit

Permalink
Fix failing tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Sep 24, 2015
1 parent e4e2087 commit d731741
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions tests/TestCase/Console/ShellTest.php
Expand Up @@ -14,6 +14,7 @@
*/ */
namespace Cake\Test\TestCase\Console; namespace Cake\Test\TestCase\Console;


use Cake\Console\ConsoleIo;
use Cake\Console\ConsoleOptionParser; use Cake\Console\ConsoleOptionParser;
use Cake\Console\Shell; use Cake\Console\Shell;
use Cake\Core\App; use Cake\Core\App;
Expand Down Expand Up @@ -93,11 +94,6 @@ public function logSomething()
$this->log($this->testMessage); $this->log($this->testMessage);
} }
//@codingStandardsIgnoreEnd //@codingStandardsIgnoreEnd

public function useLogger($enable = true)
{
$this->_useLogger($enable);
}
} }


/** /**
Expand Down Expand Up @@ -926,6 +922,7 @@ public function testRunCommandWithMissingMethodInSubcommands()
public function testRunCommandBaseclassMethod() public function testRunCommandBaseclassMethod()
{ {
$shell = $this->getMock('Cake\Console\Shell', ['startup', 'getOptionParser', 'out'], [], '', false); $shell = $this->getMock('Cake\Console\Shell', ['startup', 'getOptionParser', 'out'], [], '', false);
$shell->io($this->getMock('Cake\Console\ConsoleIo'));
$parser = $this->getMock('Cake\Console\ConsoleOptionParser', [], [], '', false); $parser = $this->getMock('Cake\Console\ConsoleOptionParser', [], [], '', false);


$parser->expects($this->once())->method('help'); $parser->expects($this->once())->method('help');
Expand All @@ -945,6 +942,7 @@ public function testRunCommandBaseclassMethod()
public function testRunCommandMissingMethod() public function testRunCommandMissingMethod()
{ {
$shell = $this->getMock('Cake\Console\Shell', ['startup', 'getOptionParser', 'out'], [], '', false); $shell = $this->getMock('Cake\Console\Shell', ['startup', 'getOptionParser', 'out'], [], '', false);
$shell->io($this->getMock('Cake\Console\ConsoleIo'));
$parser = $this->getMock('Cake\Console\ConsoleOptionParser', [], [], '', false); $parser = $this->getMock('Cake\Console\ConsoleOptionParser', [], [], '', false);


$parser->expects($this->once())->method('help'); $parser->expects($this->once())->method('help');
Expand All @@ -963,18 +961,19 @@ public function testRunCommandMissingMethod()
*/ */
public function testRunCommandTriggeringHelp() public function testRunCommandTriggeringHelp()
{ {
$Parser = $this->getMock('Cake\Console\ConsoleOptionParser', [], [], '', false); $parser = $this->getMock('Cake\Console\ConsoleOptionParser', [], [], '', false);
$Parser->expects($this->once())->method('parse') $parser->expects($this->once())->method('parse')
->with(['--help']) ->with(['--help'])
->will($this->returnValue([['help' => true], []])); ->will($this->returnValue([['help' => true], []]));
$Parser->expects($this->once())->method('help'); $parser->expects($this->once())->method('help');


$Shell = $this->getMock('Cake\Console\Shell', ['getOptionParser', 'out', 'startup', '_welcome'], [], '', false); $shell = $this->getMock('Cake\Console\Shell', ['getOptionParser', 'out', 'startup', '_welcome'], [], '', false);
$Shell->expects($this->once())->method('getOptionParser') $shell->io($this->getMock('Cake\Console\ConsoleIo'));
->will($this->returnValue($Parser)); $shell->expects($this->once())->method('getOptionParser')
$Shell->expects($this->once())->method('out'); ->will($this->returnValue($parser));
$shell->expects($this->once())->method('out');


$Shell->runCommand(['--help']); $shell->runCommand(['--help']);
} }


/** /**
Expand All @@ -985,6 +984,7 @@ public function testRunCommandTriggeringHelp()
public function testRunCommandNotCallUnexposedTask() public function testRunCommandNotCallUnexposedTask()
{ {
$shell = $this->getMock('Cake\Console\Shell', ['startup', 'hasTask', 'out'], [], '', false); $shell = $this->getMock('Cake\Console\Shell', ['startup', 'hasTask', 'out'], [], '', false);
$shell->io($this->getMock('Cake\Console\ConsoleIo'));
$task = $this->getMock('Cake\Console\Shell', ['runCommand'], [], '', false); $task = $this->getMock('Cake\Console\Shell', ['runCommand'], [], '', false);


$task->expects($this->never()) $task->expects($this->never())
Expand All @@ -1010,9 +1010,12 @@ public function testRunCommandHittingTaskInSubcommand()
{ {
$parser = new ConsoleOptionParser('knife'); $parser = new ConsoleOptionParser('knife');
$parser->addSubcommand('slice'); $parser->addSubcommand('slice');
$io = $this->getMock('Cake\Console\ConsoleIo');


$shell = $this->getMock('Cake\Console\Shell', ['hasTask', 'startup', 'getOptionParser'], [], '', false); $shell = $this->getMock('Cake\Console\Shell', ['hasTask', 'startup', 'getOptionParser'], [], '', false);
$shell->io($io);
$task = $this->getMock('Cake\Console\Shell', ['main', 'runCommand'], [], '', false); $task = $this->getMock('Cake\Console\Shell', ['main', 'runCommand'], [], '', false);
$task->io($io);
$task->expects($this->once()) $task->expects($this->once())
->method('runCommand') ->method('runCommand')
->with(['one'], false); ->with(['one'], false);
Expand Down Expand Up @@ -1142,11 +1145,11 @@ public function testQuietLog()
$io->expects($this->at(0)) $io->expects($this->at(0))
->method('setLoggers') ->method('setLoggers')
->with(true); ->with(true);
$io->expects($this->at(2)) $io->expects($this->at(3))
->method('setLoggers') ->method('setLoggers')
->with(false); ->with(ConsoleIo::QUIET);


$this->Shell = $this->getMock(__NAMESPACE__ . '\ShellTestShell', ['_useLogger'], [$io]); $this->Shell = $this->getMock(__NAMESPACE__ . '\ShellTestShell', ['welcome'], [$io]);
$this->Shell->runCommand(['foo', '--quiet']); $this->Shell->runCommand(['foo', '--quiet']);
} }


Expand Down

0 comments on commit d731741

Please sign in to comment.