Skip to content

Instantly share code, notes, and snippets.

@mente
Created October 18, 2016 20:24
Show Gist options
  • Save mente/e2fa40d939a080ff824cc1dd8b18f6b2 to your computer and use it in GitHub Desktop.
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
<?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