diff --git a/core/modules/locale/src/Tests/LocaleConfigSubscriberTest.php b/core/modules/locale/src/Tests/LocaleConfigSubscriberTest.php index c5063bd..d95458c 100644 --- a/core/modules/locale/src/Tests/LocaleConfigSubscriberTest.php +++ b/core/modules/locale/src/Tests/LocaleConfigSubscriberTest.php @@ -74,6 +74,10 @@ protected function setUp() { $this->installConfig(['locale_test']); ConfigurableLanguage::createFromLangcode($this->langcode)->save(); + + // Set up the locale database the same way we have in the config samples. + $this->setUpNoTranslation('locale_test.no_translation', 'test', 'Test'); + $this->setUpTranslation('locale_test.translation', 'test', 'English test', 'German test'); } /** @@ -82,7 +86,6 @@ protected function setUp() { public function testCreateTranslation() { $config_name = 'locale_test.no_translation'; - $this->setUpNoTranslation($config_name, 'test', 'Test'); $this->saveLanguageOverride($config_name, 'test', 'Test (German)'); $this->assertTranslation($config_name, 'Test (German)'); } @@ -93,7 +96,6 @@ public function testCreateTranslation() { public function testLocaleCreateTranslation() { $config_name = 'locale_test.no_translation'; - $this->setUpNoTranslation($config_name, 'test', 'Test'); $this->saveLocaleTranslationData($config_name, 'test', 'Test', 'Test (German)'); $this->assertTranslation($config_name, 'Test (German)', FALSE); } @@ -104,7 +106,6 @@ public function testLocaleCreateTranslation() { public function testUpdateTranslation() { $config_name = 'locale_test.translation'; - $this->setUpTranslation($config_name, 'test', 'English test', 'German test'); $this->saveLanguageOverride($config_name, 'test', 'Updated German test'); $this->assertTranslation($config_name, 'Updated German test'); } @@ -115,7 +116,6 @@ public function testUpdateTranslation() { public function testLocaleUpdateTranslation() { $config_name = 'locale_test.translation'; - $this->setUpTranslation($config_name, 'test', 'English test', 'German test'); $this->saveLocaleTranslationData($config_name, 'test', 'English test', 'Updated German test'); $this->assertTranslation($config_name, 'Updated German test', FALSE); } @@ -126,7 +126,6 @@ public function testLocaleUpdateTranslation() { public function testDeleteTranslation() { $config_name = 'locale_test.translation'; - $this->setUpTranslation($config_name, 'test', 'English test', 'German test'); $this->deleteLanguageOverride($config_name, 'test', 'English test'); // Instead of deleting the translation, we need to keep a translation with // the source value and mark it as customized to prevent the deletion being @@ -140,7 +139,6 @@ public function testDeleteTranslation() { public function testLocaleDeleteTranslation() { $config_name = 'locale_test.translation'; - $this->setUpTranslation($config_name, 'test', 'English test', 'German test'); $this->deleteLocaleTranslationData($config_name, 'test', 'English test'); $this->assertNoTranslation($config_name); } @@ -161,9 +159,7 @@ public function testLocaleDeleteTranslation() { * The source string. */ protected function setUpNoTranslation($config_name, $key, $source) { - // Add a source string with the configuration name as a location. This gets - // called from LocaleConfigManager::updateConfigTranslations() normally. - $this->localeConfigManager->translateString($config_name, $this->langcode, $source, ''); + $this->localeConfigManager->updateConfigTranslations(array($config_name), array($this->langcode)); $this->languageManager ->setConfigOverrideLanguage(ConfigurableLanguage::load($this->langcode)); @@ -198,12 +194,13 @@ protected function setUpTranslation($config_name, $key, $source, $translation) { $this->localeConfigManager ->getStringTranslation($config_name, $this->langcode, $source, '') ->setString($translation) + ->setCustomized(FALSE) ->save(); $this->languageManager ->setConfigOverrideLanguage(ConfigurableLanguage::load($this->langcode)); $this->assertConfigValue($config_name, $key, $translation); - $this->assertTranslation($config_name, $translation, TRUE); + $this->assertTranslation($config_name, $translation, FALSE); } /** @@ -254,8 +251,8 @@ protected function saveLocaleTranslationData($config_name, $key, $source, $trans ->getStringTranslation($config_name, $this->langcode, $source, '') ->setString($translation) ->save(); - $this->localeConfigManager - ->saveTranslationOverride($config_name, $this->langcode, [$key => $translation]); + $this->localeConfigManager->reset(); + $this->localeConfigManager->updateConfigTranslations(array($config_name), array($this->langcode)); $this->configFactory->reset($config_name); $this->assertConfigValue($config_name, $key, $translation); @@ -310,7 +307,8 @@ protected function deleteLocaleTranslationData($config_name, $key, $source_value $this->localeConfigManager ->getStringTranslation($config_name, $this->langcode, $source_value, '') ->delete(); - $this->localeConfigManager->deleteTranslationOverride($config_name, $this->langcode); + $this->localeConfigManager->reset(); + $this->localeConfigManager->updateConfigTranslations(array($config_name), array($this->langcode)); $this->configFactory->reset($config_name); $this->assertConfigValue($config_name, $key, $source_value);