Issue #2618040 by Maouna, plach, catch, YesCT, steelsector, matsbla, SiliconMind, vodde83: Configuration of configurable language types reset after module install
parent
8b1db1954d
commit
043fb23885
|
@ -311,8 +311,13 @@ function language_negotiation_url_domains() {
|
|||
*/
|
||||
function language_modules_installed($modules) {
|
||||
if (!in_array('language', $modules)) {
|
||||
// Since newly (un)installed modules may change the default settings for
|
||||
// non-locked language types (e.g. content language), we need to resave the
|
||||
// language type configuration.
|
||||
/** @var \Drupal\language\LanguageNegotiatorInterface $negotiator */
|
||||
$negotiator = \Drupal::service('language_negotiator');
|
||||
$negotiator->updateConfiguration(array());
|
||||
$configurable = \Drupal::config('language.types')->get('configurable');
|
||||
$negotiator->updateConfiguration($configurable);
|
||||
$negotiator->purgeConfiguration();
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -23,14 +23,14 @@ class LanguageNegotiationInfoTest extends WebTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('language');
|
||||
public static $modules = ['language', 'content_translation'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$admin_user = $this->drupalCreateUser(array('administer languages', 'access administration pages', 'view the administration theme'));
|
||||
$admin_user = $this->drupalCreateUser(['administer languages', 'access administration pages', 'view the administration theme', 'administer modules']);
|
||||
$this->drupalLogin($admin_user);
|
||||
$this->drupalPostForm('admin/config/regional/language/add', array('predefined_langcode' => 'it'), t('Add language'));
|
||||
}
|
||||
|
@ -174,4 +174,41 @@ class LanguageNegotiationInfoTest extends WebTestBase {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests altering config of configurable language types.
|
||||
*/
|
||||
public function testConfigLangTypeAlterations() {
|
||||
// Default of config.
|
||||
$test_type = LanguageInterface::TYPE_CONTENT;
|
||||
$this->assertFalse($this->isLanguageTypeConfigurable($test_type), 'Language type is not configurable.');
|
||||
|
||||
// Editing config.
|
||||
$edit = [$test_type . '[configurable]' => TRUE];
|
||||
$this->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings'));
|
||||
$this->assertTrue($this->isLanguageTypeConfigurable($test_type), 'Language type is now configurable.');
|
||||
|
||||
// After installing another module, the config should be the same.
|
||||
$this->drupalPostForm('admin/modules', ['modules[Testing][test_module][enable]' => 1], t('Install'));
|
||||
$this->assertTrue($this->isLanguageTypeConfigurable($test_type), 'Language type is still configurable.');
|
||||
|
||||
// After uninstalling the other module, the config should be the same.
|
||||
$this->drupalPostForm('admin/modules/uninstall', ['uninstall[test_module]' => 1], t('Uninstall'));
|
||||
$this->assertTrue($this->isLanguageTypeConfigurable($test_type), 'Language type is still configurable.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the given language type is configurable.
|
||||
*
|
||||
* @param string $type
|
||||
* The language type.
|
||||
*
|
||||
* @return bool
|
||||
* TRUE if the specified language type is configurable, FALSE otherwise.
|
||||
*/
|
||||
protected function isLanguageTypeConfigurable($type) {
|
||||
$configurable_types = $this->config('language.types')->get('configurable');
|
||||
return in_array($type, $configurable_types);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
name: 'Test Module'
|
||||
type: module
|
||||
description: 'Support module for testing.'
|
||||
package: Testing
|
||||
version: VERSION
|
||||
core: 8.x
|
Loading…
Reference in New Issue