You are here

public function LanguageSwitcherExtendedTest::testShowLangcode in Language Switcher Extended 8

Tests, to show language switcher item showing lang code instead of name.

File

tests/src/Functional/LanguageSwitcherExtendedTest.php, line 307

Class

LanguageSwitcherExtendedTest
Functional tests for the language_switcher_extended feature.

Namespace

Drupal\Tests\language_switcher_extended\Functional

Code

public function testShowLangcode() {

  // Open the module's configuration page.
  $this
    ->drupalGet('admin/config/regional/language/language-switcher-extended');

  // Configure to show language switcher as lang code.
  $edit = [
    'show_langcode' => 1,
  ];
  $this
    ->submitForm($edit, 'Save configuration');

  // Open the node without a translation.
  $this
    ->drupalGet('node/1');

  // Verify, that the language switcher text is shown as lang code.
  $this
    ->assertSession()
    ->elementTextContains('css', '#block-test-language-block li.en', 'en');
  $this
    ->assertSession()
    ->elementTextNotContains('css', '#block-test-language-block li.en', 'English');

  // Logout user to verify user login page lang switcher is using lang code.
  $this
    ->drupalLogout();
  $this
    ->drupalGet('user');
  $this
    ->assertSession()
    ->elementTextContains('css', '#block-test-language-block li.en', 'en');
  $this
    ->assertSession()
    ->elementTextNotContains('css', '#block-test-language-block li.en', 'English');
}