public function ConfigTranslationUiTest::testLocaleDBStorage in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php \Drupal\config_translation\Tests\ConfigTranslationUiTest::testLocaleDBStorage()
Test translation storage in locale storage.
File
- core/
modules/ config_translation/ src/ Tests/ ConfigTranslationUiTest.php, line 739 - Contains \Drupal\config_translation\Tests\ConfigTranslationUiTest.
Class
- ConfigTranslationUiTest
- Translate settings and entities to various languages.
Namespace
Drupal\config_translation\TestsCode
public function testLocaleDBStorage() {
// Enable import of translations. By default this is disabled for automated
// tests.
$this
->config('locale.settings')
->set('translation.import_enabled', TRUE)
->save();
$this
->drupalLogin($this->adminUser);
$langcode = 'xx';
$name = $this
->randomMachineName(16);
$edit = array(
'predefined_langcode' => 'custom',
'langcode' => $langcode,
'label' => $name,
'direction' => Language::DIRECTION_LTR,
);
$this
->drupalPostForm('admin/config/regional/language/add', $edit, t('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 = array(
'translation[config_names][user.settings][anonymous]' => 'Anonyme',
);
$this
->drupalPostForm('admin/config/people/accounts/translate/fr/add', $edit, t('Save translation'));
// Make sure translation stored in locale storage after saved language
// specific configuration translation.
$translation = $this
->getTranslation('user.settings', 'anonymous', 'fr');
$this
->assertEqual('Anonyme', $translation
->getString());
// revert custom translations to base translation.
$edit = array(
'translation[config_names][user.settings][anonymous]' => 'Anonymous',
);
$this
->drupalPostForm('admin/config/people/accounts/translate/fr/edit', $edit, t('Save translation'));
// Make sure there is no translation stored in locale storage after revert.
$translation = $this
->getTranslation('user.settings', 'anonymous', 'fr');
$this
->assertEqual('Anonymous', $translation
->getString());
}