diff --git a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListener.php b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerForV5.php similarity index 76% rename from src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListener.php rename to src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerForV5.php index 5ed545a512..2da40f2c20 100644 --- a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListener.php +++ b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerForV5.php @@ -18,7 +18,7 @@ namespace Symfony\Bridge\PhpUnit\Legacy; * * @internal */ -class SymfonyTestsListener extends \PHPUnit_Framework_BaseTestListener +class SymfonyTestsListenerForV5 extends \PHPUnit_Framework_BaseTestListener { private $trait; @@ -34,26 +34,26 @@ class SymfonyTestsListener extends \PHPUnit_Framework_BaseTestListener public function startTestSuite(\PHPUnit_Framework_TestSuite $suite) { - return $this->trait->startTestSuite($suite); + $this->trait->startTestSuite($suite); } public function addSkippedTest(\PHPUnit_Framework_Test $test, \Exception $e, $time) { - return $this->trait->addSkippedTest($test, $e, $time); + $this->trait->addSkippedTest($test, $e, $time); } public function startTest(\PHPUnit_Framework_Test $test) { - return $this->trait->startTest($test); + $this->trait->startTest($test); } public function addWarning(\PHPUnit_Framework_Test $test, \PHPUnit_Framework_Warning $e, $time) { - return $this->trait->addWarning($test, $e, $time); + $this->trait->addWarning($test, $e, $time); } public function endTest(\PHPUnit_Framework_Test $test, $time) { - return $this->trait->endTest($test, $time); + $this->trait->endTest($test, $time); } } diff --git a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerForV6.php b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerForV6.php new file mode 100644 index 0000000000..d8e74e8192 --- /dev/null +++ b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerForV6.php @@ -0,0 +1,64 @@ + + * + * 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\Framework\BaseTestListener; +use PHPUnit\Framework\Test; +use PHPUnit\Framework\TestSuite; +use PHPUnit\Framework\Warning; + +/** + * Collects and replays skipped tests. + * + * @author Nicolas Grekas + * + * @internal + */ +class SymfonyTestsListenerForV6 extends BaseTestListener +{ + private $trait; + + public function __construct(array $mockedNamespaces = array()) + { + $this->trait = new Legacy\SymfonyTestsListenerTrait($mockedNamespaces); + } + + public function globalListenerDisabled() + { + $this->trait->globalListenerDisabled(); + } + + public function startTestSuite(TestSuite $suite) + { + $this->trait->startTestSuite($suite); + } + + public function addSkippedTest(Test $test, \Exception $e, $time) + { + $this->trait->addSkippedTest($test, $e, $time); + } + + public function startTest(Test $test) + { + $this->trait->startTest($test); + } + + public function addWarning(Test $test, Warning $e, $time) + { + $this->trait->addWarning($test, $e, $time); + } + + public function endTest(Test $test, $time) + { + $this->trait->endTest($test, $time); + } +} diff --git a/src/Symfony/Bridge/PhpUnit/SymfonyTestsListenerWithReturnTypes.php b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerForV7.php similarity index 86% rename from src/Symfony/Bridge/PhpUnit/SymfonyTestsListenerWithReturnTypes.php rename to src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerForV7.php index dfe13afb3f..d3acd53960 100644 --- a/src/Symfony/Bridge/PhpUnit/SymfonyTestsListenerWithReturnTypes.php +++ b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerForV7.php @@ -20,13 +20,11 @@ use PHPUnit\Framework\Warning; /** * Collects and replays skipped tests. * - * (Version of SymfonyTestsListener for PHPUnit 7+, and PHP 7.1+.) - * * @author Nicolas Grekas * - * @final + * @internal */ -class SymfonyTestsListenerWithReturnTypes implements TestListener +class SymfonyTestsListenerForV7 implements TestListener { use TestListenerDefaultImplementation; @@ -34,7 +32,7 @@ class SymfonyTestsListenerWithReturnTypes implements TestListener public function __construct(array $mockedNamespaces = array()) { - $this->trait = new Legacy\SymfonyTestsListenerTrait($mockedNamespaces); + $this->trait = new SymfonyTestsListenerTrait($mockedNamespaces); } public function globalListenerDisabled() diff --git a/src/Symfony/Bridge/PhpUnit/SymfonyTestsListener.php b/src/Symfony/Bridge/PhpUnit/SymfonyTestsListener.php index 7115f31485..d46a79e00e 100644 --- a/src/Symfony/Bridge/PhpUnit/SymfonyTestsListener.php +++ b/src/Symfony/Bridge/PhpUnit/SymfonyTestsListener.php @@ -11,62 +11,10 @@ namespace Symfony\Bridge\PhpUnit; -use PHPUnit\Framework\BaseTestListener; -use PHPUnit\Framework\Test; -use PHPUnit\Framework\TestSuite; -use PHPUnit\Framework\Warning; - -// Using an early return instead of a else does not work when using the PHPUnit phar due to some weird PHP behavior (the class -// gets defined without executing the code before it and so the definition is not properly conditional) if (class_exists('PHPUnit_Runner_Version') && version_compare(\PHPUnit_Runner_Version::id(), '6.0.0', '<')) { - class_alias('Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListener', 'Symfony\Bridge\PhpUnit\SymfonyTestsListener'); -} elseif (version_compare(\PHPUnit\Runner\Version::id(), '7.0.0', '>=')) { - class_alias('Symfony\Bridge\PhpUnit\SymfonyTestsListenerWithReturnTypes', 'Symfony\Bridge\PhpUnit\SymfonyTestsListener'); + class_alias('Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerForV5', 'Symfony\Bridge\PhpUnit\SymfonyTestsListener'); +} elseif (version_compare(\PHPUnit\Runner\Version::id(), '7.0.0', '<')) { + class_alias('Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerForV6', 'Symfony\Bridge\PhpUnit\SymfonyTestsListener'); } else { - /** - * Collects and replays skipped tests. - * - * @author Nicolas Grekas - * - * @final - */ - class SymfonyTestsListener extends BaseTestListener - { - private $trait; - - public function __construct(array $mockedNamespaces = array()) - { - $this->trait = new Legacy\SymfonyTestsListenerTrait($mockedNamespaces); - } - - public function globalListenerDisabled() - { - $this->trait->globalListenerDisabled(); - } - - public function startTestSuite(TestSuite $suite) - { - return $this->trait->startTestSuite($suite); - } - - public function addSkippedTest(Test $test, \Exception $e, $time) - { - return $this->trait->addSkippedTest($test, $e, $time); - } - - public function startTest(Test $test) - { - return $this->trait->startTest($test); - } - - public function addWarning(Test $test, Warning $e, $time) - { - return $this->trait->addWarning($test, $e, $time); - } - - public function endTest(Test $test, $time) - { - return $this->trait->endTest($test, $time); - } - } + class_alias('Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerForV7', 'Symfony\Bridge\PhpUnit\SymfonyTestsListener'); }