Skip to content

Commit

Permalink
Remove use of TestCase::getMock() from "Shell" namepace tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Jun 5, 2016
1 parent 893358f commit b4b4d3d
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 64 deletions.
20 changes: 9 additions & 11 deletions tests/TestCase/Shell/CommandListShellTest.php
Expand Up @@ -40,17 +40,15 @@ public function setUp()
$this->out = new ConsoleOutput();
$io = new ConsoleIo($this->out);

$this->Shell = $this->getMock(
'Cake\Shell\CommandListShell',
['in', 'err', '_stop', 'clear'],
[$io]
);

$this->Shell->Command = $this->getMock(
'Cake\Shell\Task\CommandTask',
['in', '_stop', 'err', 'clear'],
[$io]
);
$this->Shell = $this->getMockBuilder('Cake\Shell\CommandListShell')
->setMethods(['in', 'err', '_stop', 'clear'])
->setConstructorArgs([$io])
->getMock();

$this->Shell->Command = $this->getMockBuilder('Cake\Shell\Task\CommandTask')
->setMethods(['in', '_stop', 'err', 'clear'])
->setConstructorArgs([$io])
->getMock();
}

/**
Expand Down
20 changes: 9 additions & 11 deletions tests/TestCase/Shell/CompletionShellTest.php
Expand Up @@ -55,17 +55,15 @@ public function setUp()
$this->out = new TestCompletionStringOutput();
$io = new ConsoleIo($this->out);

$this->Shell = $this->getMock(
'Cake\Shell\CompletionShell',
['in', '_stop', 'clear'],
[$io]
);

$this->Shell->Command = $this->getMock(
'Cake\Shell\Task\CommandTask',
['in', '_stop', 'clear'],
[$io]
);
$this->Shell = $this->getMockBuilder('Cake\Shell\CompletionShell')
->setMethods(['in', '_stop', 'clear'])
->setConstructorArgs([$io])
->getMock();

$this->Shell->Command = $this->getMockBuilder('Cake\Shell\Task\CommandTask')
->setMethods(['in', '_stop', 'clear'])
->setConstructorArgs([$io])
->getMock();
}

/**
Expand Down
8 changes: 6 additions & 2 deletions tests/TestCase/Shell/RoutesShellTest.php
Expand Up @@ -33,8 +33,12 @@ class RoutesShellTest extends TestCase
public function setUp()
{
parent::setUp();
$this->io = $this->getMock('Cake\Console\ConsoleIo', ['helper', 'out', 'err']);
$this->table = $this->getMock('Cake\Shell\Helper\TableHelper', [], [$this->io]);
$this->io = $this->getMockBuilder('Cake\Console\ConsoleIo')
->setMethods(['helper', 'out', 'err'])
->getMock();
$this->table = $this->getMockBuilder('Cake\Shell\Helper\TableHelper')
->setConstructorArgs([$this->io])
->getMock();
$this->io->expects($this->any())
->method('helper')
->with('table')
Expand Down
23 changes: 11 additions & 12 deletions tests/TestCase/Shell/Task/AssetsTaskTest.php
Expand Up @@ -14,7 +14,6 @@
*/
namespace Cake\Test\TestCase\Shell\Task;

use Cake\Core\Configure;
use Cake\Core\Plugin;
use Cake\Filesystem\Folder;
use Cake\TestSuite\TestCase;
Expand All @@ -40,13 +39,14 @@ public function setUp()
'Skip AssetsTask tests on windows to prevent side effects for UrlHelper tests on AppVeyor.'
);

$this->io = $this->getMock('Cake\Console\ConsoleIo', [], [], '', false);
$this->io = $this->getMockBuilder('Cake\Console\ConsoleIo')
->disableOriginalConstructor()
->getMock();

$this->Task = $this->getMock(
'Cake\Shell\Task\AssetsTask',
['in', 'out', 'err', '_stop'],
[$this->io]
);
$this->Task = $this->getMockBuilder('Cake\Shell\Task\AssetsTask')
->setMethods(['in', 'out', 'err', '_stop'])
->setConstructorArgs([$this->io])
->getMock();
}

/**
Expand Down Expand Up @@ -129,11 +129,10 @@ public function testSymlinkWhenTargetAlreadyExits()
{
Plugin::load('TestTheme');

$shell = $this->getMock(
'Cake\Shell\Task\AssetsTask',
['in', 'out', 'err', '_stop', '_createSymlink', '_copyDirectory'],
[$this->io]
);
$shell = $this->getMockBuilder('Cake\Shell\Task\AssetsTask')
->setMethods(['in', 'out', 'err', '_stop', '_createSymlink', '_copyDirectory'])
->setConstructorArgs([$this->io])
->getMock();

$this->assertTrue(is_dir(WWW_ROOT . 'test_theme'));

Expand Down
44 changes: 22 additions & 22 deletions tests/TestCase/Shell/Task/ExtractTaskTest.php
Expand Up @@ -34,16 +34,19 @@ class ExtractTaskTest extends TestCase
public function setUp()
{
parent::setUp();
$this->io = $this->getMock('Cake\Console\ConsoleIo', [], [], '', false);
$progress = $this->getMock('Cake\Shell\Helper\ProgressHelper', [], [$this->io]);
$this->io = $this->getMockBuilder('Cake\Console\ConsoleIo')
->disableOriginalConstructor()
->getMock();
$progress = $this->getMockBuilder('Cake\Shell\Helper\ProgressHelper')
->setConstructorArgs([$this->io])
->getMock();
$this->io->method('helper')
->will($this->returnValue($progress));

$this->Task = $this->getMock(
'Cake\Shell\Task\ExtractTask',
['in', 'out', 'err', '_stop'],
[$this->io]
);
$this->Task = $this->getMockBuilder('Cake\Shell\Task\ExtractTask')
->setMethods(['in', 'out', 'err', '_stop'])
->setConstructorArgs([$this->io])
->getMock();
$this->path = TMP . 'tests/extract_task_test';
new Folder($this->path . DS . 'locale', true);
}
Expand Down Expand Up @@ -242,11 +245,10 @@ public function testExtractMultiplePaths()
public function testExtractExcludePlugins()
{
Configure::write('App.namespace', 'TestApp');
$this->Task = $this->getMock(
'Cake\Shell\Task\ExtractTask',
['_isExtractingApp', 'in', 'out', 'err', 'clear', '_stop'],
[$this->io]
);
$this->Task = $this->getMockBuilder('Cake\Shell\Task\ExtractTask')
->setMethods(['_isExtractingApp', 'in', 'out', 'err', 'clear', '_stop'])
->setConstructorArgs([$this->io])
->getMock();
$this->Task->expects($this->exactly(1))
->method('_isExtractingApp')
->will($this->returnValue(true));
Expand All @@ -269,11 +271,10 @@ public function testExtractPlugin()
{
Configure::write('App.namespace', 'TestApp');

$this->Task = $this->getMock(
'Cake\Shell\Task\ExtractTask',
['_isExtractingApp', 'in', 'out', 'err', 'clear', '_stop'],
[$this->io]
);
$this->Task = $this->getMockBuilder('Cake\Shell\Task\ExtractTask')
->setMethods(['_isExtractingApp', 'in', 'out', 'err', 'clear', '_stop'])
->setConstructorArgs([$this->io])
->getMock();

$this->Task->params['output'] = $this->path . DS;
$this->Task->params['plugin'] = 'TestPlugin';
Expand All @@ -294,11 +295,10 @@ public function testExtractVendoredPlugin()
{
Configure::write('App.namespace', 'TestApp');

$this->Task = $this->getMock(
'Cake\Shell\Task\ExtractTask',
['_isExtractingApp', 'in', 'out', 'err', 'clear', '_stop'],
[$this->io]
);
$this->Task = $this->getMockBuilder('Cake\Shell\Task\ExtractTask')
->setMethods(['_isExtractingApp', 'in', 'out', 'err', 'clear', '_stop'])
->setConstructorArgs([$this->io])
->getMock();

$this->Task->params['output'] = $this->path . DS;
$this->Task->params['plugin'] = 'Company/TestPluginThree';
Expand Down
11 changes: 8 additions & 3 deletions tests/TestCase/Shell/Task/LoadTaskTest.php
Expand Up @@ -33,9 +33,14 @@ public function setUp()
{
parent::setUp();

$this->io = $this->getMock('Cake\Console\ConsoleIo', [], [], '', false);

$this->Task = $this->getMock('Cake\Shell\Task\LoadTask', ['in', 'out', 'err', '_stop'], [$this->io]);
$this->io = $this->getMockBuilder('Cake\Console\ConsoleIo')
->disableOriginalConstructor()
->getMock();

$this->Task = $this->getMockBuilder('Cake\Shell\Task\LoadTask')
->setMethods(['in', 'out', 'err', '_stop'])
->setConstructorArgs([$this->io])
->getMock();

$this->bootstrap = ROOT . DS . 'config' . DS . 'bootstrap.php';

Expand Down
11 changes: 8 additions & 3 deletions tests/TestCase/Shell/Task/UnloadTaskTest.php
Expand Up @@ -33,9 +33,14 @@ public function setUp()
{
parent::setUp();

$this->io = $this->getMock('Cake\Console\ConsoleIo', [], [], '', false);

$this->Task = $this->getMock('Cake\Shell\Task\UnloadTask', ['in', 'out', 'err', '_stop'], [$this->io]);
$this->io = $this->getMockBuilder('Cake\Console\ConsoleIo')
->disableOriginalConstructor()
->getMock();

$this->Task = $this->getMockBuilder('Cake\Shell\Task\UnloadTask')
->setMethods(['in', 'out', 'err', '_stop'])
->setConstructorArgs([$this->io])
->getMock();

$this->bootstrap = ROOT . DS . 'config' . DS . 'bootstrap.php';

Expand Down

0 comments on commit b4b4d3d

Please sign in to comment.