Skip to content

Commit 704c648

Browse files
committed
feature #37708 Allow Drupal to wrap the Symfony test listener (alexpott)
This PR was squashed before being merged into the 5.2-dev branch. Discussion ---------- Allow Drupal to wrap the Symfony test listener | Q | A | ------------- | --- | Branch? | 5.1 | Bug fix? | kinda | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tickets | Fix #... <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead --> | License | MIT | Doc PR | symfony/symfony-docs#... <!-- required for new features --> Drupal has a test listener that wraps the Symfony listener as we need to manipulate deprecation testing to skip specific deprecations. We've managed to remove some how custom stuff and reaching into Symfony's privates via reflection recently (and fix a bug or two) but now we're getting output like: ``` 2x: a:4:{s:11:"deprecation";s:191:"Calling Drupal\Tests\WebAssert::responseNotMatches with more than one argument is deprecated in drupal:9.1.0 and will throw an exception in drupal:10.0.0. See https://www.drupal.org/node/TODO";s:5:"class";s:52:"Drupal\Tests\comment\Functional\CommentAnonymousTest";s:6:"method";s:13:"testAnonymous";s:15:"triggering_file";s:74:"/Users/alex/dev/sites/drupal8alt.dev/core/tests/Drupal/Tests/WebAssert.php";} 2x in DrupalListener::endTest from Drupal\Tests\Listeners ``` instead of ``` 2x: Calling Drupal\Tests\WebAssert::responseNotMatches with more than one argument is deprecated in drupal:9.1.0 and will throw an exception in drupal:10.0.0. See https://www.drupal.org/node/TODO 2x in CommentAnonymousTest::testAnonymous from Drupal\Tests\comment\Functional ``` We can fix this by aliasing and copying the \Symfony\Bridge\PhpUnit\DeprecationErrorHandler\Deprecation class but ideally that class could be a bit more liberal in its implementation. Commits ------- 91de46d Allow Drupal to wrap the Symfony test listener
2 parents a435dfe + 91de46d commit 704c648

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Bridge\PhpUnit\DeprecationErrorHandler;
1313

1414
use PHPUnit\Util\Test;
15-
use Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerFor;
1615

1716
/**
1817
* @internal
@@ -61,8 +60,8 @@ public function __construct($message, array $trace, $file)
6160
$line = $trace[$i];
6261
$this->triggeringFile = $file;
6362
if (isset($line['object']) || isset($line['class'])) {
64-
if (isset($line['class']) && 0 === strpos($line['class'], SymfonyTestsListenerFor::class)) {
65-
$parsedMsg = unserialize($this->message);
63+
$parsedMsg = @unserialize($this->message);
64+
if ($parsedMsg && isset($parsedMsg['deprecation'])) {
6665
$this->message = $parsedMsg['deprecation'];
6766
$this->originClass = $parsedMsg['class'];
6867
$this->originMethod = $parsedMsg['method'];

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy