diff --git a/src/Symfony/Bridge/PhpUnit/Compat/Framework/AssertionFailedError.php b/src/Symfony/Bridge/PhpUnit/Compat/Framework/AssertionFailedError.php new file mode 100644 index 000000000000..b7fdf13052dc --- /dev/null +++ b/src/Symfony/Bridge/PhpUnit/Compat/Framework/AssertionFailedError.php @@ -0,0 +1,30 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bridge\PhpUnit\Compat\Framework; + +if (class_exists('PHPUnit\Framework\AssertionFailedError')) { + /** + * Class AssertionFailedError + * @package Symfony\Bridge\PhpUnit\Compat\Framework + * @internal + */ + class AssertionFailedError extends \PHPUnit\Framework\AssertionFailedError + {} +} else { + /** + * Class AssertionFailedError + * @package Symfony\Bridge\PhpUnit\Compat\Framework + * @internal + */ + class AssertionFailedError extends \PHPUnit_Framework_AssertionFailedError + {} +} diff --git a/src/Symfony/Bridge/PhpUnit/Compat/Framework/BaseTestListener.php b/src/Symfony/Bridge/PhpUnit/Compat/Framework/BaseTestListener.php new file mode 100644 index 000000000000..1914832ab417 --- /dev/null +++ b/src/Symfony/Bridge/PhpUnit/Compat/Framework/BaseTestListener.php @@ -0,0 +1,30 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bridge\PhpUnit\Compat\Framework; + +if (class_exists('PHPUnit\Framework\BaseTestListener')) { + /** + * Class BaseTestListener + * @package Symfony\Bridge\PhpUnit\Compat\Framework + * @internal + */ + abstract class BaseTestListener extends \PHPUnit\Framework\BaseTestListener + {} +} else { + /** + * Class BaseTestListener + * @package Symfony\Bridge\PhpUnit\Compat\Framework + * @internal + */ + abstract class BaseTestListener extends \PHPUnit_Framework_BaseTestListener + {} +} diff --git a/src/Symfony/Bridge/PhpUnit/Compat/Framework/TestCase.php b/src/Symfony/Bridge/PhpUnit/Compat/Framework/TestCase.php new file mode 100644 index 000000000000..b60c84d74ab1 --- /dev/null +++ b/src/Symfony/Bridge/PhpUnit/Compat/Framework/TestCase.php @@ -0,0 +1,30 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bridge\PhpUnit\Compat\Framework; + +if (class_exists('PHPUnit\Framework\TestCase')) { + /** + * Class TestCase + * @package Symfony\Bridge\PhpUnit\Compat\Framework + * @internal + */ + class TestCase extends \PHPUnit\Framework\TestCase + {} +} else { + /** + * Class TestCase + * @package Symfony\Bridge\PhpUnit\Compat\Framework + * @internal + */ + class TestCase extends \PHPUnit_Framework_TestCase + {} +} diff --git a/src/Symfony/Bridge/PhpUnit/Compat/Framework/Warning.php b/src/Symfony/Bridge/PhpUnit/Compat/Framework/Warning.php new file mode 100644 index 000000000000..a27dd81c6357 --- /dev/null +++ b/src/Symfony/Bridge/PhpUnit/Compat/Framework/Warning.php @@ -0,0 +1,30 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bridge\PhpUnit\Compat\Framework; + +if (class_exists('PHPUnit\Framework\Warning')) { + /** + * Class Warning + * @package Symfony\Bridge\PhpUnit\Compat\Framework + * @internal + */ + class Warning extends \PHPUnit\Framework\Warning + {} +} else { + /** + * Class Warning + * @package Symfony\Bridge\PhpUnit\Compat\Framework + * @internal + */ + class Warning extends \PHPUnit_Framework_Warning + {} +} diff --git a/src/Symfony/Bridge/PhpUnit/Compat/Runner/BaseTestRunner.php b/src/Symfony/Bridge/PhpUnit/Compat/Runner/BaseTestRunner.php new file mode 100644 index 000000000000..288896cd2b8c --- /dev/null +++ b/src/Symfony/Bridge/PhpUnit/Compat/Runner/BaseTestRunner.php @@ -0,0 +1,30 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bridge\PhpUnit\Compat\Runner; + +if (class_exists('PHPUnit\Runner\BaseTestRunner')) { + /** + * Class BaseTestRunner + * @package Symfony\Bridge\PhpUnit\Compat\Runner + * @internal + */ + abstract class BaseTestRunner extends \PHPUnit\Runner\BaseTestRunner + {} +} else { + /** + * Class BaseTestRunner + * @package Symfony\Bridge\PhpUnit\Compat\Runner + * @internal + */ + abstract class BaseTestRunner extends \PHPUnit_Runner_BaseTestRunner + {} +} diff --git a/src/Symfony/Bridge/PhpUnit/Compat/TextUI/Command.php b/src/Symfony/Bridge/PhpUnit/Compat/TextUI/Command.php new file mode 100644 index 000000000000..9a4b37ddb41f --- /dev/null +++ b/src/Symfony/Bridge/PhpUnit/Compat/TextUI/Command.php @@ -0,0 +1,30 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bridge\PhpUnit\Compat\TextUI; + +if (class_exists('PHPUnit\TextUI\Command')) { + /** + * Class Command + * @package Symfony\Bridge\PhpUnit\Compat\TextUI + * @internal + */ + class Command extends \PHPUnit\TextUI\Command + {} +} else { + /** + * Class Command + * @package Symfony\Bridge\PhpUnit\Compat\TextUI + * @internal + */ + class Command extends \PHPUnit_TextUI_Command + {} +} diff --git a/src/Symfony/Bridge/PhpUnit/Compat/TextUI/TestRunner.php b/src/Symfony/Bridge/PhpUnit/Compat/TextUI/TestRunner.php new file mode 100644 index 000000000000..8208ca083565 --- /dev/null +++ b/src/Symfony/Bridge/PhpUnit/Compat/TextUI/TestRunner.php @@ -0,0 +1,30 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bridge\PhpUnit\Compat\TextUI; + +if (class_exists('PHPUnit\TextUI\TestRunner')) { + /** + * Class TestRunner + * @package Symfony\Bridge\PhpUnit\Compat\TextUI + * @internal + */ + class TestRunner extends \PHPUnit\TextUI\TestRunner + {} +} else { + /** + * Class TestRunner + * @package Symfony\Bridge\PhpUnit\Compat\TextUI + * @internal + */ + class TestRunner extends \PHPUnit_TextUI_TestRunner + {} +} diff --git a/src/Symfony/Bridge/PhpUnit/Compat/Util/Blacklist.php b/src/Symfony/Bridge/PhpUnit/Compat/Util/Blacklist.php new file mode 100644 index 000000000000..ea8b240b1325 --- /dev/null +++ b/src/Symfony/Bridge/PhpUnit/Compat/Util/Blacklist.php @@ -0,0 +1,30 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bridge\PhpUnit\Compat\Util; + +if (class_exists('PHPUnit\Util\Blacklist')) { + /** + * Class Blacklist + * @package Symfony\Bridge\PhpUnit\Compat\Util + * @internal + */ + class Blacklist extends \PHPUnit\Util\Blacklist + {} +} else { + /** + * Class Blacklist + * @package Symfony\Bridge\PhpUnit\Compat\Util + * @internal + */ + class Blacklist extends \PHPUnit_Util_Blacklist + {} +} diff --git a/src/Symfony/Bridge/PhpUnit/Compat/Util/ErrorHandler.php b/src/Symfony/Bridge/PhpUnit/Compat/Util/ErrorHandler.php new file mode 100644 index 000000000000..f0b87b16f665 --- /dev/null +++ b/src/Symfony/Bridge/PhpUnit/Compat/Util/ErrorHandler.php @@ -0,0 +1,30 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bridge\PhpUnit\Compat\Util; + +if (class_exists('PHPUnit\Util\ErrorHandler')) { + /** + * Class ErrorHandler + * @package Symfony\Bridge\PhpUnit\Compat\Util + * @internal + */ + class ErrorHandler extends \PHPUnit\Util\ErrorHandler + {} +} else { + /** + * Class ErrorHandler + * @package Symfony\Bridge\PhpUnit\Compat\Util + * @internal + */ + class ErrorHandler extends \PHPUnit_Util_ErrorHandler + {} +} diff --git a/src/Symfony/Bridge/PhpUnit/Compat/Util/Test.php b/src/Symfony/Bridge/PhpUnit/Compat/Util/Test.php new file mode 100644 index 000000000000..022815093587 --- /dev/null +++ b/src/Symfony/Bridge/PhpUnit/Compat/Util/Test.php @@ -0,0 +1,30 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bridge\PhpUnit\Compat\Util; + +if (class_exists('PHPUnit\Util\Test')) { + /** + * Class Test + * @package Symfony\Bridge\PhpUnit\Compat\Util + * @internal + */ + class Test extends \PHPUnit\Util\Test + {} +} else { + /** + * Class Test + * @package Symfony\Bridge\PhpUnit\Compat\Util + * @internal + */ + class Test extends \PHPUnit_Util_Test + {} +} diff --git a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php index ca85d8aba599..0171ff234b5e 100644 --- a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php +++ b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php @@ -11,6 +11,9 @@ namespace Symfony\Bridge\PhpUnit; +use Symfony\Bridge\PhpUnit\Compat\Util\ErrorHandler; +use Symfony\Bridge\PhpUnit\Compat\Util\Test; + /** * Catch deprecation notices and print a summary report at the end of the test suite. * @@ -70,14 +73,14 @@ public static function register($mode = 0) $deprecationHandler = function ($type, $msg, $file, $line, $context) use (&$deprecations, $getMode) { $mode = $getMode(); if ((E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type) || DeprecationErrorHandler::MODE_DISABLED === $mode) { - return \PHPUnit_Util_ErrorHandler::handleError($type, $msg, $file, $line, $context); + return ErrorHandler::handleError($type, $msg, $file, $line, $context); } $trace = debug_backtrace(true); $group = 'other'; $i = count($trace); - while (1 < $i && (!isset($trace[--$i]['class']) || ('ReflectionMethod' === $trace[$i]['class'] || 0 === strpos($trace[$i]['class'], 'PHPUnit_')))) { + while (1 < $i && (!isset($trace[--$i]['class']) || ('ReflectionMethod' === $trace[$i]['class'] || 0 === strpos($trace[$i]['class'], 'PHPUnit_') || 0 === strpos($trace[$i]['class'], 'PHPUnit\\')))) { // No-op } @@ -91,7 +94,7 @@ public static function register($mode = 0) || 0 === strpos($method, 'provideLegacy') || 0 === strpos($method, 'getLegacy') || strpos($class, '\Legacy') - || in_array('legacy', \PHPUnit_Util_Test::getGroups($class, $method), true) + || in_array('legacy', Test::getGroups($class, $method), true) ) { $group = 'legacy'; } else { @@ -128,7 +131,7 @@ public static function register($mode = 0) if (null !== $oldErrorHandler) { restore_error_handler(); - if (array('PHPUnit_Util_ErrorHandler', 'handleError') === $oldErrorHandler) { + if (array('PHPUnit_Util_ErrorHandler', 'handleError') === $oldErrorHandler || array('PHPUnit\Util\ErrorHandler', 'handleError') === $oldErrorHandler) { restore_error_handler(); self::register($mode); } diff --git a/src/Symfony/Bridge/PhpUnit/SymfonyTestsListener.php b/src/Symfony/Bridge/PhpUnit/SymfonyTestsListener.php index 339ff3f8d417..a1b6b28bf9ae 100644 --- a/src/Symfony/Bridge/PhpUnit/SymfonyTestsListener.php +++ b/src/Symfony/Bridge/PhpUnit/SymfonyTestsListener.php @@ -12,13 +12,22 @@ namespace Symfony\Bridge\PhpUnit; use Doctrine\Common\Annotations\AnnotationRegistry; +use PHPUnit\Framework\Test; +use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\TestSuite; +use Symfony\Bridge\PhpUnit\Compat\Framework\AssertionFailedError; +use Symfony\Bridge\PhpUnit\Compat\Framework\BaseTestListener; +use Symfony\Bridge\PhpUnit\Compat\Framework\Warning; +use Symfony\Bridge\PhpUnit\Compat\Runner\BaseTestRunner; +use Symfony\Bridge\PhpUnit\Compat\Util\Blacklist; +use Symfony\Bridge\PhpUnit\Compat\Util\Test as TestUtil; /** * Collects and replays skipped tests. * * @author Nicolas Grekas
*/ -class SymfonyTestsListener extends \PHPUnit_Framework_BaseTestListener +class SymfonyTestsListener extends BaseTestListener { private static $globallyEnabled = false; private $state = -1; @@ -35,7 +44,7 @@ class SymfonyTestsListener extends \PHPUnit_Framework_BaseTestListener */ public function __construct(array $mockedNamespaces = array()) { - \PHPUnit_Util_Blacklist::$blacklistedClassNames['\Symfony\Bridge\PhpUnit\SymfonyTestsListener'] = 1; + Blacklist::$blacklistedClassNames['\Symfony\Bridge\PhpUnit\SymfonyTestsListener'] = 1; $warn = false; foreach ($mockedNamespaces as $type => $namespaces) { @@ -75,8 +84,13 @@ public function __destruct() } } - public function startTestSuite(\PHPUnit_Framework_TestSuite $suite) + /** + * @param \PHPUnit_Framework_TestSuite | TestSuite $suite + */ + public function startTestSuite($suite) { + $this->assertIsInstanceOfTestSuite($suite); + $suiteName = $suite->getName(); $this->testsWithWarnings = array(); @@ -103,12 +117,12 @@ public function startTestSuite(\PHPUnit_Framework_TestSuite $suite) $testSuites = array($suite); for ($i = 0; isset($testSuites[$i]); ++$i) { foreach ($testSuites[$i]->tests() as $test) { - if ($test instanceof \PHPUnit_Framework_TestSuite) { + if ($this->isInstanceOfTestSuite($test)) { if (!class_exists($test->getName(), false)) { $testSuites[] = $test; continue; } - $groups = \PHPUnit_Util_Test::getGroups($test->getName()); + $groups = TestUtil::getGroups($test->getName()); if (in_array('time-sensitive', $groups, true)) { ClockMock::register($test->getName()); } @@ -121,7 +135,7 @@ public function startTestSuite(\PHPUnit_Framework_TestSuite $suite) } elseif (2 === $this->state) { $skipped = array(); foreach ($suite->tests() as $test) { - if (!$test instanceof \PHPUnit_Framework_TestCase + if (!$this->isInstanceOfTestCase($test) || isset($this->wasSkipped[$suiteName]['*']) || isset($this->wasSkipped[$suiteName][$test->getName()])) { $skipped[] = $test; @@ -131,10 +145,17 @@ public function startTestSuite(\PHPUnit_Framework_TestSuite $suite) } } - public function addSkippedTest(\PHPUnit_Framework_Test $test, \Exception $e, $time) + /** + * @param \PHPUnit_Framework_Test | Test $test + * @param \Exception $e + * @param float $time + */ + public function addSkippedTest($test, \Exception $e, $time) { + $this->assertIsInstanceOfTest($test); + if (0 < $this->state) { - if ($test instanceof \PHPUnit_Framework_TestCase) { + if ($this->isInstanceOfTestCase($test)) { $class = get_class($test); $method = $test->getName(); } else { @@ -146,10 +167,15 @@ public function addSkippedTest(\PHPUnit_Framework_Test $test, \Exception $e, $ti } } - public function startTest(\PHPUnit_Framework_Test $test) + /** + * @param \PHPUnit_Framework_Test | Test $test + */ + public function startTest($test) { - if (-2 < $this->state && $test instanceof \PHPUnit_Framework_TestCase) { - $groups = \PHPUnit_Util_Test::getGroups(get_class($test), $test->getName(false)); + $this->assertIsInstanceOfTest($test); + + if (-2 < $this->state && $this->isInstanceOfTestCase($test)) { + $groups = TestUtil::getGroups(get_class($test), $test->getName(false)); if (in_array('time-sensitive', $groups, true)) { ClockMock::register(get_class($test)); @@ -159,14 +185,14 @@ public function startTest(\PHPUnit_Framework_Test $test) DnsMock::register(get_class($test)); } - $annotations = \PHPUnit_Util_Test::parseTestMethodAnnotations(get_class($test), $test->getName(false)); + $annotations = TestUtil::parseTestMethodAnnotations(get_class($test), $test->getName(false)); if (isset($annotations['class']['expectedDeprecation'])) { - $test->getTestResultObject()->addError($test, new \PHPUnit_Framework_AssertionFailedError('`@expectedDeprecation` annotations are not allowed at the class level.'), 0); + $test->getTestResultObject()->addError($test, new AssertionFailedError('`@expectedDeprecation` annotations are not allowed at the class level.'), 0); } if (isset($annotations['method']['expectedDeprecation'])) { if (!in_array('legacy', $groups, true)) { - $test->getTestResultObject()->addError($test, new \PHPUnit_Framework_AssertionFailedError('Only tests with the `@group legacy` annotation can have `@expectedDeprecation`.'), 0); + $test->getTestResultObject()->addError($test, new AssertionFailedError('Only tests with the `@group legacy` annotation can have `@expectedDeprecation`.'), 0); } $this->expectedDeprecations = $annotations['method']['expectedDeprecation']; $this->previousErrorHandler = set_error_handler(array($this, 'handleError')); @@ -174,35 +200,51 @@ public function startTest(\PHPUnit_Framework_Test $test) } } - public function addWarning(\PHPUnit_Framework_Test $test, \PHPUnit_Framework_Warning $e, $time) + /** + * @param \PHPUnit_Framework_Test | Test $test + * @param \PHPUnit_Framework_Warning | Warning $e + * @param $time + */ + public function addWarning($test, $e, $time) { - if ($test instanceof \PHPUnit_Framework_TestCase) { + $this->assertIsInstanceOfTest($test); + $this->assertIsInstanceOfWarning($e); + + if ($this->isInstanceOfTestCase($test)) { $this->testsWithWarnings[$test->getName()] = true; } } - public function endTest(\PHPUnit_Framework_Test $test, $time) + /** + * @param \PHPUnit_Framework_Test | Test $test + * @param float $time + */ + public function endTest($test, $time) { + $this->assertIsInstanceOfTest($test); + $className = get_class($test); - $classGroups = \PHPUnit_Util_Test::getGroups($className); - $groups = \PHPUnit_Util_Test::getGroups($className, $test->getName(false)); + $classGroups = TestUtil::getGroups($className); + $groups = TestUtil::getGroups($className, $test->getName(false)); if ($this->expectedDeprecations) { restore_error_handler(); - if (!in_array($test->getStatus(), array(\PHPUnit_Runner_BaseTestRunner::STATUS_SKIPPED, \PHPUnit_Runner_BaseTestRunner::STATUS_INCOMPLETE, \PHPUnit_Runner_BaseTestRunner::STATUS_FAILURE, \PHPUnit_Runner_BaseTestRunner::STATUS_ERROR), true)) { + if (!in_array($test->getStatus(), array(BaseTestRunner::STATUS_SKIPPED, BaseTestRunner::STATUS_INCOMPLETE, BaseTestRunner::STATUS_FAILURE, BaseTestRunner::STATUS_ERROR), true)) { try { $prefix = "@expectedDeprecation:\n"; $test->assertStringMatchesFormat($prefix.'%A '.implode("\n%A ", $this->expectedDeprecations)."\n%A", $prefix.' '.implode("\n ", $this->gatheredDeprecations)."\n"); } catch (\PHPUnit_Framework_AssertionFailedError $e) { $test->getTestResultObject()->addFailure($test, $e, $time); + } catch (\PHPUnit\Framework\AssertionFailedError $e) { + $test->getTestResultObject()->addFailure($test, $e, $time); } } $this->expectedDeprecations = $this->gatheredDeprecations = array(); $this->previousErrorHandler = null; } - if (-2 < $this->state && $test instanceof \PHPUnit_Framework_TestCase) { + if (-2 < $this->state && ($this->isInstanceOfTestCase($test))) { if (in_array('time-sensitive', $groups, true)) { ClockMock::withClockMock(false); } @@ -211,19 +253,19 @@ public function endTest(\PHPUnit_Framework_Test $test, $time) } } - if ($test instanceof \PHPUnit_Framework_TestCase && 0 === strpos($test->getName(), 'testLegacy') && !isset($this->testsWithWarnings[$test->getName()]) && !in_array('legacy', $groups, true)) { + if ($this->isInstanceOfTestCase($test) && 0 === strpos($test->getName(), 'testLegacy') && !isset($this->testsWithWarnings[$test->getName()]) && !in_array('legacy', $groups, true)) { $result = $test->getTestResultObject(); if (method_exists($result, 'addWarning')) { - $result->addWarning($test, new \PHPUnit_Framework_Warning('Using the "testLegacy" prefix to mark tests as legacy is deprecated since version 3.3 and will be removed in 4.0. Use the "@group legacy" notation instead to add the test to the legacy group.'), $time); + $result->addWarning($test, new Warning('Using the "testLegacy" prefix to mark tests as legacy is deprecated since version 3.3 and will be removed in 4.0. Use the "@group legacy" notation instead to add the test to the legacy group.'), $time); } } - if ($test instanceof \PHPUnit_Framework_TestCase && strpos($className, '\Legacy') && !isset($this->testsWithWarnings[$test->getName()]) && !in_array('legacy', $classGroups, true)) { + if ($this->isInstanceOfTestCase($test) && strpos($className, '\Legacy') && !isset($this->testsWithWarnings[$test->getName()]) && !in_array('legacy', $classGroups, true)) { $result = $test->getTestResultObject(); if (method_exists($result, 'addWarning')) { - $result->addWarning($test, new \PHPUnit_Framework_Warning('Using the "Legacy" prefix to mark all tests of a class as legacy is deprecated since version 3.3 and will be removed in 4.0. Use the "@group legacy" notation instead to add the test to the legacy group.'), $time); + $result->addWarning($test, new Warning('Using the "Legacy" prefix to mark all tests of a class as legacy is deprecated since version 3.3 and will be removed in 4.0. Use the "@group legacy" notation instead to add the test to the legacy group.'), $time); } } } @@ -240,4 +282,80 @@ public function handleError($type, $msg, $file, $line, $context) } $this->gatheredDeprecations[] = $msg; } + + private function assertIsInstanceOfTest($test) + { + if (!$this->isInstanceOfTest($test)) { + $argType = is_object($test) ? get_class($test) : gettype($test); + throw new \InvalidArgumentException('Wrong parameter: expected \PHPUnit_Framework_Test or PHPUnit\Framework\Test, got ' . $argType); + } + } + + private function assertIsInstanceOfTestSuite($testSuite) + { + if (!$this->isInstanceOfTestSuite($testSuite)) { + $argType = is_object($testSuite) ? get_class($testSuite) : gettype($testSuite); + throw new \InvalidArgumentException('Wrong parameter: expected \PHPUnit_Framework_TestSuite or PHPUnit\Framework\TestSuite, got ' . $argType); + } + } + + private function assertIsInstanceOfWarning($warning) + { + if (!$this->isInstanceOfWarning($warning)) { + $argType = is_object($warning) ? get_class($warning) : gettype($warning); + throw new \InvalidArgumentException('Wrong parameter: expected \PHPUnit_Framework_Warning or PHPUnit\Framework\Warning, got ' . $argType); + } + } + + private function isInstanceOfTestSuite($testSuite) + { + if (class_exists(\PHPUnit_Framework_TestSuite::class)) { + return $testSuite instanceof \PHPUnit_Framework_TestSuite; + } + + if (class_exists(TestSuite::class)) { + return $testSuite instanceof TestSuite; + } + + return false; + } + + private function isInstanceOfTestCase($testCase) + { + if (class_exists(\PHPUnit_Framework_TestCase::class)) { + return $testCase instanceof \PHPUnit_Framework_TestCase; + } + + if (class_exists(TestCase::class)) { + return $testCase instanceof TestCase; + } + + return false; + } + + private function isInstanceOfWarning($warning) + { + if (class_exists(\PHPUnit_Framework_Warning::class)) { + return $warning instanceof \PHPUnit_Framework_Warning; + } + + if (class_exists(Warning::class)) { + return $warning instanceof Warning; + } + + return false; + } + + private function isInstanceOfTest($test) + { + if (class_exists(\PHPUnit_Framework_Test::class)) { + return $test instanceof \PHPUnit_Framework_Test; + } + + if (class_exists(Test::class)) { + return $test instanceof Test; + } + + return false; + } } diff --git a/src/Symfony/Bridge/PhpUnit/Tests/DnsMockTest.php b/src/Symfony/Bridge/PhpUnit/Tests/DnsMockTest.php index 034d07a30f67..f5b3be23f546 100644 --- a/src/Symfony/Bridge/PhpUnit/Tests/DnsMockTest.php +++ b/src/Symfony/Bridge/PhpUnit/Tests/DnsMockTest.php @@ -11,9 +11,10 @@ namespace Symfony\Bridge\PhpUnit\Tests; +use Symfony\Bridge\PhpUnit\Compat\Framework\TestCase; use Symfony\Bridge\PhpUnit\DnsMock; -class DnsMockTest extends \PHPUnit_Framework_TestCase +class DnsMockTest extends TestCase { protected function tearDown() { diff --git a/src/Symfony/Bridge/PhpUnit/TextUI/Command.php b/src/Symfony/Bridge/PhpUnit/TextUI/Command.php index 203fd1641482..5b9535875a69 100644 --- a/src/Symfony/Bridge/PhpUnit/TextUI/Command.php +++ b/src/Symfony/Bridge/PhpUnit/TextUI/Command.php @@ -14,7 +14,7 @@ /** * {@inheritdoc} */ -class Command extends \PHPUnit_TextUI_Command +class Command extends \Symfony\Bridge\PhpUnit\Compat\TextUI\Command { /** * {@inheritdoc} diff --git a/src/Symfony/Bridge/PhpUnit/TextUI/TestRunner.php b/src/Symfony/Bridge/PhpUnit/TextUI/TestRunner.php index 94602bb3d63c..c3a48b8f33e1 100644 --- a/src/Symfony/Bridge/PhpUnit/TextUI/TestRunner.php +++ b/src/Symfony/Bridge/PhpUnit/TextUI/TestRunner.php @@ -16,7 +16,7 @@ /** * {@inheritdoc} */ -class TestRunner extends \PHPUnit_TextUI_TestRunner +class TestRunner extends \Symfony\Bridge\PhpUnit\Compat\TextUI\TestRunner { /** * {@inheritdoc} diff --git a/src/Symfony/Bridge/PhpUnit/bootstrap.php b/src/Symfony/Bridge/PhpUnit/bootstrap.php index 5e2ed0ca85f8..f2ceffb1b51a 100644 --- a/src/Symfony/Bridge/PhpUnit/bootstrap.php +++ b/src/Symfony/Bridge/PhpUnit/bootstrap.php @@ -13,7 +13,7 @@ use Symfony\Bridge\PhpUnit\DeprecationErrorHandler; // Detect if we're loaded by an actual run of phpunit -if (!defined('PHPUNIT_COMPOSER_INSTALL') && !class_exists('PHPUnit_TextUI_Command', false)) { +if (!defined('PHPUNIT_COMPOSER_INSTALL') && !class_exists('PHPUnit_TextUI_Command', false) && !class_exists('PHPUnit\TextUI\Command', false)) { return; }