Browse Source

Fixed test that was never supposed to work

Jose Lorenzo Rodriguez 10 years ago
parent
commit
abf063e8f3

+ 9 - 2
tests/TestCase/Console/ShellTest.php

@@ -962,7 +962,11 @@ TEXT;
      */
     public function testRunCommandBaseclassMethod()
     {
-        $shell = $this->getMock('Cake\Console\Shell', ['startup', 'getOptionParser', 'out'], [], '', false);
+        $shell = $this->getMockBuilder('Cake\Console\Shell')
+            ->setMethods(['startup', 'getOptionParser', 'out', 'hr'])
+            ->disableOriginalConstructor()
+            ->getMock();
+
         $shell->io($this->getMock('Cake\Console\ConsoleIo'));
         $parser = $this->getMock('Cake\Console\ConsoleOptionParser', [], [], '', false);
 
@@ -982,7 +986,10 @@ TEXT;
      */
     public function testRunCommandMissingMethod()
     {
-        $shell = $this->getMock('Cake\Console\Shell', ['startup', 'getOptionParser', 'out'], [], '', false);
+        $shell = $this->getMockBuilder('Cake\Console\Shell')
+            ->setMethods(['startup', 'getOptionParser', 'out', 'hr'])
+            ->disableOriginalConstructor()
+            ->getMock();
         $shell->io($this->getMock('Cake\Console\ConsoleIo'));
         $parser = $this->getMock('Cake\Console\ConsoleOptionParser', [], [], '', false);
 

+ 1 - 0
tests/TestCase/Controller/Component/AuthComponentTest.php

@@ -1450,6 +1450,7 @@ class AuthComponentTest extends TestCase
      */
     public function testStatelessFollowedByStatefulAuth()
     {
+        $this->Auth->response = $this->getMock('Cake\Network\Response', ['stop', 'statusCode', 'send']);
         $event = new Event('Controller.startup', $this->Controller);
         $this->Auth->authenticate = ['Basic', 'Form'];
         $this->Controller->request['action'] = 'add';

+ 6 - 18
tests/TestCase/Controller/ControllerTest.php

@@ -522,29 +522,17 @@ class ControllerTest extends TestCase
         $this->assertEquals(302, $response->statusCode());
     }
 
-    /**
-     * test that beforeRedirect callback returning false in controller
-     *
-     * @return void
-     */
-    public function testRedirectBeforeRedirectListenerReturnFalse()
+    public function testRedirectBeforeRedirectListenerReturnResponse()
     {
-        $Response = $this->getMock('Cake\Network\Response', ['stop', 'header']);
+        $Response = $this->getMock('Cake\Network\Response', ['stop', 'header', 'statusCode']);
         $Controller = new Controller(null, $Response);
 
-        $Controller->eventManager()->attach(function ($event, $url, $response) {
-            return false;
-        }, 'Controller.beforeRedirect');
-
-        $Controller->response->expects($this->never())
-            ->method('stop');
-        $Controller->response->expects($this->never())
-            ->method('header');
-        $Controller->response->expects($this->never())
-            ->method('statusCode');
+        $Controller->eventManager()->on('Controller.beforeRedirect', function ($event, $url, $response) {
+            return new Response;
+        });
 
         $result = $Controller->redirect('http://cakephp.org');
-        $this->assertNull($result);
+        $this->assertInstanceOf(Response::class, $result);
     }
 
     /**

+ 1 - 1
tests/TestCase/ORM/Association/BelongsToTest.php

@@ -287,7 +287,7 @@ class BelongsToTest extends TestCase
      */
     public function testSaveAssociatedOnlyEntities()
     {
-        $mock = $this->getMock('Cake\ORM\Table', [], [], '', false);
+        $mock = $this->getMock('Cake\ORM\Table', ['saveAssociated'], [], '', false);
         $config = [
             'sourceTable' => $this->client,
             'targetTable' => $mock,

+ 1 - 1
tests/TestCase/ORM/Association/HasManyTest.php

@@ -485,7 +485,7 @@ class HasManyTest extends TestCase
      */
     public function testSaveAssociatedOnlyEntities()
     {
-        $mock = $this->getMock('Cake\ORM\Table', [], [], '', false);
+        $mock = $this->getMock('Cake\ORM\Table', ['saveAssociated'], [], '', false);
         $config = [
             'sourceTable' => $this->author,
             'targetTable' => $mock,

+ 1 - 1
tests/TestCase/ORM/Association/HasOneTest.php

@@ -221,7 +221,7 @@ class HasOneTest extends TestCase
      */
     public function testSaveAssociatedOnlyEntities()
     {
-        $mock = $this->getMock('Cake\ORM\Table', [], [], '', false);
+        $mock = $this->getMock('Cake\ORM\Table', ['saveAssociated'], [], '', false);
         $config = [
             'sourceTable' => $this->user,
             'targetTable' => $mock,

+ 1 - 1
tests/TestCase/ORM/EntityTest.php

@@ -818,7 +818,7 @@ class EntityTest extends TestCase
     public function testConstructorWithMarkNew()
     {
         $entity = $this->getMockBuilder('\Cake\ORM\Entity')
-            ->setMethods(['isNew'])
+            ->setMethods(['isNew', 'clean'])
             ->disableOriginalConstructor()
             ->getMock();
         $entity->expects($this->never())->method('clean');

+ 1 - 1
tests/TestCase/Routing/Filter/AssetFilterTest.php

@@ -76,7 +76,7 @@ class AssetFilterTest extends TestCase
         $this->assertEquals(200, $response->statusCode());
         $this->assertEquals($time->format('D, j M Y H:i:s') . ' GMT', $response->modified());
 
-        $response = $this->getMock('Cake\Network\Response', ['_sendHeader', 'checkNotModified']);
+        $response = $this->getMock('Cake\Network\Response', ['_sendHeader', 'checkNotModified', 'send']);
         $request = new Request('test_theme/img/cake.power.gif');
 
         $response->expects($this->once())->method('checkNotModified')