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 to mock the same function with defferent arguments in the namespace #6

Merged
merged 3 commits into from
Dec 11, 2020

Conversation

michalbundyra
Copy link
Member

In prophecy we can mock the same class function with different arguments in case it's called multiple times, for example:

$prophecy = $this->prophesize(DateTime::class);
$prophecy->format('Y-m-d')->willReturn('2018-03-19');
$prophecy->format('H:i:s')->willReturn('12:00:00');
$obj = $prophecy->reveal();

$this->assertSame('2018-03-19', $obj->format('Y-m-d'));
$this->assertSame('12:00:00', $obj->format('H:i:s'));

Now, with that library is not possible to mock the same function, because we get error:
phpmock\MockEnabledException: FUNCTION_NAME is already enabled. Call disable() on the existing mock.

This PR resolve that issue.

ping @malkusch

@malkusch
Copy link
Member

Someone else has to do that. See #7

@michalbundyra michalbundyra merged commit 0dfd45c into php-mock:master Dec 11, 2020
@michalbundyra michalbundyra deleted the hotfix/double-mock branch December 11, 2020 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants