public function ConfigTranslationUiTest::testLocaleDBStorage in Drupal 9
Same name and namespace in other branches
- 8 core/modules/config_translation/tests/src/Functional/ConfigTranslationUiTest.php \Drupal\Tests\config_translation\Functional\ConfigTranslationUiTest::testLocaleDBStorage()
- 10 core/modules/config_translation/tests/src/Functional/ConfigTranslationUiTest.php \Drupal\Tests\config_translation\Functional\ConfigTranslationUiTest::testLocaleDBStorage()
Tests translation storage in locale storage.
File
- core/
modules/ config_translation/ tests/ src/ Functional/ ConfigTranslationUiTest.php, line 823
Class
- ConfigTranslationUiTest
- Translate settings and entities to various languages.
Namespace
Drupal\Tests\config_translation\FunctionalCode
public function testLocaleDBStorage() {
// Enable import of translations. By default this is disabled for automated
// tests.
$this
->config('locale.settings')
->set('translation.import_enabled', TRUE)
->set('translation.use_source', LOCALE_TRANSLATION_USE_SOURCE_LOCAL)
->save();
$this
->drupalLogin($this->adminUser);
$langcode = 'xx';
$name = $this
->randomMachineName(16);
$edit = [
'predefined_langcode' => 'custom',
'langcode' => $langcode,
'label' => $name,
'direction' => Language::DIRECTION_LTR,
];
$this
->drupalGet('admin/config/regional/language/add');
$this
->submitForm($edit, 'Add custom language');
// Make sure there is no translation stored in locale storage before edit.
$translation = $this
->getTranslation('user.settings', 'anonymous', 'fr');
$this
->assertTrue(empty($translation));
// Add custom translation.
$edit = [
'translation[config_names][user.settings][anonymous]' => 'Anonyme',
];
$this
->drupalGet('admin/config/people/accounts/translate/fr/add');
$this
->submitForm($edit, 'Save translation');
// Make sure translation stored in locale storage after saved language
// specific configuration translation.
$translation = $this
->getTranslation('user.settings', 'anonymous', 'fr');
$this
->assertEquals('Anonyme', $translation
->getString());
// revert custom translations to base translation.
$edit = [
'translation[config_names][user.settings][anonymous]' => 'Anonymous',
];
$this
->drupalGet('admin/config/people/accounts/translate/fr/edit');
$this
->submitForm($edit, 'Save translation');
// Make sure there is no translation stored in locale storage after revert.
$translation = $this
->getTranslation('user.settings', 'anonymous', 'fr');
$this
->assertEquals('Anonymous', $translation
->getString());
}