From af2bc2f58e92262a7d03110f3d84306e8413e06b Mon Sep 17 00:00:00 2001 From: catch Date: Mon, 20 Dec 2021 17:40:41 +0000 Subject: [PATCH] Issue #3245383 by Beakerboy, daffie: If the database driver is provided by a module, it's name must be included in tests which check for enabled modules --- .../Kernel/Extension/ModuleHandlerTest.php | 6 +++++- ...solvedLibraryDefinitionsFilesMatchTest.php | 4 ++++ .../Core/Common/DrupalFlushAllCachesTest.php | 19 +++++++++++++++++-- .../Core/Theme/Stable9LibraryOverrideTest.php | 4 ++++ .../Core/Theme/StableLibraryOverrideTest.php | 4 ++++ 5 files changed, 34 insertions(+), 3 deletions(-) diff --git a/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php b/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php index 8ca75e10658..f672a4c7cc2 100644 --- a/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php +++ b/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php @@ -26,7 +26,11 @@ class ModuleHandlerTest extends KernelTestBase { */ public function testModuleList() { $module_list = ['system']; - + $database_module = \Drupal::database()->getProvider(); + if ($database_module !== 'core') { + $module_list[] = $database_module; + } + sort($module_list); $this->assertModuleList($module_list, 'Initial'); // Try to install a new module. diff --git a/core/tests/Drupal/KernelTests/Core/Asset/ResolvedLibraryDefinitionsFilesMatchTest.php b/core/tests/Drupal/KernelTests/Core/Asset/ResolvedLibraryDefinitionsFilesMatchTest.php index 32040acaccb..1626e5b219d 100644 --- a/core/tests/Drupal/KernelTests/Core/Asset/ResolvedLibraryDefinitionsFilesMatchTest.php +++ b/core/tests/Drupal/KernelTests/Core/Asset/ResolvedLibraryDefinitionsFilesMatchTest.php @@ -125,6 +125,10 @@ class ResolvedLibraryDefinitionsFilesMatchTest extends KernelTestBase { $this->allModules[] = 'system'; $this->allModules[] = 'user'; $this->allModules[] = 'path_alias'; + $database_module = \Drupal::database()->getProvider(); + if ($database_module !== 'core') { + $this->allModules[] = $database_module; + } sort($this->allModules); $this->container->get('module_installer')->install($this->allModules); diff --git a/core/tests/Drupal/KernelTests/Core/Common/DrupalFlushAllCachesTest.php b/core/tests/Drupal/KernelTests/Core/Common/DrupalFlushAllCachesTest.php index 9cb1dc2defc..6d699cb26ed 100644 --- a/core/tests/Drupal/KernelTests/Core/Common/DrupalFlushAllCachesTest.php +++ b/core/tests/Drupal/KernelTests/Core/Common/DrupalFlushAllCachesTest.php @@ -34,14 +34,29 @@ class DrupalFlushAllCachesTest extends KernelTestBase { $core_extension->set('module', module_config_sort($module))->save(); $this->containerBuilds = 0; drupal_flush_all_caches(); - $this->assertSame(['system_test', 'system'], array_keys($this->container->getParameter('container.modules'))); + $module_list = ['system_test', 'system']; + $database_module = \Drupal::database()->getProvider(); + if ($database_module !== 'core') { + $module_list[] = $database_module; + } + sort($module_list); + $container_modules = array_keys($this->container->getParameter('container.modules')); + sort($container_modules); + $this->assertSame($module_list, $container_modules); $this->assertSame(1, $this->containerBuilds); $this->assertTrue(function_exists('system_test_help')); $core_extension->clear('module.system_test')->save(); $this->containerBuilds = 0; drupal_flush_all_caches(); - $this->assertSame(['system'], array_keys($this->container->getParameter('container.modules'))); + $module_list = ['system']; + if ($database_module !== 'core') { + $module_list[] = $database_module; + } + sort($module_list); + $container_modules = array_keys($this->container->getParameter('container.modules')); + sort($container_modules); + $this->assertSame($module_list, $container_modules); $this->assertSame(1, $this->containerBuilds); } diff --git a/core/tests/Drupal/KernelTests/Core/Theme/Stable9LibraryOverrideTest.php b/core/tests/Drupal/KernelTests/Core/Theme/Stable9LibraryOverrideTest.php index 251612a401d..04521c0df9c 100644 --- a/core/tests/Drupal/KernelTests/Core/Theme/Stable9LibraryOverrideTest.php +++ b/core/tests/Drupal/KernelTests/Core/Theme/Stable9LibraryOverrideTest.php @@ -74,6 +74,10 @@ class Stable9LibraryOverrideTest extends KernelTestBase { $this->allModules[] = 'system'; $this->allModules[] = 'user'; $this->allModules[] = 'path_alias'; + $database_module = \Drupal::database()->getProvider(); + if ($database_module !== 'core') { + $this->allModules[] = $database_module; + } sort($this->allModules); $this->container->get('module_installer')->install($this->allModules); diff --git a/core/tests/Drupal/KernelTests/Core/Theme/StableLibraryOverrideTest.php b/core/tests/Drupal/KernelTests/Core/Theme/StableLibraryOverrideTest.php index b2baf2beab9..38cf0759763 100644 --- a/core/tests/Drupal/KernelTests/Core/Theme/StableLibraryOverrideTest.php +++ b/core/tests/Drupal/KernelTests/Core/Theme/StableLibraryOverrideTest.php @@ -74,6 +74,10 @@ class StableLibraryOverrideTest extends KernelTestBase { $this->allModules[] = 'system'; $this->allModules[] = 'user'; $this->allModules[] = 'path_alias'; + $database_module = \Drupal::database()->getProvider(); + if ($database_module !== 'core') { + $this->allModules[] = $database_module; + } sort($this->allModules); $this->container->get('module_installer')->install($this->allModules);