Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow shouldIgnoreMissing() to behave in a recursive fashion #1097

merged 2 commits into from Jan 26, 2021


Copy link

@AJenbo AJenbo commented Oct 17, 2020

When setting up lazy mocks I often run into issues where the test just breaks at the second link and I end up having to explicitly set expectations for the functions anyway, which requires knowledge about implementation details of things that are not relevant for the given test. This PR aims to solve that by allowing for shouldIgnoreMissing() to behave in a recursive fashion.


class A {
    function now(): DateTime {
        return new DateTime();
class Factory {
    function makeA(): A {
        return new A();
class Subject {
    function __construct($factory) {
        $this->factory = $factory;
    function testMe() {
        return $this->factory->makeA()->now()->format('c');


$mockedFactory = Mockery::spy(Factory::class):

$subject = new Subject($mockedFactory);


$mockedFactory = Mockery::mock(Factory::class)->shouldIgnoreMissing(null, true):

$subject = new Subject($mockedFactory);

library/Mockery/Mock.php Outdated Show resolved Hide resolved
@davedevelopment davedevelopment merged commit 59a0cd9 into mockery:master Jan 26, 2021
Copy link

Thank you

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

Successfully merging this pull request may close these issues.

None yet

3 participants