8000 bug #30085 Fix TestRunner compatibility to PhpUnit 8 (alexander-schranz) · symfony/symfony@d7a8b3d · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit d7a8b3d

Browse files
bug #30085 Fix TestRunner compatibility to PhpUnit 8 (alexander-schranz)
This PR was squashed before being merged into the 3.4 branch (closes #30085). Discussion ---------- Fix TestRunner compatibility to PhpUnit 8 | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | related to: #30055 | License | MIT | Doc PR | - Modify the installed phpunit version to be compatibility with the symfony custom TestRunner. This is sure not the best way but maybe currently the fastest way to support PhpUnit 8. The hack should be removed as soon as there is another way to implement a custom Runner. Commits ------- a0c66a3 Fix TestRunner compatibility to PhpUnit 8
2 parents b30f57e + a0c66a3 commit d7a8b3d

File tree

6 files changed

+39
-175
lines changed

6 files changed

+39
-175
lines changed

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

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,24 @@ class CommandForV5 extends \PHPUnit_TextUI_Command
2323
*/
2424
protected function createRunner()
2525
{
26-
return new TestRunnerForV5($this->arguments['loader']);
26+
$listener = new SymfonyTestsListenerForV5();
27+
28+
$this->arguments['listeners'] = isset($this->arguments['listeners']) ? $this->arguments['listeners'] : array();
29+
30+
$registeredLocally = false;
31+
32+
foreach ($this->arguments['listeners'] as $registeredListener) {
33+
if ($registeredListener instanceof SymfonyTestsListenerForV5) {
34+
$registeredListener->globalListenerDisabled();
35+
$registeredLocally = true;
36+
break;
37+
}
38+
}
39+
40+
if (!$registeredLocally) {
41+
$this->arguments['listeners'][] = $listener;
42+
}
43+
44+
return parent::createRunner();
2745
}
2846
}

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

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
use PHPUnit\TextUI\Command as BaseCommand;
1515
use PHPUnit\TextUI\TestRunner as BaseRunner;
16-
use Symfony\Bridge\PhpUnit\TextUI\TestRunner;
16+
use Symfony\Bridge\PhpUnit\SymfonyTestsListener;
1717

1818
/**
1919
* {@inheritdoc}
@@ -27,6 +27,24 @@ class CommandForV6 extends BaseCommand
2727
*/
2828
protected function createRunner(): BaseRunner
2929
{
30-
return new TestRunner($this->arguments['loader']);
30+
$listener = new SymfonyTestsListener();
31+
32+
$this->arguments['listeners'] = isset($this->arguments['listeners']) ? $this->arguments['listeners'] : [];
33+
34+
$registeredLocally = false;
35+
36+
foreach ($this->arguments['listeners'] as $registeredListener) {
37+
if ($registeredListener instanceof SymfonyTestsListener) {
38+
$registeredListener->globalListenerDisabled();
39+
$registeredLocally = true;
40+
break;
41+
}
42+
}
43+
44+
if (!$registeredLocally) {
45+
$this->arguments['listeners'][] = $listener;
46+
}
47+
48+
return parent::createRunner();
3149
}
3250
}

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

Lines changed: 0 additions & 48 deletions
This file was deleted.

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

Lines changed: 0 additions & 49 deletions
This file was deleted.

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

Lines changed: 0 additions & 49 deletions
This file was deleted.

src/Symfony/Bridge/PhpUnit/TextUI/TestRunner.php

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)
0