Commit 53ef54c6 authored by alexpott's avatar alexpott

Issue #1986090 by markpavlitski, jessebeach: Profile config does not overwrite...

Issue #1986090 by markpavlitski, jessebeach: Profile config does not overwrite module default config on install (system.cron.yml).
parent d0518561
......@@ -63,6 +63,15 @@ protected function getAllFolders() {
if (isset($themes['enabled'])) {
$this->folders += $this->getComponentNames('theme', array_keys($themes['enabled']));
}
// The install profile can override module default configuration. We do
// this by replacing the config file path from the module/theme with the
// install profile version if there are any duplicates.
$profile_folders = $this->getComponentNames('profile', array(drupal_get_profile()));
$folders_to_replace = array_intersect_key($profile_folders, $this->folders);
if (!empty($folders_to_replace)) {
$this->folders = array_merge($this->folders, $folders_to_replace);
}
}
return $this->folders;
}
......
......@@ -8,6 +8,7 @@
namespace Drupal\config\Tests;
use Drupal\simpletest\WebTestBase;
use Drupal\Core\Config\FileStorage;
/**
* Tests installation of configuration objects in installation functionality.
......@@ -96,4 +97,56 @@ function testIntegrationModuleReinstallation() {
$this->assertIdentical($config_entity->get('label'), 'Customized integration config label');
}
/**
* Tests install profile config changes.
*/
function testInstallProfileConfigOverwrite() {
$config_name = 'system.cron';
// The expected configuration from the system module.
$expected_original_data = array(
'threshold' => array(
'autorun' => 0,
'requirements_warning' => 172800,
'requirements_error' => 1209600,
),
);
// The expected active configuration altered by the install profile.
$expected_profile_data = array(
'threshold' => array(
'autorun' => 0,
'requirements_warning' => 259200,
'requirements_error' => 1209600,
),
);
// Verify that the original data matches. We have to read the module config
// file directly, because the install profile default system.cron.yml
// configuration file was used to create the active configuration.
$config_dir = drupal_get_path('module', 'system') . '/config';
$this->assertTrue(is_dir($config_dir));
$source_storage = new FileStorage($config_dir);
$data = $source_storage->read($config_name);
$this->assertIdentical($data, $expected_original_data);
// Verify that active configuration matches the expected data, which was
// created from the testing install profile's system.cron.yml file.
$config = \Drupal::config($config_name);
$this->assertIdentical($config->get(), $expected_profile_data);
// Turn on the test module, which will attempt to replace the
// configuration data. This attempt to replace the active configuration
// should be ignored.
\Drupal::moduleHandler()->install(array('config_override_test'));
// Verify that the test module has not been able to change the data.
$config = \Drupal::config($config_name);
$this->assertIdentical($config->get(), $expected_profile_data);
// Disable and uninstall the test module.
\Drupal::moduleHandler()->uninstall(array('config_override_test'));
// Verify that the data hasn't been altered by removing the test module.
$config = \Drupal::config($config_name);
$this->assertIdentical($config->get(), $expected_profile_data);
}
}
threshold:
autorun: 0
requirements_warning: 172800
requirements_error: 1209600
<?php
/**
* @file
* Test module containing a configuration file which matches another module.
*/
name: 'Configuration override test'
type: module
package: Testing
version: VERSION
core: 8.x
hidden: true
threshold:
autorun: 0
requirements_warning: 259200
requirements_error: 1209600
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