Skip to content

Commit 9709500

Browse files
bug #37418 [PhpUnitBridge] Fix compatibility with phpunit 9.3 (Gennadi Janzen)
This PR was merged into the 4.4 branch. Discussion ---------- [PhpUnitBridge] Fix compatibility with phpunit 9.3 | Q | A | ------------- | --- | Branch? | master for features / 4.4 <!-- see below --> | Bug fix? | yes | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tickets | - <!-- prefix each issue number with "Fix #", if any --> | License | MIT | Doc PR | -<!-- required for new features --> In PHPUnit 9.3 some Classes were moved or renamed, to make the PhpunitBridge compatible with PhpUnit 9.3 it necessary to call the new Loader instead of the Registry. <!-- Replace this notice by a short README for your feature/bugfix. This will help people understand your PR and can be used as a start for the documentation. Additionally (see https://symfony.com/releases): - Always add tests and ensure they pass. - Never break backward compatibility (see https://symfony.com/bc). - Bug fixes must be submitted against the lowest maintained 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 branch master. --> Commits ------- de71a12 Fix: compatibility with phpunit 9.3
2 parents 9c6d53a + de71a12 commit 9709500

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

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

+8-2
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@
1212
namespace Symfony\Bridge\PhpUnit\Legacy;
1313

1414
use PHPUnit\TextUI\Command as BaseCommand;
15-
use PHPUnit\TextUI\Configuration\Configuration;
15+
use PHPUnit\TextUI\Configuration\Configuration as LegacyConfiguration;
1616
use PHPUnit\TextUI\Configuration\Registry;
1717
use PHPUnit\TextUI\TestRunner as BaseRunner;
18+
use PHPUnit\TextUI\XmlConfiguration\Configuration;
19+
use PHPUnit\TextUI\XmlConfiguration\Loader;
1820
use Symfony\Bridge\PhpUnit\SymfonyTestsListener;
1921

2022
/**
@@ -43,9 +45,13 @@ protected function createRunner(): BaseRunner
4345

4446
if (isset($this->arguments['configuration'])) {
4547
$configuration = $this->arguments['configuration'];
46-
if (!$configuration instanceof Configuration) {
48+
49+
if (!class_exists(Configuration::class) && !$configuration instanceof LegacyConfiguration) {
4750
$configuration = Registry::getInstance()->get($this->arguments['configuration']);
51+
} elseif (class_exists(Configuration::class) && !$configuration instanceof Configuration) {
52+
$configuration = (new Loader())->load($this->arguments['configuration']);
4853
}
54+
4955
foreach ($configuration->listeners() as $registeredListener) {
5056
if ('Symfony\Bridge\PhpUnit\SymfonyTestsListener' === ltrim($registeredListener->className(), '\\')) {
5157
$registeredLocally = true;

0 commit comments

Comments
 (0)