Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Error when mocking abstract class with no abstract methods #22

Merged
1 commit merged into from Oct 24, 2010

Conversation

Projects
None yet
5 participants
Contributor

blt04 commented Sep 24, 2010

When mocking an abstract class with no abstract methods using getMockForAbstractClass() an error occurs:

Argument 2 passed to PHPUnit_Framework_MockObject_Generator::generateMock() must be an
array, null given, called in /usr/share/php/PHPUnit/Framework/MockObject/Generator.php
on line 280 and defined

generateMock() should allow $methods to be null. This indicates no methods should be mocked (see 977).

This pull request fixes this by allowing null while still enforcing type hinting. For more info, see the first paragraph of type hinting.

Contributor

fabpot commented Oct 2, 2010

The Symfony2 test suite fails with PHPUnit 3.5.0 because of that problem.

Could not test abstract controllers classes in Zend Framework using mock of abstract request. Please take a look on pull.

Is it advised not to set default value on parameter when the next parameter has required value?

We have to do it like this here as $methods may be be an array or null. I might remove the typehint to make it more clear.

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment