do not register the test listener twice

If the listener is already configured through the PHPUnit config, there
is no need to also enable it explicitly in the test runner.
This commit is contained in:
Christian Flothmann 2017-02-27 14:57:41 +01:00
parent 57a81eb992
commit cee435fefd

View File

@ -27,9 +27,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;
}
}