function LocaleConfigTranslationImportTest::testLocaleRemovalAndConfigOverrideDelete in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/locale/src/Tests/LocaleConfigTranslationImportTest.php \Drupal\locale\Tests\LocaleConfigTranslationImportTest::testLocaleRemovalAndConfigOverrideDelete()
Test removing a string from Locale deletes configuration translations.
File
- core/
modules/ locale/ src/ Tests/ LocaleConfigTranslationImportTest.php, line 138 - Contains \Drupal\locale\Tests\LocaleConfigTranslationImportTest.
Class
- LocaleConfigTranslationImportTest
- Tests translation update's effects on configuration translations.
Namespace
Drupal\locale\TestsCode
function testLocaleRemovalAndConfigOverrideDelete() {
// 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');
$this
->assertEqual([
'translatable_default_with_translation' => 'Locale can translate Afrikaans',
], $override
->get());
// Remove the string from translation to simulate a Locale removal. Note
// that is no current way of doing this in the UI.
$locale_storage = \Drupal::service('locale.storage');
$string = $locale_storage
->findString(array(
'source' => 'Locale can translate',
));
\Drupal::service('locale.storage')
->delete($string);
// Force a rebuild of config translations.
$count = Locale::config()
->updateConfigTranslations([
'locale_test_translate.settings',
], [
'af',
]);
$this
->assertEqual($count, 1, 'Correct count of updated translations');
$override = \Drupal::languageManager()
->getLanguageConfigOverride('af', 'locale_test_translate.settings');
$this
->assertEqual([], $override
->get());
$this
->assertTrue($override
->isNew(), 'The configuration override was deleted when the Locale string was deleted.');
}