You are here

public function LocaleConfigManagerTest::testGetStringTranslation in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/locale/src/Tests/LocaleConfigManagerTest.php \Drupal\locale\Tests\LocaleConfigManagerTest::testGetStringTranslation()

Tests getStringTranslation().

File

core/modules/locale/src/Tests/LocaleConfigManagerTest.php, line 47
Contains \Drupal\locale\Tests\LocaleConfigManagerTest.

Class

LocaleConfigManagerTest
Tests that the locale config manager operates correctly.

Namespace

Drupal\locale\Tests

Code

public function testGetStringTranslation() {
  $this
    ->installSchema('locale', array(
    'locales_location',
    'locales_source',
    'locales_target',
  ));
  $this
    ->installConfig(array(
    'locale_test',
  ));
  $locale_config_manager = \Drupal::service('locale.config_manager');
  $language = ConfigurableLanguage::createFromLangcode('de');
  $language
    ->save();
  $translation_before = $locale_config_manager
    ->getStringTranslation('locale_test.no_translation', $language
    ->getId(), 'Test', '');
  $this
    ->assertTrue($translation_before
    ->isNew());
  $translation_before
    ->setString('translation')
    ->save();
  $translation_after = $locale_config_manager
    ->getStringTranslation('locale_test.no_translation', $language
    ->getId(), 'Test', '');
  $this
    ->assertFalse($translation_after
    ->isNew());
  $translation_after
    ->setString('updated_translation')
    ->save();
}