function LocaleConfigManagerTest::testHasTranslation

Same name in other branches
  1. 9 core/modules/locale/tests/src/Kernel/LocaleConfigManagerTest.php \Drupal\Tests\locale\Kernel\LocaleConfigManagerTest::testHasTranslation()
  2. 8.9.x core/modules/locale/tests/src/Kernel/LocaleConfigManagerTest.php \Drupal\Tests\locale\Kernel\LocaleConfigManagerTest::testHasTranslation()
  3. 11.x core/modules/locale/tests/src/Kernel/LocaleConfigManagerTest.php \Drupal\Tests\locale\Kernel\LocaleConfigManagerTest::testHasTranslation()

Tests hasTranslation().

File

core/modules/locale/tests/src/Kernel/LocaleConfigManagerTest.php, line 41

Class

LocaleConfigManagerTest
Tests that the locale config manager operates correctly.

Namespace

Drupal\Tests\locale\Kernel

Code

public function testHasTranslation() : void {
    $this->installSchema('locale', [
        'locales_location',
        'locales_source',
        'locales_target',
    ]);
    $this->installConfig([
        '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.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.