public function LocaleConfigManagerTest::testHasTranslation in Drupal 8
Same name and namespace in other branches
- 9 core/modules/locale/tests/src/Kernel/LocaleConfigManagerTest.php \Drupal\Tests\locale\Kernel\LocaleConfigManagerTest::testHasTranslation()
- 10 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 39
Class
- LocaleConfigManagerTest
- Tests that the locale config manager operates correctly.
Namespace
Drupal\Tests\locale\KernelCode
public function testHasTranslation() {
$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.');
}