You are here

public function LanguageSelectorTranslatableTest::testLanguageStringSelector in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/language/src/Tests/LanguageSelectorTranslatableTest.php \Drupal\language\Tests\LanguageSelectorTranslatableTest::testLanguageStringSelector()

Tests content translation language selectors are correctly translated.

File

core/modules/language/src/Tests/LanguageSelectorTranslatableTest.php, line 70
Contains \Drupal\language\Tests\LanguageSelectorTranslatableTest.

Class

LanguageSelectorTranslatableTest
Tests the content translation settings language selector options.

Namespace

Drupal\language\Tests

Code

public function testLanguageStringSelector() {

  // Add another language.
  $edit = array(
    'predefined_langcode' => 'es',
  );
  $this
    ->drupalPostForm('admin/config/regional/language/add', $edit, t('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.
  $elements = $this
    ->xpath('//select[@id=:id]//option[@value=:option]', array(
    ':id' => 'edit-settings-user-user-settings-language-langcode',
    ':option' => 'en',
  ));

  // Check that the language text is translated.
  $this
    ->assertEqual((string) $elements[0], $name_translation, 'Checking the option string English is translated to Spanish.');
}