bug #21788 [PhpUnitBridge] do not register the test listener twice (xabbuh)

This PR was merged into the 3.3-dev branch.

Discussion
----------

[PhpUnitBridge] do not register the test listener twice

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

If the listener is already configured through the PHPUnit config, there
is no need to also enable it explicitly in the test runner.

Commits
-------

f7bdfd068f do not register the test listener twice
This commit is contained in:
Fabien Potencier 2017-03-01 06:33:32 -08:00
commit 431fad02c6

View File

@ -23,9 +23,16 @@ class TestRunner extends \PHPUnit_TextUI_TestRunner
*/
protected function handleConfiguration(array &$arguments)
{
$arguments['listeners'] = isset($arguments['listeners']) ? $arguments['listeners'] : array();
$arguments['listeners'][] = new SymfonyTestsListener();
$listener = new SymfonyTestsListener();
return parent::handleConfiguration($arguments);
$result = parent::handleConfiguration($arguments);
$arguments['listeners'] = isset($arguments['listeners']) ? $arguments['listeners'] : array();
if (!array_filter($arguments['listeners'], function ($listener) { return $listener instanceof SymfonyTestsListener; })) {
$arguments['listeners'][] = $listener;
}
return $result;
}
}