[Bridge\PhpUnit] Cleanup BC layer

This commit is contained in:
Nicolas Grekas 2018-02-11 15:19:16 +01:00
parent 40fb8434d3
commit c41681cb80
4 changed files with 77 additions and 67 deletions

View File

@ -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);
}
}

View File

@ -0,0 +1,64 @@
<?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\Framework\BaseTestListener;
use PHPUnit\Framework\Test;
use PHPUnit\Framework\TestSuite;
use PHPUnit\Framework\Warning;
/**
* Collects and replays skipped tests.
*
* @author Nicolas Grekas <p@tchwork.com>
*
* @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);
}
}

View File

@ -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 <p@tchwork.com>
*
* @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()

View File

@ -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 <p@tchwork.com>
*
* @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');
}