Commit 3a4f6f29 authored by webchick's avatar webchick

Issue #2901692 by tim.plunkett, xjm, Cottser, dawehner, EclipseGc:...

Issue #2901692 by tim.plunkett, xjm, Cottser, dawehner, EclipseGc: FieldDefinitionIntegrityTest does not respect module dependencies
parent c8daa8d2
......@@ -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');
......
......@@ -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.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment