Closed
Description
Symfony version(s) affected: 3.4.13, 4.1.3
Description
There seems to be a bug in when functional testing an action under the following conditions:
- the tested controller redirects to another action
- browser client runs in insulated mode
- data collector is enabled
When running the test, the following error is reported:
RuntimeException : OUTPUT: ERROR OUTPUT: PHP Fatal error: Uncaught unserialize(): Error at offset 1569 of 2589 bytes
/media/perso/my_project2/vendor/symfony/phpunit-bridge/DeprecationErrorHandler.php:290
thrown in Standard input code on line 14
/media/perso/my_project2/vendor/symfony/browser-kit/Client.php:405
/media/perso/my_project2/vendor/symfony/framework-bundle/Client.php:143
/media/perso/my_project2/vendor/symfony/browser-kit/Client.php:349
/media/perso/my_project2/vendor/symfony/browser-kit/Client.php:561
/media/perso/my_project2/vendor/symfony/browser-kit/Client.php:369
/media/perso/my_project2/tests/Controller/RedirectControllerTest.php:15
How to reproduce
A minimal project exposing the issue can be found at https://github.com/jean-gui/redirect-collector. Interesting files are:
- https://github.com/jean-gui/redirect-collector/blob/master/src/Controller/TestController.php
- https://github.com/jean-gui/redirect-collector/blob/master/tests/Controller/RedirectControllerTest.php
- https://github.com/jean-gui/redirect-collector/blob/master/config/packages/test/framework.yaml
Running PHPUnit will lead to the error mentioned above.
Possible Solution
In Symfony\Bundle\FrameworkBundle\Client, changing getScript() as shown below seems to fix the issue. I don't know if that has any negative side-effects.
protected function getScript($request)
{
$kernel = str_replace("'", "\\'", serialize($this->kernel));
$request = str_replace("'", "\\'", serialize($request));
$request = str_replace('\\\\', '\\\\\\', $request);
...
Thanks!
Metadata
Metadata
Assignees
Labels
No labels