|
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
|
|
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).
|
|
From: Manuel V. <man...@gm...> - 2009-06-02 14:33:05
|
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
>
>
|
|
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
|
|
From: Marcus B. <ma...@wo...> - 2009-06-02 14:21:10
|
Hi... Manuel Vacelet wrote: > How can I solve that ? It should work. You can place a pint in front of mock::generatePartial() I think. At least then we can see the generated code. Can you send me a complete piece of code (failing). i can debug from there. > > Best regards, > Manuel yours, Marcus |
|
From: Manuel V. <man...@gm...> - 2009-07-02 12:04:51
|
On Tue, Jun 2, 2009 at 3:48 PM, Marcus Baker<ma...@wo...> wrote: > Hi... > > Manuel Vacelet wrote: >> How can I solve that ? > > It should work. You can place a pint in front of > mock::generatePartial() I think. At least then we can see the > generated code. > > Can you send me a complete piece of code (failing). i can debug from > there. Too much pint later here is the code (tell me if you need more class decl). Print doesn't generate any code because it fails before returning anything Fatal error: Declaration of LDAP_GroupManagerUmbrella::addUserToGroup() must be compatible with that of LDAP_GroupManager::addUserToGroup() in ../include/simpletest/mock_objects.php(1001) : eval()'d code on line 149 |
|
From: Marcus B. <ma...@wo...> - 2009-06-03 09:00:30
|
Hi...
Marcus Baker wrote:
> Hi...
>
> Manuel Vacelet wrote:
>> How can I solve that ?
>
> It should work. You can place a pint in front of
^^^^ print
> mock::generatePartial() I think. At least then we can see the
> generated code.
Although starting with a pint might be a good idea too :).
yours, Marcus
|
|
From: Jason S. <jsw...@ya...> - 2009-06-04 20:27:57
|
Marcus Baker wrote:
>Although starting with a pint might be a good idea too :).
I'll second that idea :)
Regards,
Jason
|