From 29bebc73d73014020a3f5729ba9246d6f0c7fb6f Mon Sep 17 00:00:00 2001
From: catch <catch@35733.no-reply.drupal.org>
Date: Wed, 10 Apr 2024 09:41:04 +0100
Subject: [PATCH] Issue #3427172 by mondrake, longwave: Replace calls to
 ::expectWarning*() from Drupal\KernelTests\Core\Config\ConfigInstallTest

---
 core/.phpstan-baseline.php                           | 12 ------------
 core/lib/Drupal/Core/Config/ConfigInstaller.php      |  2 +-
 .../KernelTests/Core/Config/ConfigInstallTest.php    |  4 ++--
 3 files changed, 3 insertions(+), 15 deletions(-)

diff --git a/core/.phpstan-baseline.php b/core/.phpstan-baseline.php
index 49fe93ec66f3..ce5472a1b88f 100644
--- a/core/.phpstan-baseline.php
+++ b/core/.phpstan-baseline.php
@@ -2030,18 +2030,6 @@
 	'count' => 1,
 	'path' => __DIR__ . '/tests/Drupal/KernelTests/Core/Cache/ApcuBackendTest.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/KernelTests/Core/Config/ConfigInstallTest.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/KernelTests/Core/Config/ConfigInstallTest.php',
-];
 $ignoreErrors[] = [
 	'message' => '#^Variable \\$expected_driver might not be defined\\.$#',
 	'count' => 2,
diff --git a/core/lib/Drupal/Core/Config/ConfigInstaller.php b/core/lib/Drupal/Core/Config/ConfigInstaller.php
index ec94fb331c75..665c4ff2d58f 100644
--- a/core/lib/Drupal/Core/Config/ConfigInstaller.php
+++ b/core/lib/Drupal/Core/Config/ConfigInstaller.php
@@ -388,7 +388,7 @@ protected function createConfiguration($collection, array $config_to_create) {
         if ($entity->isInstallable()) {
           $entity->trustData()->save();
           if ($id !== $entity->id()) {
-            trigger_error(sprintf('The configuration name "%s" does not match the ID "%s"', $name, $entity->id()), E_USER_WARNING);
+            throw new \LogicException(sprintf('The configuration name "%s" does not match the ID "%s"', $name, $entity->id()));
           }
         }
       }
diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigInstallTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigInstallTest.php
index 4655ae374ea0..63d2bc861832 100644
--- a/core/tests/Drupal/KernelTests/Core/Config/ConfigInstallTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigInstallTest.php
@@ -263,8 +263,8 @@ public function testLanguage() {
    * Tests installing configuration where the filename and ID do not match.
    */
   public function testIdMisMatch() {
-    $this->expectWarning();
-    $this->expectWarningMessage('The configuration name "config_test.dynamic.no_id_match" does not match the ID "does_not_match"');
+    $this->expectException(\LogicException::class);
+    $this->expectExceptionMessage('The configuration name "config_test.dynamic.no_id_match" does not match the ID "does_not_match"');
     $this->installModules(['config_test_id_mismatch']);
   }
 
-- 
GitLab