diff --git a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php index 6a0d9aec99..43394cea79 100644 --- a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php +++ b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php @@ -262,6 +262,7 @@ class SymfonyTestsListenerTrait if ($this->runsInSeparateProcess) { $deprecations = file_get_contents($this->runsInSeparateProcess); unlink($this->runsInSeparateProcess); + putenv('SYMFONY_DEPRECATIONS_SERIALIZE'); foreach ($deprecations ? unserialize($deprecations) : array() as $deprecation) { if ($deprecation[0]) { trigger_error(serialize(array('deprecation' => $deprecation[1], 'class' => $className, 'method' => $test->getName(false))), E_USER_DEPRECATED); diff --git a/src/Symfony/Bridge/PhpUnit/bootstrap.php b/src/Symfony/Bridge/PhpUnit/bootstrap.php index 2803caf02b..a265a129e6 100644 --- a/src/Symfony/Bridge/PhpUnit/bootstrap.php +++ b/src/Symfony/Bridge/PhpUnit/bootstrap.php @@ -12,12 +12,15 @@ use Doctrine\Common\Annotations\AnnotationRegistry; use Symfony\Bridge\PhpUnit\DeprecationErrorHandler; +// Detect if we need to serialize deprecations to a file. +if ($file = getenv('SYMFONY_DEPRECATIONS_SERIALIZE')) { + DeprecationErrorHandler::collectDeprecations($file); + + return; +} + // Detect if we're loaded by an actual run of phpunit if (!defined('PHPUNIT_COMPOSER_INSTALL') && !class_exists('PHPUnit_TextUI_Command', false) && !class_exists('PHPUnit\TextUI\Command', false)) { - if ($ser = getenv('SYMFONY_DEPRECATIONS_SERIALIZE')) { - DeprecationErrorHandler::collectDeprecations($ser); - } - return; }