Skip to content

Commit

Permalink
Fix failing tests caused by already existing classes
Browse files Browse the repository at this point in the history
  • Loading branch information
ndm2 committed Mar 1, 2014
1 parent 008ad32 commit 01e1b5c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
8 changes: 4 additions & 4 deletions lib/Cake/Test/Case/Console/ShellDispatcherTest.php
Expand Up @@ -481,7 +481,7 @@ public function testDispatchNotAShellWithMain() {
$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');
Expand All @@ -493,7 +493,7 @@ public function testDispatchNotAShellWithMain() {
$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;
Expand All @@ -512,7 +512,7 @@ public function testDispatchNotAShellWithoutMain() {
$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');
Expand All @@ -524,7 +524,7 @@ public function testDispatchNotAShellWithoutMain() {
$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;
Expand Down
11 changes: 7 additions & 4 deletions lib/Cake/Test/Case/Controller/Component/AclComponentTest.php
Expand Up @@ -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);
Expand Down Expand Up @@ -68,10 +70,11 @@ public function testConstrutorException() {
* @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');
}

/**
Expand Down

0 comments on commit 01e1b5c

Please sign in to comment.