From 01e1b5ca610cda98453ea1e1c6fbc2ae3f1d49d9 Mon Sep 17 00:00:00 2001 From: ndm2 Date: Sat, 1 Mar 2014 20:24:32 +0100 Subject: [PATCH] Fix failing tests caused by already existing classes --- lib/Cake/Test/Case/Console/ShellDispatcherTest.php | 8 ++++---- .../Case/Controller/Component/AclComponentTest.php | 11 +++++++---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/Cake/Test/Case/Console/ShellDispatcherTest.php b/lib/Cake/Test/Case/Console/ShellDispatcherTest.php index 258e46030..2d3aa5bf5 100644 --- a/lib/Cake/Test/Case/Console/ShellDispatcherTest.php +++ b/lib/Cake/Test/Case/Console/ShellDispatcherTest.php @@ -481,7 +481,7 @@ class ShellDispatcherTest extends CakeTestCase { $Dispatcher = new TestShellDispatcher(); $methods = get_class_methods('Object'); array_push($methods, 'main', 'initdb', 'initialize', 'loadTasks', 'startup', '_secret'); - $Shell = $this->getMock('Object', $methods, array(), 'MockWithMainNotAShell'); + $Shell = $this->getMock('Object', $methods); $Shell->expects($this->never())->method('initialize'); $Shell->expects($this->once())->method('startup'); @@ -493,7 +493,7 @@ class ShellDispatcherTest extends CakeTestCase { $this->assertTrue($result); $this->assertEquals(array(), $Dispatcher->args); - $Shell = $this->getMock('Object', $methods, array(), 'MockWithMainNotAShell'); + $Shell = $this->getMock('Object', $methods); $Shell->expects($this->once())->method('initdb')->will($this->returnValue(true)); $Shell->expects($this->once())->method('startup'); $Dispatcher->TestShell = $Shell; @@ -512,7 +512,7 @@ class ShellDispatcherTest extends CakeTestCase { $Dispatcher = new TestShellDispatcher(); $methods = get_class_methods('Object'); array_push($methods, 'main', 'initdb', 'initialize', 'loadTasks', 'startup', '_secret'); - $Shell = $this->getMock('Object', $methods, array(&$Dispatcher), 'MockWithoutMainNotAShell'); + $Shell = $this->getMock('Object', $methods); $Shell->expects($this->never())->method('initialize'); $Shell->expects($this->once())->method('startup'); @@ -524,7 +524,7 @@ class ShellDispatcherTest extends CakeTestCase { $this->assertTrue($result); $this->assertEquals(array(), $Dispatcher->args); - $Shell = $this->getMock('Object', $methods, array(&$Dispatcher), 'MockWithoutMainNotAShell'); + $Shell = $this->getMock('Object', $methods); $Shell->expects($this->once())->method('initdb')->will($this->returnValue(true)); $Shell->expects($this->once())->method('startup'); $Dispatcher->TestShell = $Shell; diff --git a/lib/Cake/Test/Case/Controller/Component/AclComponentTest.php b/lib/Cake/Test/Case/Controller/Component/AclComponentTest.php index 71b65ba77..375d03067 100644 --- a/lib/Cake/Test/Case/Controller/Component/AclComponentTest.php +++ b/lib/Cake/Test/Case/Controller/Component/AclComponentTest.php @@ -33,7 +33,9 @@ class AclComponentTest extends CakeTestCase { */ public function setUp() { parent::setUp(); - $this->MockAclImplementation = $this->getMock('AclInterface', array(), array(), 'MockAclImplementation'); + if (!class_exists('MockAclImplementation', false)) { + $this->getMock('AclInterface', array(), array(), 'MockAclImplementation'); + } Configure::write('Acl.classname', 'MockAclImplementation'); $Collection = new ComponentCollection(); $this->Acl = new AclComponent($Collection); @@ -68,10 +70,11 @@ class AclComponentTest extends CakeTestCase { * @return void */ public function testAdapter() { - $this->MockAclImplementation->expects($this->once())->method('initialize')->with($this->Acl); - $this->assertNull($this->Acl->adapter($this->MockAclImplementation)); + $Adapter = $this->getMock('AclInterface'); + $Adapter->expects($this->once())->method('initialize')->with($this->Acl); - $this->assertEquals($this->Acl->adapter(), $this->MockAclImplementation, 'Returned object is different %s'); + $this->assertNull($this->Acl->adapter($Adapter)); + $this->assertEquals($this->Acl->adapter(), $Adapter, 'Returned object is different %s'); } /**