You are here

public function LocaleConfigManagerTest::testHasTranslation in Zircon Profile 8.0

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

Tests hasTranslation().

File

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

Class

LocaleConfigManagerTest
Tests that the locale config manager operates correctly.

Namespace

Drupal\locale\Tests

Code

public function testHasTranslation() {
  $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();
  $result = $locale_config_manager
    ->hasTranslation('locale_test.no_translation', $language
    ->getId());
  $this
    ->assertFalse($result, 'There is no translation for locale_test.no_translation configuration.');
  $result = $locale_config_manager
    ->hasTranslation('locale_test.translation', $language
    ->getId());
  $this
    ->assertTrue($result, 'There is a translation for locale_test.translation configuration.');
}