Fix 5.3 compat of SymfonyTestsListener
This commit is contained in:
parent
6c0d5c90e4
commit
ba8abcb5d0
@ -11,8 +11,6 @@
|
||||
|
||||
namespace Symfony\Bridge\PhpUnit\Legacy;
|
||||
|
||||
use Symfony\Bridge\PhpUnit\SymfonyTestsListenerTrait;
|
||||
|
||||
/**
|
||||
* Collects and replays skipped tests.
|
||||
*
|
||||
@ -22,30 +20,35 @@ use Symfony\Bridge\PhpUnit\SymfonyTestsListenerTrait;
|
||||
*/
|
||||
class SymfonyTestsListener extends \PHPUnit_Framework_BaseTestListener
|
||||
{
|
||||
use SymfonyTestsListenerTrait;
|
||||
private $trait;
|
||||
|
||||
public function __construct(array $mockedNamespaces = array())
|
||||
{
|
||||
$this->trait = new SymfonyTestsListenerTrait($mockedNamespaces);
|
||||
}
|
||||
|
||||
public function startTestSuite(\PHPUnit_Framework_TestSuite $suite)
|
||||
{
|
||||
return $this->doStartTestSuite($suite);
|
||||
return $this->trait->startTestSuite($suite);
|
||||
}
|
||||
|
||||
public function addSkippedTest(\PHPUnit_Framework_Test $test, \Exception $e, $time)
|
||||
{
|
||||
return $this->doAddSkippedTest($test, $e, $time);
|
||||
return $this->trait->addSkippedTest($test, $e, $time);
|
||||
}
|
||||
|
||||
public function startTest(\PHPUnit_Framework_Test $test)
|
||||
{
|
||||
return $this->doStartTest($test);
|
||||
return $this->trait->startTest($test);
|
||||
}
|
||||
|
||||
public function addWarning(\PHPUnit_Framework_Test $test, \PHPUnit_Framework_Warning $e, $time)
|
||||
{
|
||||
return $this->doAddWarning($test, $e, $time);
|
||||
return $this->trait->addWarning($test, $e, $time);
|
||||
}
|
||||
|
||||
public function endTest(\PHPUnit_Framework_Test $test, $time)
|
||||
{
|
||||
return $this->doEndTest($test, $time);
|
||||
return $this->trait->endTest($test, $time);
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bridge\PhpUnit;
|
||||
namespace Symfony\Bridge\PhpUnit\Legacy;
|
||||
|
||||
use Doctrine\Common\Annotations\AnnotationRegistry;
|
||||
use PHPUnit\Framework\AssertionFailedError;
|
||||
@ -19,13 +19,13 @@ use PHPUnit\Util\Blacklist;
|
||||
use PHPUnit\Util\Test;
|
||||
|
||||
/**
|
||||
* Collects and replays skipped tests.
|
||||
* PHP 5.3 compatible trait-like shared implementation.
|
||||
*
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
trait SymfonyTestsListenerTrait
|
||||
class SymfonyTestsListenerTrait
|
||||
{
|
||||
private static $globallyEnabled = false;
|
||||
private $state = -1;
|
||||
@ -45,13 +45,13 @@ trait SymfonyTestsListenerTrait
|
||||
if (class_exists('PHPUnit_Util_Blacklist')) {
|
||||
\PHPUnit_Util_Blacklist::$blacklistedClassNames['\Symfony\Bridge\PhpUnit\DeprecationErrorHandler'] = 1;
|
||||
\PHPUnit_Util_Blacklist::$blacklistedClassNames['\Symfony\Bridge\PhpUnit\SymfonyTestsListener'] = 1;
|
||||
\PHPUnit_Util_Blacklist::$blacklistedClassNames['\Symfony\Bridge\PhpUnit\SymfonyTestsListenerTrait'] = 1;
|
||||
\PHPUnit_Util_Blacklist::$blacklistedClassNames['\Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListener'] = 1;
|
||||
\PHPUnit_Util_Blacklist::$blacklistedClassNames['\Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerTrait'] = 1;
|
||||
} else {
|
||||
Blacklist::$blacklistedClassNames['\Symfony\Bridge\PhpUnit\DeprecationErrorHandler'] = 1;
|
||||
Blacklist::$blacklistedClassNames['\Symfony\Bridge\PhpUnit\SymfonyTestsListener'] = 1;
|
||||
Blacklist::$blacklistedClassNames['\Symfony\Bridge\PhpUnit\SymfonyTestsListenerTrait'] = 1;
|
||||
Blacklist::$blacklistedClassNames['\Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListener'] = 1;
|
||||
Blacklist::$blacklistedClassNames['\Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerTrait'] = 1;
|
||||
}
|
||||
|
||||
$warn = false;
|
||||
@ -92,7 +92,7 @@ trait SymfonyTestsListenerTrait
|
||||
}
|
||||
}
|
||||
|
||||
private function doStartTestSuite($suite)
|
||||
public function startTestSuite($suite)
|
||||
{
|
||||
if (class_exists('PHPUnit_Util_Blacklist', false)) {
|
||||
$Test = 'PHPUnit_Util_Test';
|
||||
@ -153,7 +153,7 @@ trait SymfonyTestsListenerTrait
|
||||
}
|
||||
}
|
||||
|
||||
private function doAddSkippedTest($test, \Exception $e, $time)
|
||||
public function addSkippedTest($test, \Exception $e, $time)
|
||||
{
|
||||
if (0 < $this->state) {
|
||||
if ($test instanceof \PHPUnit_Framework_TestCase || $test instanceof TestCase) {
|
||||
@ -168,7 +168,7 @@ trait SymfonyTestsListenerTrait
|
||||
}
|
||||
}
|
||||
|
||||
private function doStartTest($test)
|
||||
public function startTest($test)
|
||||
{
|
||||
if (-2 < $this->state && ($test instanceof \PHPUnit_Framework_TestCase || $test instanceof TestCase)) {
|
||||
if (class_exists('PHPUnit_Util_Blacklist', false)) {
|
||||
@ -203,14 +203,14 @@ trait SymfonyTestsListenerTrait
|
||||
}
|
||||
}
|
||||
|
||||
private function doAddWarning($test, $e, $time)
|
||||
public function addWarning($test, $e, $time)
|
||||
{
|
||||
if ($test instanceof \PHPUnit_Framework_TestCase || $test instanceof TestCase) {
|
||||
$this->testsWithWarnings[$test->getName()] = true;
|
||||
}
|
||||
}
|
||||
|
||||
private function doEndTest($test, $time)
|
||||
public function endTest($test, $time)
|
||||
{
|
||||
if (class_exists('PHPUnit_Util_Blacklist', false)) {
|
||||
$Test = 'PHPUnit_Util_Test';
|
@ -31,30 +31,35 @@ if (class_exists('PHPUnit_Framework_BaseTestListener')) {
|
||||
*/
|
||||
class SymfonyTestsListener extends BaseTestListener
|
||||
{
|
||||
use SymfonyTestsListenerTrait;
|
||||
private $trait;
|
||||
|
||||
public function __construct(array $mockedNamespaces = array())
|
||||
{
|
||||
$this->trait = new Legacy\SymfonyTestsListenerTrait($mockedNamespaces);
|
||||
}
|
||||
|
||||
public function startTestSuite(TestSuite $suite)
|
||||
{
|
||||
return $this->doStartTestSuite($suite);
|
||||
return $this->trait->startTestSuite($suite);
|
||||
}
|
||||
|
||||
public function addSkippedTest(Test $test, \Exception $e, $time)
|
||||
{
|
||||
return $this->doAddSkippedTest($test, $e, $time);
|
||||
return $this->trait->addSkippedTest($test, $e, $time);
|
||||
}
|
||||
|
||||
public function startTest(Test $test)
|
||||
{
|
||||
return $this->doStartTest($test);
|
||||
return $this->trait->startTest($test);
|
||||
}
|
||||
|
||||
public function addWarning(Test $test, Warning $e, $time)
|
||||
{
|
||||
return $this->doAddWarning($test, $e, $time);
|
||||
return $this->trait->addWarning($test, $e, $time);
|
||||
}
|
||||
|
||||
public function endTest(Test $test, $time)
|
||||
{
|
||||
return $this->doEndTest($test, $time);
|
||||
return $this->trait->endTest($test, $time);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user