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

Fix chained demeter calls with type hint #956

Merged
merged 1 commit into from Mar 8, 2019

Conversation

thiagorb
Copy link
Contributor

@thiagorb thiagorb commented Mar 7, 2019

The current implementation fails in the following situation:

$mock = \Mockery::mock(Order::class);
$mock->shouldReceive('getCustomer->getFirstName')->andReturn('John');
$mock->shouldReceive('getCustomer->getLastName')->andReturn('Doe');

In this case, if getCustomer has a type hint for return type, the mock for getLastName will not work. This happens because the named mock doesn't have the prefix Mockery_<count>__, so instead of Mockery_1__demeter_02db565163e0992acfde42edfd58d833_getCustomer, it will be named only demeter_02db565163e0992acfde42edfd58d833_getCustomer.

Because of that, the method Container::getKeyOfDemeterMockFor will not be able to find the mock.

Some users complained about this problem in some already closed issues:

@davedevelopment davedevelopment merged commit 74cdce5 into mockery:master Mar 8, 2019
@davedevelopment
Copy link
Collaborator

Thank you 👍

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

Successfully merging this pull request may close these issues.

None yet

2 participants