Skip to content

Commit

Permalink
disable global test listener when not registered
Browse files Browse the repository at this point in the history
The global test listener is always initialized to register the clock
mock and DNS mock as soon as possible. However, when the listener is
registered locally through the PHPUnit config, it will never be
registered as a listener. In thise case, the state of the local
listener must be reset to correctly report expected deprecation test
results.
  • Loading branch information
xabbuh committed Mar 1, 2017
1 parent 4b27628 commit e068661
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/Symfony/Bridge/PhpUnit/SymfonyTestsListener.php
Expand Up @@ -68,6 +68,12 @@ public function __destruct()
}
}

public function globalListenerDisabled()
{
self::$globallyEnabled = false;
$this->state = -1;
}

public function startTestSuite(\PHPUnit_Framework_TestSuite $suite)
{
$suiteName = $suite->getName();
Expand Down
12 changes: 11 additions & 1 deletion src/Symfony/Bridge/PhpUnit/TextUI/TestRunner.php
Expand Up @@ -33,7 +33,17 @@ protected function handleConfiguration(array &$arguments)

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

if (!array_filter($arguments['listeners'], function ($listener) { return $listener instanceof SymfonyTestsListener; })) {
$registeredLocally = false;

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

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

Expand Down

0 comments on commit e068661

Please sign in to comment.