|
From: Sebastian S. <ssc...@ch...> - 2009-06-02 16:05:22
|
If I get this one right, I did it the same way.
S.
> -----Ursprüngliche Nachricht-----
> Von: Manuel Vacelet [mailto:man...@gm...]
> Gesendet: Dienstag, 2. Juni 2009 15:30
> An: Help, advice, bugs and workarounds
> Betreff: Re: [Simpletest-support] SimpleTest PartialMock of abstract
> classes
>
> I don't "need" mock, it's just easier to manipulate.
> Thanks for the (quick!) proposal.
>
> Cheers,
> Manuel
>
> On Tue, Jun 2, 2009 at 3:23 PM, T.J.Hunt <T.J...@op...> wrote:
> > 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).
> >
> > ---------------------------------------------------------------------
> ---------
> > 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
> >
> >
>
> -----------------------------------------------------------------------
> -------
> 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
|