From 3a4f6f2979bbc84c567bbffc5dbeb9b76889bf3e Mon Sep 17 00:00:00 2001 From: webchick <drupal@webchick.net> Date: Tue, 29 Aug 2017 12:33:43 -0700 Subject: [PATCH] Issue #2901692 by tim.plunkett, xjm, Cottser, dawehner, EclipseGc: FieldDefinitionIntegrityTest does not respect module dependencies --- .../src/Kernel/FieldDefinitionIntegrityTest.php | 13 ++++++++++--- core/tests/Drupal/KernelTests/KernelTestBase.php | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/core/modules/field/tests/src/Kernel/FieldDefinitionIntegrityTest.php b/core/modules/field/tests/src/Kernel/FieldDefinitionIntegrityTest.php index b4add538ee0e..85d6b0bfc47a 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 6a35f15373af..7c272f0f3ec3 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. -- GitLab