From 8e607b58df3fe820ea6e8ac4f2e3b6b36588c1cd Mon Sep 17 00:00:00 2001 From: Steve Grunwell Date: Mon, 28 Sep 2020 16:03:26 -0400 Subject: [PATCH] [PhpUnitBridge] Fix class_alias() for PHPUnit\Framework\Error\Error PHPUnit 6.x removed the PHPUnit_Framework_* classes in favor of PHP namespaces, but one error class did not map the same as the others: `PHPUnit_Framework_Error`. Instead of mapping to `PHPUnit\Framework\Error` in the same way that `PHPUnit_Framework_Error_Warning` mapped to `PHPUnit\Framework\Error\Warning`, this base class was replaced with `PHPUnit\Framework\Error\Error`. --- .../Bridge/PhpUnit/Tests/BootstrapTest.php | 40 +++++++++++++++++++ src/Symfony/Bridge/PhpUnit/bootstrap.php | 2 +- 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 src/Symfony/Bridge/PhpUnit/Tests/BootstrapTest.php diff --git a/src/Symfony/Bridge/PhpUnit/Tests/BootstrapTest.php b/src/Symfony/Bridge/PhpUnit/Tests/BootstrapTest.php new file mode 100644 index 0000000000..d181157508 --- /dev/null +++ b/src/Symfony/Bridge/PhpUnit/Tests/BootstrapTest.php @@ -0,0 +1,40 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bridge\PhpUnit\Tests; + +use PHPUnit\Framework\TestCase; + +class BootstrapTest extends TestCase +{ + /** + * @requires PHPUnit < 6.0 + */ + public function testAliasingOfErrorClasses() + { + $this->assertInstanceOf( + \PHPUnit_Framework_Error::class, + new \PHPUnit\Framework\Error\Error('message', 0, __FILE__, __LINE__) + ); + $this->assertInstanceOf( + \PHPUnit_Framework_Error_Deprecated::class, + new \PHPUnit\Framework\Error\Deprecated('message', 0, __FILE__, __LINE__) + ); + $this->assertInstanceOf( + \PHPUnit_Framework_Error_Notice::class, + new \PHPUnit\Framework\Error\Notice('message', 0, __FILE__, __LINE__) + ); + $this->assertInstanceOf( + \PHPUnit_Framework_Error_Warning::class, + new \PHPUnit\Framework\Error\Warning('message', 0, __FILE__, __LINE__) + ); + } +} diff --git a/src/Symfony/Bridge/PhpUnit/bootstrap.php b/src/Symfony/Bridge/PhpUnit/bootstrap.php index 490b1bfded..2b6f2bac6c 100644 --- a/src/Symfony/Bridge/PhpUnit/bootstrap.php +++ b/src/Symfony/Bridge/PhpUnit/bootstrap.php @@ -56,7 +56,6 @@ if (class_exists('PHPUnit_Runner_Version') && version_compare(\PHPUnit_Runner_Ve 'PHPUnit_Framework_Constraint_TraversableContains', 'PHPUnit_Framework_Constraint_TraversableContainsOnly', - 'PHPUnit_Framework_Error', 'PHPUnit_Framework_Error_Deprecated', 'PHPUnit_Framework_Error_Notice', 'PHPUnit_Framework_Error_Warning', @@ -100,6 +99,7 @@ if (class_exists('PHPUnit_Runner_Version') && version_compare(\PHPUnit_Runner_Ve class_alias('PHPUnit_Framework_Constraint_Not', 'PHPUnit\Framework\Constraint\LogicalNot'); class_alias('PHPUnit_Framework_Constraint_Or', 'PHPUnit\Framework\Constraint\LogicalOr'); class_alias('PHPUnit_Framework_Constraint_Xor', 'PHPUnit\Framework\Constraint\LogicalXor'); + class_alias('PHPUnit_Framework_Error', 'PHPUnit\Framework\Error\Error'); } // Detect if we need to serialize deprecations to a file.