diff --git a/core/tests/Drupal/Tests/Core/Test/LegacyTest.php b/core/tests/Drupal/Tests/Core/Test/LegacyTest.php index cca015c..2c9081e 100644 --- a/core/tests/Drupal/Tests/Core/Test/LegacyTest.php +++ b/core/tests/Drupal/Tests/Core/Test/LegacyTest.php @@ -6,26 +6,43 @@ use Symfony\Bridge\PhpUnit\ErrorAssert; /** + * Tests Drupal's integration with Symfony PHPUnit Bridge. + * * @group legacy */ class LegacyTest extends UnitTestCase { /** - * Tests that the Symfony PHPUnit Bridge is working. + * Tests Symfony PHPUnit Bridge handles deprecation notices. + * + * @dataProvider providerTestSymfonyPhpUnitBridge() */ - public function testSymfonyPhpUnitBridge() { - ErrorAssert::assertDeprecationsAreTriggered('Testing Symfony PHPUnit Bridge', function () { - trigger_error('Testing Symfony PHPUnit Bridge', E_USER_DEPRECATED); - }); + public function testSymfonyPhpUnitBridge(callable $function, $expected) { + ErrorAssert::assertDeprecationsAreTriggered($expected, $function); } /** - * Tests that the Symfony PHPUnit Bridge is working. + * DataProvider for LegacyTest::testSymfonyPhpUnitBridge(). + * + * @return array */ - public function testSymfonyPhpUnitBridgeHideError() { - ErrorAssert::assertDeprecationsAreTriggered('Testing Symfony PHPUnit Bridge', function () { - @trigger_error('Testing Symfony PHPUnit Bridge', E_USER_DEPRECATED); - }); + public function providerTestSymfonyPhpUnitBridge() { + $tests = []; + // Test that a regular un-silenced E_USER_DEPRECATED error is caught. + $tests[] = [ + function () { + trigger_error('Testing Symfony PHPUnit Bridge', E_USER_DEPRECATED); + }, + 'Testing Symfony PHPUnit Bridge', + ]; + // Test that a silenced E_USER_DEPRECATED error is caught. + $tests[] = [ + function () { + @trigger_error('Testing Symfony PHPUnit Bridge with silenced errors', E_USER_DEPRECATED); + }, + 'Testing Symfony PHPUnit Bridge with silenced errors', + ]; + return $tests; } }