function LanguageSelectorTranslatableTest::testLanguageStringSelector

Same name in other branches
  1. 9 core/modules/language/tests/src/Functional/LanguageSelectorTranslatableTest.php \Drupal\Tests\language\Functional\LanguageSelectorTranslatableTest::testLanguageStringSelector()
  2. 8.9.x core/modules/language/tests/src/Functional/LanguageSelectorTranslatableTest.php \Drupal\Tests\language\Functional\LanguageSelectorTranslatableTest::testLanguageStringSelector()
  3. 11.x core/modules/language/tests/src/Functional/LanguageSelectorTranslatableTest.php \Drupal\Tests\language\Functional\LanguageSelectorTranslatableTest::testLanguageStringSelector()

Tests content translation language selectors are correctly translated.

File

core/modules/language/tests/src/Functional/LanguageSelectorTranslatableTest.php, line 74

Class

LanguageSelectorTranslatableTest
Tests the content translation settings language selector options.

Namespace

Drupal\Tests\language\Functional

Code

public function testLanguageStringSelector() : void {
    // Add another language.
    static::createLanguageFromLangcode('es');
    // Translate the string English in Spanish (Inglés). Override config entity.
    $name_translation = 'Inglés';
    \Drupal::languageManager()->getLanguageConfigOverride('es', 'language.entity.en')
        ->set('label', $name_translation)
        ->save();
    // Check content translation overview selector.
    $path = 'es/admin/config/regional/content-language';
    $this->drupalGet($path);
    // Get en language from selector.
    $option = $this->assertSession()
        ->optionExists('edit-settings-user-user-settings-language-langcode', 'en');
    // Check that the language text is translated.
    $this->assertSame($name_translation, $option->getText());
}

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