Created
October 18, 2016 20:24
-
-
Save mente/e2fa40d939a080ff824cc1dd8b18f6b2 to your computer and use it in GitHub Desktop.
Reproduce of phpunit not asserting expectations of prophecy mocks created in data provider
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class RandomClassWithMock | |
{ | |
public function methodToMock() | |
{ | |
return 42; | |
} | |
} | |
class ProphecyNotAssertedReproduce extends PHPUnit_Framework_TestCase | |
{ | |
/** | |
* @dataProvider setProvider | |
*/ | |
public function testProphecyCheckFails($mock) | |
{ | |
$mock->methodToMock()->shouldBeCalled(); | |
} | |
public function setProvider() | |
{ | |
$mock = $this->prophesize(RandomClassWithMock::class); | |
yield 'this mock is not asserted' => [ | |
$mock | |
]; | |
} | |
/** | |
* @dataProvider setProvider | |
*/ | |
public function testProphecyCheckManuallySucceeds($mock) | |
{ | |
$mock->methodToMock()->shouldBeCalled(); | |
$mock->checkProphecyMethodsPredictions(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment