| Q | A
| --------------------| ---------------
| PHPUnit version | 9.2.5
| PHP version | PHP 7.4.7 (cli) (built: Jun 11 2020 18:33:07) ( NTS )
| Installation Method | Composer
When passing an Exception
instance via a dataProvider, an Uncaught ReflectionException is thrown:
Fatal error: Uncaught Exception: Serialization of 'ReflectionClass' is not allowed in /var/www/html/vendor/phpunit/phpunit/src/Framework/TestCase.php:723
Stack trace:
#0 /var/www/html/vendor/phpunit/phpunit/src/Framework/TestCase.php(723): serialize(Array)
#1 /var/www/html/vendor/phpunit/phpunit/src/Framework/TestSuite.php(638): PHPUnit\Framework\TestCase->run(Object(PHPUnit\Framework\TestResult))
#2 /var/www/html/vendor/phpunit/phpunit/src/Framework/TestSuite.php(638): PHPUnit\Framework\TestSuite->run(Object(PHPUnit\Framework\TestResult))
#3 /var/www/html/vendor/phpunit/phpunit/src/Framework/TestSuite.php(638): PHPUnit\Framework\TestSuite->run(Object(PHPUnit\Framework\TestResult))
#4 /var/www/html/vendor/phpunit/phpunit/src/Framework/TestSuite.php(638): PHPUnit\Framework\TestSuite->run(Object(PHPUnit\Framework\TestResult))
#5 /var/www/html/vendor/phpunit/phpunit/src/TextUI/TestRunner.php(657): PHPUnit\Framework\TestSuite->run(Object(PHPUnit\Framework\TestResult))
#6 /var/www/html/vendor/phpunit/phpunit/src/TextUI/Command in /var/www/html/vendor/phpunit/phpunit/src/Framework/TestCase.php on line 723
processIsolation="true"
class MyTest extends \PHPUnit\Framework\TestCase
{
/**
* @dataProvider thisMethodDataProvider
*/
public function testThisMethod(\Exception $expectedException): void
{
// ...
}
public function thisMethodDataProvider()
{
return [
[new \Exception()],
];
}
}
@stemis Quick check: you are running the tests in a seperate process, is that correct?
In order to pass the provided data from the orchestrating PHPUnit process to the isolated one it uses [un]serialize($data)
.
@sebastianbergmann Is this a known limitation and expected behaviour?
@stemis Quick check: you are running the tests in a seperate process, is that correct?
In order to pass the provided data from the orchestrating PHPUnit process to the isolated one it uses[un]serialize($data)
.
Yes this only happens with processIsolation
turned on
@stemis Thanks for the additional information. Passing data around using serialization should only be used for external processes including PHPT files. ~With the upcoming @dataProvider
refactoring I'd like to know what's going on here. See what's @sebastianbergmann knows about the intended behaviour.~
Ah! Thanks for the patch notes to your update :)
I would be great if there would be a way to pass _any_ data type between processes. Will discuss this, perhaps I can stick a fork in this mechanism while refactoring the data provider load-run-unload cycle.
Thanks for bringing this to my attention. I will reply here sometime next week when working on #4302 (main loop refactoring) and #3736 (data provider resource management).