Skip to content

[PhpUnitBridge] do not register the test listener twice #21787

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 27, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/Symfony/Bridge/PhpUnit/TextUI/TestRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,16 @@ class TestRunner extends \PHPUnit_TextUI_TestRunner
*/
protected function handleConfiguration(array &$arguments)
{
$listener = new SymfonyTestsListener();

$result = parent::handleConfiguration($arguments);

$arguments['listeners'] = isset($arguments['listeners']) ? $arguments['listeners'] : array();
$arguments['listeners'][] = new SymfonyTestsListener();

return parent::handleConfiguration($arguments);
if (!array_filter($arguments['listeners'], function ($listener) { return $listener instanceof SymfonyTestsListener; })) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to filter the whole array. We should stop as soon as we find a SymfonyTestsListener even if it is the first one.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're right - yet this is a non issue in practice, isn't it? this array is usually almost empty

$arguments['listeners'][] = $listener;
}

return $result;
}
}