Skip to content

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.

2 participants