Using PHPUnit_Framework_TestCase::prophesize() in conjunction with @backupStaticAttributes enabled fails for repeated tests with a "Cannot redeclare class" error.
class ProphesizeWithBackupStaticAttributesTest extends \PHPUnit_Framework_TestCase
{
/**
* @backupStaticAttributes enabled
* @test
* @dataProvider provideProphesizeShouldWorkRepeatly
*/
public function prophesizeShouldWorkRepeatly()
{
$this->prophesize(\Countable::class);
}
public function provideProphesizeShouldWorkRepeatly()
{
return [
[], [], []
];
}
}
Running this test with PHPUnit-5.1.3 will fail with this message:
..PHP Fatal error: Cannot redeclare class Double\Countable\P2 in … vendor/phpspec/prophecy/src/Prophecy/Doubler/Generator/ClassCreator.php(49) : eval()'d code on line 2
As a hint: This issue seems to be introduced with Prophecy-1.1 and even more strangely it doesn't fail for HHVM: https://travis-ci.org/php-mock/php-mock-prophecy/builds/98688771
phpspec/prophecy@694dc3297976aa6410a236dd770bbc2adaf76e4b looks like the offending commit.
Using
PHPUnit_Framework_TestCase::prophesize()
in conjunction with@backupStaticAttributes enabled
fails for repeated tests with a "Cannot redeclare class" error.Running this test with PHPUnit-5.1.3 will fail with this message:
As a hint: This issue seems to be introduced with Prophecy-1.1 and even more strangely it doesn't fail for HHVM: https://travis-ci.org/php-mock/php-mock-prophecy/builds/98688771 phpspec/prophecy@694dc3297976aa6410a236dd770bbc2adaf76e4b looks like the offending commit.