function LocaleConfigTranslationImportTest::testLocaleRemovalAndConfigOverridePreserve in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/modules/locale/src/Tests/LocaleConfigTranslationImportTest.php \Drupal\locale\Tests\LocaleConfigTranslationImportTest::testLocaleRemovalAndConfigOverridePreserve()
Test removing a string from Locale changes configuration translations.
File
- core/
modules/ locale/ src/ Tests/ LocaleConfigTranslationImportTest.php, line 175 - Contains \Drupal\locale\Tests\LocaleConfigTranslationImportTest.
Class
- LocaleConfigTranslationImportTest
- Tests translation update's effects on configuration translations.
Namespace
Drupal\locale\TestsCode
function testLocaleRemovalAndConfigOverridePreserve() {
// Enable the locale module.
$this->container
->get('module_installer')
->install([
'locale',
]);
$this
->resetAll();
$admin_user = $this
->drupalCreateUser(array(
'administer modules',
'administer site configuration',
'administer languages',
'access administration pages',
'administer permissions',
'translate interface',
));
$this
->drupalLogin($admin_user);
// Enable import of translations. By default this is disabled for automated
// tests.
$this
->config('locale.settings')
->set('translation.import_enabled', TRUE)
->save();
// Add predefined language.
$this
->drupalPostForm('admin/config/regional/language/add', [
'predefined_langcode' => 'af',
], t('Add language'));
$override = \Drupal::languageManager()
->getLanguageConfigOverride('af', 'locale_test_translate.settings');
// Update test configuration.
$override
->set('translatable_no_default', 'This translation is preserved')
->set('translatable_default_with_no_translation', 'This translation is preserved')
->save();
$expected = [
'translatable_default_with_translation' => 'Locale can translate Afrikaans',
'translatable_no_default' => 'This translation is preserved',
'translatable_default_with_no_translation' => 'This translation is preserved',
];
$this
->assertEqual($expected, $override
->get());
// Set the translated string to empty.
$search = array(
'string' => 'Locale can translate',
'langcode' => 'af',
'translation' => 'all',
);
$this
->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
$textareas = $this
->xpath('//textarea');
$textarea = current($textareas);
$lid = (string) $textarea[0]['name'];
$edit = array(
$lid => '',
);
$this
->drupalPostForm('admin/config/regional/translate', $edit, t('Save translations'));
$override = \Drupal::languageManager()
->getLanguageConfigOverride('af', 'locale_test_translate.settings');
$expected = [
'translatable_no_default' => 'This translation is preserved',
'translatable_default_with_no_translation' => 'This translation is preserved',
];
$this
->assertEqual($expected, $override
->get());
}