|
From: Manuel V. <man...@gm...> - 2009-06-02 13:07:56
|
Hello,
I'd like to test an abstract class (actually one of the non abstracted
method in the class). I need to manipulate a PartialMock of this class
but PHP type checker is not my friend:
- With my very first attempt, I didn't mocked the abstract methods so
I got a fatal error because my partial mock didn't defined the
abstract methods
- So I mocked the abstract methods but now PHP claims that the mocked
abstract methods signature doesn't match the parent's one...
How can I solve that ?
Here is a code sample:
abstract class A {
public function methodToTest() {
$f = $this->getFactory();
....
}
public function getFactory() {
....
}
abstract public function methodToBeRedifined($id);
}
Mock::generateParital('A', 'ATestVersion', array('getFactory',
'methodToBeRedifined');
class AUnitTest extends UnitTestCase {
function testMethodToTest() {
$f = newMockFactory($this);
$a = new ATestVersion($this);
$a->setReturnValue($f);
....
}
}
Best regards,
Manuel
|