Fix TestRunner compatibility to PhpUnit 8
This commit is contained in:
parent
77320cb645
commit
a0c66a399d
@ -23,6 +23,24 @@ class CommandForV5 extends \PHPUnit_TextUI_Command
|
|||||||
*/
|
*/
|
||||||
protected function createRunner()
|
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ namespace Symfony\Bridge\PhpUnit\Legacy;
|
|||||||
|
|
||||||
use PHPUnit\TextUI\Command as BaseCommand;
|
use PHPUnit\TextUI\Command as BaseCommand;
|
||||||
use PHPUnit\TextUI\TestRunner as BaseRunner;
|
use PHPUnit\TextUI\TestRunner as BaseRunner;
|
||||||
use Symfony\Bridge\PhpUnit\TextUI\TestRunner;
|
use Symfony\Bridge\PhpUnit\SymfonyTestsListener;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
@ -27,6 +27,24 @@ class CommandForV6 extends BaseCommand
|
|||||||
*/
|
*/
|
||||||
protected function createRunner(): BaseRunner
|
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,48 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Bridge\PhpUnit\Legacy;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*
|
|
||||||
* @internal
|
|
||||||
*/
|
|
||||||
class TestRunnerForV5 extends \PHPUnit_TextUI_TestRunner
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function handleConfiguration(array &$arguments)
|
|
||||||
{
|
|
||||||
$listener = new SymfonyTestsListenerForV5();
|
|
||||||
|
|
||||||
$result = parent::handleConfiguration($arguments);
|
|
||||||
|
|
||||||
$arguments['listeners'] = isset($arguments['listeners']) ? $arguments['listeners'] : array();
|
|
||||||
|
|
||||||
$registeredLocally = false;
|
|
||||||
|
|
||||||
foreach ($arguments['listeners'] as $registeredListener) {
|
|
||||||
if ($registeredListener instanceof SymfonyTestsListenerForV5) {
|
|
||||||
$registeredListener->globalListenerDisabled();
|
|
||||||
$registeredLocally = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$registeredLocally) {
|
|
||||||
$arguments['listeners'][] = $listener;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,49 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Bridge\PhpUnit\Legacy;
|
|
||||||
|
|
||||||
use PHPUnit\TextUI\TestRunner as BaseRunner;
|
|
||||||
use Symfony\Bridge\PhpUnit\SymfonyTestsListener;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*
|
|
||||||
* @internal
|
|
||||||
*/
|
|
||||||
class TestRunnerForV6 extends BaseRunner
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function handleConfiguration(array &$arguments)
|
|
||||||
{
|
|
||||||
$listener = new SymfonyTestsListener();
|
|
||||||
|
|
||||||
parent::handleConfiguration($arguments);
|
|
||||||
|
|
||||||
$arguments['listeners'] = isset($arguments['listeners']) ? $arguments['listeners'] : array();
|
|
||||||
|
|
||||||
$registeredLocally = false;
|
|
||||||
|
|
||||||
foreach ($arguments['listeners'] as $registeredListener) {
|
|
||||||
if ($registeredListener instanceof SymfonyTestsListener) {
|
|
||||||
$registeredListener->globalListenerDisabled();
|
|
||||||
$registeredLocally = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$registeredLocally) {
|
|
||||||
$arguments['listeners'][] = $listener;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,49 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Bridge\PhpUnit\Legacy;
|
|
||||||
|
|
||||||
use PHPUnit\TextUI\TestRunner as BaseRunner;
|
|
||||||
use Symfony\Bridge\PhpUnit\SymfonyTestsListener;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*
|
|
||||||
* @internal
|
|
||||||
*/
|
|
||||||
class TestRunnerForV7 extends BaseRunner
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function handleConfiguration(array &$arguments): void
|
|
||||||
{
|
|
||||||
$listener = new SymfonyTestsListener();
|
|
||||||
|
|
||||||
parent::handleConfiguration($arguments);
|
|
||||||
|
|
||||||
$arguments['listeners'] = isset($arguments['listeners']) ? $arguments['listeners'] : array();
|
|
||||||
|
|
||||||
$registeredLocally = false;
|
|
||||||
|
|
||||||
foreach ($arguments['listeners'] as $registeredListener) {
|
|
||||||
if ($registeredListener instanceof SymfonyTestsListener) {
|
|
||||||
$registeredListener->globalListenerDisabled();
|
|
||||||
$registeredLocally = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$registeredLocally) {
|
|
||||||
$arguments['listeners'][] = $listener;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Bridge\PhpUnit\TextUI;
|
|
||||||
|
|
||||||
if (class_exists('PHPUnit_Runner_Version') && version_compare(\PHPUnit_Runner_Version::id(), '6.0.0', '<')) {
|
|
||||||
class_alias('Symfony\Bridge\PhpUnit\Legacy\TestRunnerForV5', 'Symfony\Bridge\PhpUnit\TextUI\TestRunner');
|
|
||||||
} elseif (version_compare(\PHPUnit\Runner\Version::id(), '7.0.0', '<')) {
|
|
||||||
class_alias('Symfony\Bridge\PhpUnit\Legacy\TestRunnerForV6', 'Symfony\Bridge\PhpUnit\TextUI\TestRunner');
|
|
||||||
} else {
|
|
||||||
class_alias('Symfony\Bridge\PhpUnit\Legacy\TestRunnerForV7', 'Symfony\Bridge\PhpUnit\TextUI\TestRunner');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (false) {
|
|
||||||
class TestRunner
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
Reference in New Issue
Block a user