padraic/mockery — pull request #194 by searbe (2013-08-02 10:39:57+00:00)
Title: Multiple calls and shouldDeferMissing

A few times I've expected "shouldDeferMissing" to mean "defer *anything* I am not expecting" as opposed to "defer methods I have set *zero* expectations for". So I can write:

$mock->shouldReceive('getValue')->with('name')->andReturn('Craig')->once();
$mock->shouldDeferMissing();

Then I would expect this:

echo $mock->getValue('name');
// "Craig"

But I also expect this:

echo $mock->getValue('something_else');
// Whatever the object would return if it wasn't mocked

The ->once() call would take care of the expectation not being met during ::Close.

It could be done by adding something like this on line ~267:

} elseif ($this->_mockery_shouldDeferMissing) {
return call_user_func_array("parent::$method", $args);
}

I noticed bug report https://github.com/padraic/mockery/issues/115 (hence the similarity in the titles) and figured perhaps this is a similar thing.

What do you think? I am happy to write a test for this and make a pull request but wanted to gather opinion first..