Commit 8a016678 authored by catch's avatar catch

Issue #2679008 by webflo, stBorchert, clemens.tolboom, gilesmc, dawehner:...

Issue #2679008 by webflo, stBorchert, clemens.tolboom, gilesmc, dawehner: Module weight is not taken into account after module installation
parent 31a3fe83
......@@ -136,6 +136,10 @@ public function install(array $module_list, $enable_dependencies = TRUE) {
throw new ExtensionNameLengthException("Module name '$module' is over the maximum allowed length of " . DRUPAL_EXTENSION_NAME_MAX_LENGTH . ' characters');
}
// Load a new config object for each iteration, otherwise changes made
// in hook_install() are not reflected in $extension_config.
$extension_config = \Drupal::configFactory()->getEditable('core.extension');
// Check the validity of the default configuration. This will throw
// exceptions if the configuration is not valid.
$config_installer->checkConfigurationToInstall('module', $module);
......
<?php
/**
* @file
* Install, update and uninstall functions for the module_handler_test_multiple module.
*/
/**
* Implements hook_install().
*/
function module_handler_test_multiple_install() {
// Set weight of module.
module_set_weight('module_handler_test_multiple', 1);
}
......@@ -5,3 +5,5 @@ package: Testing
version: VERSION
core: 8.x
hidden: true
dependencies:
- module_handler_test_multiple
<?php
/**
* @file
* Utility functions for the module_handler_test_multiple_child module.
*
* Install, update and uninstall functions for the
* module_handler_test_multiple_child module.
*/
/**
* Implements hook_install().
*/
function module_handler_test_multiple_child_install() {
// Set weight of module.
module_set_weight('module_handler_test_multiple_child', 1);
}
......@@ -44,4 +44,20 @@ public function testRouteRebuild() {
$this->container->get('router.route_provider')->getRouteByName('router_test.1');
}
/**
* Tests config changes by hook_install() are saved for dependent modules.
*
* @covers ::install
*/
public function testConfigChangeOnInstall() {
// Install the child module so the parent is installed automatically.
$this->container->get('module_installer')->install(['module_handler_test_multiple_child']);
$modules = $this->config('core.extension')->get('module');
$this->assertArrayHasKey('module_handler_test_multiple', $modules, 'Module module_handler_test_multiple is installed');
$this->assertArrayHasKey('module_handler_test_multiple_child', $modules, 'Module module_handler_test_multiple_child is installed');
$this->assertEquals(1, $modules['module_handler_test_multiple'], 'Weight of module_handler_test_multiple is set.');
$this->assertEquals(1, $modules['module_handler_test_multiple_child'], 'Weight of module_handler_test_multiple_child is set.');
}
}
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