diff --git a/core/modules/field/tests/src/Kernel/FieldDefinitionIntegrityTest.php b/core/modules/field/tests/src/Kernel/FieldDefinitionIntegrityTest.php index b4add538ee0e0f6cb54c0b72750d0b3bf6c32344..85d6b0bfc47a9f1f2cb3d55ce79fdc8f4565eb26 100644 --- a/core/modules/field/tests/src/Kernel/FieldDefinitionIntegrityTest.php +++ b/core/modules/field/tests/src/Kernel/FieldDefinitionIntegrityTest.php @@ -2,6 +2,7 @@ namespace Drupal\Tests\field\Kernel; +use Drupal\Component\Utility\NestedArray; use Drupal\Core\Extension\Extension; use Drupal\KernelTests\KernelTestBase; @@ -21,8 +22,8 @@ class FieldDefinitionIntegrityTest extends KernelTestBase { * Tests the integrity of field plugin definitions. */ public function testFieldPluginDefinitionIntegrity() { - - // Enable all core modules that provide field plugins. + // Enable all core modules that provide field plugins, and their + // dependencies. $modules = system_rebuild_module_data(); $modules = array_filter($modules, function (Extension $module) { // Filter contrib, hidden, already enabled modules and modules in the @@ -36,7 +37,13 @@ public function testFieldPluginDefinitionIntegrity() { } return FALSE; }); - $this->enableModules(array_keys($modules)); + // Gather the dependencies of the modules. + $dependencies = NestedArray::mergeDeepArray(array_map(function (Extension $module) { + return array_keys($module->requires); + }, $modules)); + $modules = array_unique(NestedArray::mergeDeep(array_keys($modules), $dependencies)); + + $this->enableModules($modules); /** @var \Drupal\Component\Plugin\Discovery\DiscoveryInterface $field_type_manager */ $field_type_manager = \Drupal::service('plugin.manager.field.field_type'); diff --git a/core/tests/Drupal/KernelTests/KernelTestBase.php b/core/tests/Drupal/KernelTests/KernelTestBase.php index 6a35f15373af2fc0619e640d5101acda629945b6..7c272f0f3ec3f5a69ed5fc5437859e0bb035000c 100644 --- a/core/tests/Drupal/KernelTests/KernelTestBase.php +++ b/core/tests/Drupal/KernelTests/KernelTestBase.php @@ -814,7 +814,7 @@ protected function enableModules(array $modules) { foreach ($modules as $module) { if ($module_handler->moduleExists($module)) { - throw new \LogicException("$module module is already enabled."); + continue; } $module_handler->addModule($module, $module_list[$module]->getPath()); // Maintain the list of enabled modules in configuration.