Fix failing tests caused by already existing classes

This commit is contained in:
ndm2 2014-03-01 20:24:32 +01:00
parent 008ad3237c
commit 01e1b5ca61
2 changed files with 11 additions and 8 deletions

View file

@ -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;

View file

@ -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');
}
/**