Created
July 5, 2011 14:21
-
-
Save giorgiosironi/1064921 to your computer and use it in GitHub Desktop.
Non existent methods cannot be mocked
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class MyMethodOfficiallyDoesNotExist | |
{ | |
public function __call($method, $args) { | |
return true; | |
} | |
} | |
class MockingNotExistingMethodsTest extends PHPUnit_Framework_TestCase | |
{ | |
public function testANonExistentMethod() | |
{ | |
$original = new MyMethodOfficiallyDoesNotExist(); | |
$this->assertTrue($original->doesNotExist()); | |
$mock = $this->getMock('MyMethodOfficiallyDoesNotExist'); | |
$mock->expects($this->any()) | |
->method('doesNotExist') | |
->will($this->returnValue(false)); | |
$this->assertFalse($mock->doesNotExist()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment