PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Testing » PHPUnit2 » Bug #6815

Mock generation

Details

Submitted2006-02-17 15:13 UTC
Frommaximilian dot gass at arcor dot de
StatusClosed
PackagePHPUnit2
PHP Version5.1.2
OSGentoo Linux
Roadmaps(Not assigned)

Comments

[2006-02-17 15:13 UTC] maximilian dot gass at arcor dot de

Description:
------------
The mock generation is a bit weird:

-Generating an abstract class doesn't make sense for
mocking because you can't create instances
-Generating interfaces also doesn't make sense. If I mock
an interface I want a MockObject that implements it.
-Abstract methods also remain abstract which is not very
useful.
-Generated destructors don't call the parent destructor
(the constructors do)

[2006-02-17 15:23 UTC] maximilian dot gass at arcor dot de

I've found another one: The generated __clone() method
calls the parent one even if there's none.

[2006-02-17 15:41 UTC] sebastian at php dot net

> Generating an abstract class doesn't make sense
> for mocking because you can't create instances

You can extend the generated mock class, for instance when you need different implementations of the mock.

> Abstract methods also remain abstract which
> is not very useful.

See above.

> If I mock an interface I want a MockObject that
> implements it.

I am thinking of supporting this.

> Generated destructors don't call the parent
> destructor (the constructors do)

I will look into this.

> The generated __clone() method calls the parent
> one even if there's none.

I will look into this, too.

[2006-02-17 15:49 UTC] maximilian dot gass at web dot de

>> Generating an abstract class doesn't make sense
>> for mocking because you can't create instances

> You can extend the generated mock class, for instance
> when you need
> different implementations of the mock.

What about a switch for it?

Another one: In a mock's destructor the verify() method of
the InvocationMocker is not called (commented out). I don't
know if it is called elsewhere but invocation counts were
not verified until I enabled it again.

[2006-02-17 16:04 UTC] sebastian at php dot net

I addressed a couple of the issues you reported with this CVS commit: http://news.php.net/php.pear.cvs/38329.

[2006-03-09 10:01 UTC] sebastian at php dot net

With the exception of mocking interfaces (which I will implement shortly) all issues raised in this report have been addressed.

Please open one report per issue in the future.

Thank you.