Browse Source

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

ADmad 9 years ago
parent
commit
b4b4d3d20c

+ 9 - 11
tests/TestCase/Shell/CommandListShellTest.php

@@ -40,17 +40,15 @@ class CommandListShellTest extends TestCase
         $this->out = new ConsoleOutput();
         $this->out = new ConsoleOutput();
         $io = new ConsoleIo($this->out);
         $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();
     }
     }
 
 
     /**
     /**

+ 9 - 11
tests/TestCase/Shell/CompletionShellTest.php

@@ -55,17 +55,15 @@ class CompletionShellTest extends TestCase
         $this->out = new TestCompletionStringOutput();
         $this->out = new TestCompletionStringOutput();
         $io = new ConsoleIo($this->out);
         $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();
     }
     }
 
 
     /**
     /**

+ 6 - 2
tests/TestCase/Shell/RoutesShellTest.php

@@ -33,8 +33,12 @@ class RoutesShellTest extends TestCase
     public function setUp()
     public function setUp()
     {
     {
         parent::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())
         $this->io->expects($this->any())
             ->method('helper')
             ->method('helper')
             ->with('table')
             ->with('table')

+ 11 - 12
tests/TestCase/Shell/Task/AssetsTaskTest.php

@@ -14,7 +14,6 @@
  */
  */
 namespace Cake\Test\TestCase\Shell\Task;
 namespace Cake\Test\TestCase\Shell\Task;
 
 
-use Cake\Core\Configure;
 use Cake\Core\Plugin;
 use Cake\Core\Plugin;
 use Cake\Filesystem\Folder;
 use Cake\Filesystem\Folder;
 use Cake\TestSuite\TestCase;
 use Cake\TestSuite\TestCase;
@@ -40,13 +39,14 @@ class AssetsTaskTest extends TestCase
             'Skip AssetsTask tests on windows to prevent side effects for UrlHelper tests on AppVeyor.'
             '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();
     }
     }
 
 
     /**
     /**
@@ -129,11 +129,10 @@ class AssetsTaskTest extends TestCase
     {
     {
         Plugin::load('TestTheme');
         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'));
         $this->assertTrue(is_dir(WWW_ROOT . 'test_theme'));
 
 

+ 22 - 22
tests/TestCase/Shell/Task/ExtractTaskTest.php

@@ -34,16 +34,19 @@ class ExtractTaskTest extends TestCase
     public function setUp()
     public function setUp()
     {
     {
         parent::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')
         $this->io->method('helper')
             ->will($this->returnValue($progress));
             ->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';
         $this->path = TMP . 'tests/extract_task_test';
         new Folder($this->path . DS . 'locale', true);
         new Folder($this->path . DS . 'locale', true);
     }
     }
@@ -242,11 +245,10 @@ class ExtractTaskTest extends TestCase
     public function testExtractExcludePlugins()
     public function testExtractExcludePlugins()
     {
     {
         Configure::write('App.namespace', 'TestApp');
         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))
         $this->Task->expects($this->exactly(1))
             ->method('_isExtractingApp')
             ->method('_isExtractingApp')
             ->will($this->returnValue(true));
             ->will($this->returnValue(true));
@@ -269,11 +271,10 @@ class ExtractTaskTest extends TestCase
     {
     {
         Configure::write('App.namespace', 'TestApp');
         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['output'] = $this->path . DS;
         $this->Task->params['plugin'] = 'TestPlugin';
         $this->Task->params['plugin'] = 'TestPlugin';
@@ -294,11 +295,10 @@ class ExtractTaskTest extends TestCase
     {
     {
         Configure::write('App.namespace', 'TestApp');
         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['output'] = $this->path . DS;
         $this->Task->params['plugin'] = 'Company/TestPluginThree';
         $this->Task->params['plugin'] = 'Company/TestPluginThree';

+ 8 - 3
tests/TestCase/Shell/Task/LoadTaskTest.php

@@ -33,9 +33,14 @@ class LoadTaskTest extends TestCase
     {
     {
         parent::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';
         $this->bootstrap = ROOT . DS . 'config' . DS . 'bootstrap.php';
 
 

+ 8 - 3
tests/TestCase/Shell/Task/UnloadTaskTest.php

@@ -33,9 +33,14 @@ class UnloadTaskTest extends TestCase
     {
     {
         parent::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';
         $this->bootstrap = ROOT . DS . 'config' . DS . 'bootstrap.php';