You are here

public function LanguageSelectorTranslatableTest::testLanguageStringSelector in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/language/tests/src/Functional/LanguageSelectorTranslatableTest.php \Drupal\Tests\language\Functional\LanguageSelectorTranslatableTest::testLanguageStringSelector()
  2. 9 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 70

Class

LanguageSelectorTranslatableTest
Tests the content translation settings language selector options.

Namespace

Drupal\Tests\language\Functional

Code

public function testLanguageStringSelector() {

  // Add another language.
  $edit = [
    'predefined_langcode' => 'es',
  ];
  $this
    ->drupalGet('admin/config/regional/language/add');
  $this
    ->submitForm($edit, 'Add language');

  // 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());
}