Skip to content

Commit 91d2690

Browse files
bug #24696 Ensure DeprecationErrorHandler::collectDeprecations() is triggered (alexpott)
This PR was squashed before being merged into the 3.3 branch (closes #24696). Discussion ---------- Ensure DeprecationErrorHandler::collectDeprecations() is triggered Ensure DeprecationErrorHandler::collectDeprecations() is triggered if SYMFONY_DEPRECATIONS_SERIALIZE is set | Q | A | ------------- | --- | Branch? | 3.3 <!-- see comment below --> | Bug fix? | yes | New feature? | no <!-- don't forget to update src/**/CHANGELOG.md files --> | BC breaks? | no | Deprecations? | no <!-- don't forget to update UPGRADE-*.md files --> | Tests pass? | yes | Fixed tickets | #... <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | symfony/symfony-docs#... <!--highly recommended for new features--> <!-- - Bug fixes must be submitted against the lowest branch where they apply (lowest branches are regularly merged to upper ones so they get the fixes too). - Features and deprecations must be submitted against the 3.4, legacy code removals go to the master branch. - Please fill in this template according to the PR you're about to submit. - Replace this comment by a description of what your PR is solving. --> Drupal doesn't use src/Symfony/Bridge/PhpUnit/bin/simple-phpunit but would like to use the deprecation collection features of src/Symfony/Bridge/PhpUnit. The checks in src/Symfony/Bridge/PhpUnit/bootstrap.php mean that this is difficult because they rely on simple-phpunit - but I'm not sure that that is necessary. The problem is even in isolated tests we have PHPUNIT_COMPOSER_INSTALL set because we use a custom phpunit config file. Commits ------- e7da160 Ensure DeprecationErrorHandler::collectDeprecations() is triggered
2 parents 4910ac6 + e7da160 commit 91d2690

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php

+1
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ public function endTest($test, $time)
262262
if ($this->runsInSeparateProcess) {
263263
$deprecations = file_get_contents($this->runsInSeparateProcess);
264264
unlink($this->runsInSeparateProcess);
265+
putenv('SYMFONY_DEPRECATIONS_SERIALIZE');
265266
foreach ($deprecations ? unserialize($deprecations) : array() as $deprecation) {
266267
if ($deprecation[0]) {
267268
trigger_error(serialize(array('deprecation' => $deprecation[1], 'class' => $className, 'method' => $test->getName(false))), E_USER_DEPRECATED);

src/Symfony/Bridge/PhpUnit/bootstrap.php

+7-4
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,15 @@
1212
use Doctrine\Common\Annotations\AnnotationRegistry;
1313
use Symfony\Bridge\PhpUnit\DeprecationErrorHandler;
1414

15+
// Detect if we need to serialize deprecations to a file.
16+
if ($file = getenv('SYMFONY_DEPRECATIONS_SERIALIZE')) {
17+
DeprecationErrorHandler::collectDeprecations($file);
18+
19+
return;
20+
}
21+
1522
// Detect if we're loaded by an actual run of phpunit
1623
if (!defined('PHPUNIT_COMPOSER_INSTALL') && !class_exists('PHPUnit_TextUI_Command', false) && !class_exists('PHPUnit\TextUI\Command', false)) {
17-
if ($ser = getenv('SYMFONY_DEPRECATIONS_SERIALIZE')) {
18-
DeprecationErrorHandler::collectDeprecations($ser);
19-
}
20-
2124
return;
2225
}
2326

0 commit comments

Comments
 (0)