Skip to content
Permalink
Browse files

Remove use of TestCase::getMock() from "Console" namepace tests.

  • Loading branch information...
ADmad committed Jun 4, 2016
1 parent d29af6d commit 8dcf70d29d482883e30255314ccd5cc3b4250cc3
@@ -30,13 +30,18 @@ class ConsoleErrorHandlerTest extends TestCase
/**
* setup, create mocks
*
* @return Mock object
* @return void
*/
public function setUp()
{
parent::setUp();
$this->stderr = $this->getMock('Cake\Console\ConsoleOutput', [], [], '', false);
$this->Error = $this->getMock('Cake\Console\ConsoleErrorHandler', ['_stop'], [['stderr' => $this->stderr]]);
$this->stderr = $this->getMockBuilder('Cake\Console\ConsoleOutput')
->disableOriginalConstructor()
->getMock();
$this->Error = $this->getMockBuilder('Cake\Console\ConsoleErrorHandler')
->setMethods(['_stop'])
->setConstructorArgs([['stderr' => $this->stderr]])
->getMock();
Log::drop('stderr');
}
@@ -35,9 +35,15 @@ public function setUp()
parent::setUp();
Configure::write('App.namespace', 'TestApp');
$this->out = $this->getMock('Cake\Console\ConsoleOutput', [], [], '', false);
$this->err = $this->getMock('Cake\Console\ConsoleOutput', [], [], '', false);
$this->in = $this->getMock('Cake\Console\ConsoleInput', [], [], '', false);
$this->out = $this->getMockBuilder('Cake\Console\ConsoleOutput')
->disableOriginalConstructor()
->getMock();
$this->err = $this->getMockBuilder('Cake\Console\ConsoleOutput')
->disableOriginalConstructor()
->getMock();
$this->in = $this->getMockBuilder('Cake\Console\ConsoleInput')
->disableOriginalConstructor()
->getMock();
$this->io = new ConsoleIo($this->out, $this->err, $this->in);
}
@@ -34,7 +34,9 @@ class ConsoleOutputTest extends TestCase
public function setUp()
{
parent::setUp();
$this->output = $this->getMock('Cake\Console\ConsoleOutput', ['_write']);
$this->output = $this->getMockBuilder('Cake\Console\ConsoleOutput')
->setMethods(['_write'])
->getMock();
$this->output->outputAs(ConsoleOutput::COLOR);
}
@@ -34,7 +34,9 @@ public function setUp()
{
parent::setUp();
Configure::write('App.namespace', 'TestApp');
$io = $this->getMock('Cake\Console\ConsoleIo', [], [], '', false);
$io = $this->getMockBuilder('Cake\Console\ConsoleIo')
->disableOriginalConstructor()
->getMock();
$this->helpers = new HelperRegistry();
$this->helpers->setIo($io);
}
@@ -36,7 +36,9 @@ public function setUp()
parent::setUp();
Plugin::load('TestPlugin');
Configure::write('App.namespace', 'TestApp');
$this->dispatcher = $this->getMock('Cake\Console\ShellDispatcher', ['_stop']);
$this->dispatcher = $this->getMockBuilder('Cake\Console\ShellDispatcher')
->setMethods(['_stop'])
->getMock();
}
/**
@@ -155,14 +157,19 @@ public function testFindShellAliasedAppShadow()
public function testDispatchShellWithAbort()
{
$io = $this->getMockBuilder('Cake\Console\ConsoleIo')->getMock();
$shell = $this->getMock('Cake\Console\Shell', ['main'], [$io]);
$shell = $this->getMockBuilder('Cake\Console\Shell')
->setMethods(['main'])
->setConstructorArgs([$io])
->getMock();
$shell->expects($this->once())
->method('main')
->will($this->returnCallback(function () use ($shell) {
$shell->abort('Bad things', 99);
}));
$dispatcher = $this->getMock('Cake\Console\ShellDispatcher', ['findShell']);
$dispatcher = $this->getMockBuilder('Cake\Console\ShellDispatcher')
->setMethods(['findShell'])
->getMock();
$dispatcher->expects($this->any())
->method('findShell')
->with('aborter')
@@ -180,7 +187,9 @@ public function testDispatchShellWithAbort()
*/
public function testDispatchShellWithMain()
{
$dispatcher = $this->getMock('Cake\Console\ShellDispatcher', ['findShell']);
$dispatcher = $this->getMockBuilder('Cake\Console\ShellDispatcher')
->setMethods(['findShell'])
->getMock();
$Shell = $this->getMockBuilder('Cake\Console\Shell')->getMock();
$Shell->expects($this->exactly(2))->method('initialize');
@@ -212,7 +221,9 @@ public function testDispatchShellWithMain()
*/
public function testDispatchShellWithoutMain()
{
$dispatcher = $this->getMock('Cake\Console\ShellDispatcher', ['findShell']);
$dispatcher = $this->getMockBuilder('Cake\Console\ShellDispatcher')
->setMethods(['findShell'])
->getMock();
$Shell = $this->getMockBuilder('Cake\Console\Shell')->getMock();
$Shell->expects($this->once())->method('initialize');
@@ -237,10 +248,9 @@ public function testDispatchShellWithoutMain()
*/
public function testDispatchShortPluginAlias()
{
$dispatcher = $this->getMock(
'Cake\Console\ShellDispatcher',
['_shellExists', '_createShell']
);
$dispatcher = $this->getMockBuilder('Cake\Console\ShellDispatcher')
->setMethods(['_shellExists', '_createShell'])
->getMock();
$Shell = $this->getMockBuilder('Cake\Console\Shell')->getMock();
$dispatcher->expects($this->at(1))
@@ -265,10 +275,9 @@ public function testDispatchShortPluginAlias()
*/
public function testDispatchShortPluginAliasCamelized()
{
$dispatcher = $this->getMock(
'Cake\Console\ShellDispatcher',
['_shellExists', '_createShell']
);
$dispatcher = $this->getMockBuilder('Cake\Console\ShellDispatcher')
->setMethods(['_shellExists', '_createShell'])
->getMock();
$Shell = $this->getMockBuilder('Cake\Console\Shell')->getMock();
$dispatcher->expects($this->at(1))
@@ -293,10 +302,9 @@ public function testDispatchShortPluginAliasCamelized()
*/
public function testDispatchShortPluginAliasConflict()
{
$dispatcher = $this->getMock(
'Cake\Console\ShellDispatcher',
['_shellExists', '_createShell']
);
$dispatcher = $this->getMockBuilder('Cake\Console\ShellDispatcher')
->setMethods(['_shellExists', '_createShell'])
->getMock();
$Shell = $this->getMockBuilder('Cake\Console\Shell')->getMock();
$dispatcher->expects($this->at(1))
@@ -349,11 +357,15 @@ public function testShiftArgs()
*/
public function testHelpOption()
{
$mockShell = $this->getMock('Cake\Shell\CommandListShell', ['main', 'initialize', 'startup']);
$mockShell = $this->getMockBuilder('Cake\Shell\CommandListShell')
->setMethods(['main', 'initialize', 'startup'])
->getMock();
$mockShell->expects($this->once())
->method('main');
$dispatcher = $this->getMock('Cake\Console\ShellDispatcher', ['findShell', '_stop']);
$dispatcher = $this->getMockBuilder('Cake\Console\ShellDispatcher')
->setMethods(['findShell', '_stop'])
->getMock();
$dispatcher->expects($this->once())
->method('findShell')
->with('command_list')
@@ -369,11 +381,15 @@ public function testHelpOption()
*/
public function testVersionOption()
{
$mockShell = $this->getMock('Cake\Shell\CommandListShell', ['main', 'initialize', 'startup']);
$mockShell = $this->getMockBuilder('Cake\Shell\CommandListShell')
->setMethods(['main', 'initialize', 'startup'])
->getMock();
$mockShell->expects($this->once())
->method('main');
$dispatcher = $this->getMock('Cake\Console\ShellDispatcher', ['findShell', '_stop']);
$dispatcher = $this->getMockBuilder('Cake\Console\ShellDispatcher')
->setMethods(['findShell', '_stop'])
->getMock();
$dispatcher->expects($this->once())
->method('findShell')
->with('command_list')
Oops, something went wrong.

0 comments on commit 8dcf70d

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