[PhpBridge] add PHPUnit 7 support to SymfonyTestsListener
This commit is contained in:
parent
a48849e58e
commit
a175a25d97
@ -16,10 +16,12 @@ use PHPUnit\Framework\Test;
|
|||||||
use PHPUnit\Framework\TestSuite;
|
use PHPUnit\Framework\TestSuite;
|
||||||
use PHPUnit\Framework\Warning;
|
use PHPUnit\Framework\Warning;
|
||||||
|
|
||||||
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');
|
|
||||||
// Using an early return instead of a else does not work when using the PHPUnit phar due to some weird PHP behavior (the class
|
// 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)
|
// 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');
|
||||||
} else {
|
} else {
|
||||||
/**
|
/**
|
||||||
* Collects and replays skipped tests.
|
* Collects and replays skipped tests.
|
||||||
|
@ -0,0 +1,69 @@
|
|||||||
|
<?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;
|
||||||
|
|
||||||
|
use PHPUnit\Framework\Test;
|
||||||
|
use PHPUnit\Framework\TestListener;
|
||||||
|
use PHPUnit\Framework\TestListenerDefaultImplementation;
|
||||||
|
use PHPUnit\Framework\TestSuite;
|
||||||
|
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
|
||||||
|
*/
|
||||||
|
class SymfonyTestsListenerWithReturnTypes implements TestListener
|
||||||
|
{
|
||||||
|
use TestListenerDefaultImplementation;
|
||||||
|
|
||||||
|
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): void
|
||||||
|
{
|
||||||
|
$this->trait->startTestSuite($suite);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addSkippedTest(Test $test, \Throwable $t, float $time): void
|
||||||
|
{
|
||||||
|
$this->trait->addSkippedTest($test, $t, $time);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function startTest(Test $test): void
|
||||||
|
{
|
||||||
|
$this->trait->startTest($test);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addWarning(Test $test, Warning $e, float $time): void
|
||||||
|
{
|
||||||
|
$this->trait->addWarning($test, $e, $time);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function endTest(Test $test, float $time): void
|
||||||
|
{
|
||||||
|
$this->trait->endTest($test, $time);
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user