I am in the process of testing an abstract class that has a method called Method.
Here is my abstract class (abridged):
abstract class ClassToTest {
function Method($_value = NULL) {
// based on the value passed in a different value is returned.
}
}
Here is my PHPUnit class:
class ClassToTestTest extends PHPUnit_Framework_TestCase {
public $object = NULL;
public function setUp() {
$this->object = $this->getMockForAbstractClass('ClassToTest');
}
public function testMethod() {
// passing no value should return NULL
$this->assertNull($this->object->Method());
// passing a value should return a value
$this->assertEquals($this->object->Method($method), 'return_value');
}
}
Based on PHPUnit Documentation I should be able to use
$stub->expects($this->any())->method('Method')->willReturn('foo');
somehow, but I cannot figure out how to make this work.
How can I use PHPUnit to test a method called Method?
Also, I don't have the option to rename the method to something else.