|
From: T.J.Hunt <T.J...@op...> - 2009-06-02 13:26:24
|
Why do you need mocks? can't you just manually define a test-specific subclass:
class SubclassOfAForTesting extends A {
public function methodToBeRedifined($id) {
}
}
then test the method your are interested on an instance of that?
Tim.
-----Original Message-----
From: Manuel Vacelet [mailto:man...@gm...]
Sent: Tue 6/2/2009 2:07 PM
To: sim...@li...
Subject: [Simpletest-support] SimpleTest PartialMock of abstract classes
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
------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises
looking to deploy the next generation of Solaris that includes the latest
innovations from Sun and the OpenSource community. Download a copy and
enjoy capabilities such as Networking, Storage and Virtualization.
Go to: http://p.sf.net/sfu/opensolaris-get
_______________________________________________
Simpletest-support mailing list
Sim...@li...
https://lists.sourceforge.net/lists/listinfo/simpletest-support
---------------------------------
The Open University is incorporated by Royal Charter (RC 000391), an exempt charity in England & Wales and a charity registered in Scotland (SC 038302).
|