From c8cfcf07a8efe5fe72ad1e3e5d3cdea712aeb675 Mon Sep 17 00:00:00 2001 From: catch Date: Wed, 10 Apr 2024 21:58:24 +0100 Subject: [PATCH] Issue #3427178 by mondrake, longwave: Replace calls to ::expectWarning*() from Drupal\Tests\Core\Security\DoTrustedCallbackTraitTest --- core/.phpstan-baseline.php | 12 ------------ .../Drupal/Core/Security/DoTrustedCallbackTrait.php | 4 ---- .../Core/Security/StaticTrustedCallbackHelper.php | 1 - .../Core/Security/TrustedCallbackInterface.php | 5 ----- .../Core/Security/DoTrustedCallbackTraitTest.php | 9 --------- 5 files changed, 31 deletions(-) diff --git a/core/.phpstan-baseline.php b/core/.phpstan-baseline.php index ce5472a1b88..c4283234b86 100644 --- a/core/.phpstan-baseline.php +++ b/core/.phpstan-baseline.php @@ -2221,18 +2221,6 @@ $ignoreErrors[] = [ 'count' => 1, 'path' => __DIR__ . '/tests/Drupal/Tests/Core/Plugin/TestPluginManager.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Call to deprecated method expectWarning\\(\\) of class PHPUnit\\\\Framework\\\\TestCase\\: -https\\://github\\.com/sebastianbergmann/phpunit/issues/5062$#', - 'count' => 1, - 'path' => __DIR__ . '/tests/Drupal/Tests/Core/Security/DoTrustedCallbackTraitTest.php', -]; -$ignoreErrors[] = [ - 'message' => '#^Call to deprecated method expectWarningMessage\\(\\) of class PHPUnit\\\\Framework\\\\TestCase\\: -https\\://github\\.com/sebastianbergmann/phpunit/issues/5062$#', - 'count' => 1, - 'path' => __DIR__ . '/tests/Drupal/Tests/Core/Security/DoTrustedCallbackTraitTest.php', -]; $ignoreErrors[] = [ 'message' => '#^Variable \\$value in isset\\(\\) always exists and is not nullable\\.$#', 'count' => 1, diff --git a/core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php b/core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php index 5c1079b9e0c..f95108a9315 100644 --- a/core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php +++ b/core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php @@ -37,7 +37,6 @@ trait DoTrustedCallbackTrait { * @param string $error_type * (optional) The type of error to trigger. One of: * - TrustedCallbackInterface::THROW_EXCEPTION - * - TrustedCallbackInterface::TRIGGER_WARNING * - TrustedCallbackInterface::TRIGGER_SILENCED_DEPRECATION * Defaults to TrustedCallbackInterface::THROW_EXCEPTION. * @param string $extra_trusted_interface @@ -99,9 +98,6 @@ trait DoTrustedCallbackTrait { if ($error_type === TrustedCallbackInterface::TRIGGER_SILENCED_DEPRECATION) { @trigger_error($message, E_USER_DEPRECATED); } - elseif ($error_type === TrustedCallbackInterface::TRIGGER_WARNING) { - trigger_error($message, E_USER_WARNING); - } else { throw new UntrustedCallbackException($message); } diff --git a/core/lib/Drupal/Core/Security/StaticTrustedCallbackHelper.php b/core/lib/Drupal/Core/Security/StaticTrustedCallbackHelper.php index f406c7a278d..0e31a933ed4 100644 --- a/core/lib/Drupal/Core/Security/StaticTrustedCallbackHelper.php +++ b/core/lib/Drupal/Core/Security/StaticTrustedCallbackHelper.php @@ -23,7 +23,6 @@ class StaticTrustedCallbackHelper { * @param string $error_type * (optional) The type of error to trigger. One of: * - TrustedCallbackInterface::THROW_EXCEPTION - * - TrustedCallbackInterface::TRIGGER_WARNING * - TrustedCallbackInterface::TRIGGER_SILENCED_DEPRECATION * Defaults to TrustedCallbackInterface::THROW_EXCEPTION. * @param string $extra_trusted_interface diff --git a/core/lib/Drupal/Core/Security/TrustedCallbackInterface.php b/core/lib/Drupal/Core/Security/TrustedCallbackInterface.php index 78f6bb93439..e4fd28382ea 100644 --- a/core/lib/Drupal/Core/Security/TrustedCallbackInterface.php +++ b/core/lib/Drupal/Core/Security/TrustedCallbackInterface.php @@ -14,11 +14,6 @@ interface TrustedCallbackInterface { */ const THROW_EXCEPTION = 'exception'; - /** - * Untrusted callbacks trigger E_USER_WARNING errors. - */ - const TRIGGER_WARNING = 'warning'; - /** * Untrusted callbacks trigger silenced E_USER_DEPRECATION errors. */ diff --git a/core/tests/Drupal/Tests/Core/Security/DoTrustedCallbackTraitTest.php b/core/tests/Drupal/Tests/Core/Security/DoTrustedCallbackTraitTest.php index a97a5b6ab68..60b454ac5ff 100644 --- a/core/tests/Drupal/Tests/Core/Security/DoTrustedCallbackTraitTest.php +++ b/core/tests/Drupal/Tests/Core/Security/DoTrustedCallbackTraitTest.php @@ -87,15 +87,6 @@ class DoTrustedCallbackTraitTest extends UnitTestCase { $this->doTrustedCallback($callback, [], '%s is not trusted', TrustedCallbackInterface::TRIGGER_SILENCED_DEPRECATION); } - /** - * @dataProvider errorTypeProvider - */ - public function testWarning($callback) { - $this->expectWarning(); - $this->expectWarningMessage('Drupal\Tests\Core\Security\UntrustedObject::callback is not trusted'); - $this->doTrustedCallback($callback, [], '%s is not trusted', TrustedCallbackInterface::TRIGGER_WARNING); - } - /** * Data provider for tests of ::doTrustedCallback $error_type argument. */