padraic/mockery — pull request #173 by malteriesch (2013-06-06 09:22:20+00:00)
Title: Update allowing mocking of selected non-existent methods with \Mockery::getConfiguration()->allowMockingNonExistentMethods(false)

When testing classes that utilize magic methods such as the Zend Framework 2 Controller classes with their plugins (for example the `Params` plugin is called from within the controller as `$this->params())` it was as far as I could see necessary to turn `allowMockingNonExistentMethods` on to be able to test these methods.

Mocking dependent classes heavily in the the controller classes, I wanted to be able to both allow mocking `params()` but still be protected from dependent classes and their mocks getting out of sync whilst refactoring: I can easily see a scenario where all tests pass but in actual use the controller breaks with an undefined method if method name checking is disabled.

Here is a small patch that introduces a new method on mock objects, `allowMethodToBeMocked`, which allows to specifically add methods to be mocked with method name checking turned on.