Skip to content

Commit

Permalink
bug #30085 Fix TestRunner compatibility to PhpUnit 8 (alexander-schranz)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
nicolas-grekas committed Apr 8, 2019
2 parents b30f57e + a0c66a3 commit d7a8b3d
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 175 deletions.
20 changes: 19 additions & 1 deletion src/Symfony/Bridge/PhpUnit/Legacy/CommandForV5.php
Expand Up @@ -23,6 +23,24 @@ class CommandForV5 extends \PHPUnit_TextUI_Command
*/
protected function createRunner()
{
return new TestRunnerForV5($this->arguments['loader']);
$listener = new SymfonyTestsListenerForV5();

$this->arguments['listeners'] = isset($this->arguments['listeners']) ? $this->arguments['listeners'] : array();

$registeredLocally = false;

foreach ($this->arguments['listeners'] as $registeredListener) {
if ($registeredListener instanceof SymfonyTestsListenerForV5) {
$registeredListener->globalListenerDisabled();
$registeredLocally = true;
break;
}
}

if (!$registeredLocally) {
$this->arguments['listeners'][] = $listener;
}

return parent::createRunner();
}
}
22 changes: 20 additions & 2 deletions src/Symfony/Bridge/PhpUnit/Legacy/CommandForV6.php
Expand Up @@ -13,7 +13,7 @@

use PHPUnit\TextUI\Command as BaseCommand;
use PHPUnit\TextUI\TestRunner as BaseRunner;
use Symfony\Bridge\PhpUnit\TextUI\TestRunner;
use Symfony\Bridge\PhpUnit\SymfonyTestsListener;

/**
* {@inheritdoc}
Expand All @@ -27,6 +27,24 @@ class CommandForV6 extends BaseCommand
*/
protected function createRunner(): BaseRunner
{
return new TestRunner($this->arguments['loader']);
$listener = new SymfonyTestsListener();

$this->arguments['listeners'] = isset($this->arguments['listeners']) ? $this->arguments['listeners'] : [];

$registeredLocally = false;

foreach ($this->arguments['listeners'] as $registeredListener) {
if ($registeredListener instanceof SymfonyTestsListener) {
$registeredListener->globalListenerDisabled();
$registeredLocally = true;
break;
}
}

if (!$registeredLocally) {
$this->arguments['listeners'][] = $listener;
}

return parent::createRunner();
}
}
48 changes: 0 additions & 48 deletions src/Symfony/Bridge/PhpUnit/Legacy/TestRunnerForV5.php

This file was deleted.

49 changes: 0 additions & 49 deletions src/Symfony/Bridge/PhpUnit/Legacy/TestRunnerForV6.php

This file was deleted.

49 changes: 0 additions & 49 deletions src/Symfony/Bridge/PhpUnit/Legacy/TestRunnerForV7.php

This file was deleted.

26 changes: 0 additions & 26 deletions src/Symfony/Bridge/PhpUnit/TextUI/TestRunner.php

This file was deleted.

0 comments on commit d7a8b3d

Please sign in to comment.