minor #26139 [Bridge\PhpUnit] Cleanup BC layer (nicolas-grekas)
This PR was merged into the 3.4 branch.
Discussion
----------
[Bridge\PhpUnit] Cleanup BC layer
| Q | A
| ------------- | ---
| Branch? | 3.4
| Bug fix? | no
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | -
| License | MIT
| Doc PR | -
Follow up of #26024
Commits
-------
c41681c
[Bridge\PhpUnit] Cleanup BC layer
This commit is contained in:
commit
fd1d6d1191
@ -18,7 +18,7 @@ namespace Symfony\Bridge\PhpUnit\Legacy;
|
|||||||
*
|
*
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
class SymfonyTestsListener extends \PHPUnit_Framework_BaseTestListener
|
class SymfonyTestsListenerForV5 extends \PHPUnit_Framework_BaseTestListener
|
||||||
{
|
{
|
||||||
private $trait;
|
private $trait;
|
||||||
|
|
||||||
@ -34,26 +34,26 @@ class SymfonyTestsListener extends \PHPUnit_Framework_BaseTestListener
|
|||||||
|
|
||||||
public function startTestSuite(\PHPUnit_Framework_TestSuite $suite)
|
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)
|
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)
|
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)
|
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)
|
public function endTest(\PHPUnit_Framework_Test $test, $time)
|
||||||
{
|
{
|
||||||
return $this->trait->endTest($test, $time);
|
$this->trait->endTest($test, $time);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
@ -20,13 +20,11 @@ use PHPUnit\Framework\Warning;
|
|||||||
/**
|
/**
|
||||||
* Collects and replays skipped tests.
|
* Collects and replays skipped tests.
|
||||||
*
|
*
|
||||||
* (Version of SymfonyTestsListener for PHPUnit 7+, and PHP 7.1+.)
|
|
||||||
*
|
|
||||||
* @author Nicolas Grekas <p@tchwork.com>
|
* @author Nicolas Grekas <p@tchwork.com>
|
||||||
*
|
*
|
||||||
* @final
|
* @internal
|
||||||
*/
|
*/
|
||||||
class SymfonyTestsListenerWithReturnTypes implements TestListener
|
class SymfonyTestsListenerForV7 implements TestListener
|
||||||
{
|
{
|
||||||
use TestListenerDefaultImplementation;
|
use TestListenerDefaultImplementation;
|
||||||
|
|
||||||
@ -34,7 +32,7 @@ class SymfonyTestsListenerWithReturnTypes implements TestListener
|
|||||||
|
|
||||||
public function __construct(array $mockedNamespaces = array())
|
public function __construct(array $mockedNamespaces = array())
|
||||||
{
|
{
|
||||||
$this->trait = new Legacy\SymfonyTestsListenerTrait($mockedNamespaces);
|
$this->trait = new SymfonyTestsListenerTrait($mockedNamespaces);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function globalListenerDisabled()
|
public function globalListenerDisabled()
|
@ -11,62 +11,10 @@
|
|||||||
|
|
||||||
namespace Symfony\Bridge\PhpUnit;
|
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', '<')) {
|
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');
|
class_alias('Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerForV5', 'Symfony\Bridge\PhpUnit\SymfonyTestsListener');
|
||||||
} elseif (version_compare(\PHPUnit\Runner\Version::id(), '7.0.0', '>=')) {
|
} 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\SymfonyTestsListenerForV6', 'Symfony\Bridge\PhpUnit\SymfonyTestsListener');
|
||||||
} else {
|
} else {
|
||||||
/**
|
class_alias('Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerForV7', 'Symfony\Bridge\PhpUnit\SymfonyTestsListener');
|
||||||
* 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user