You are here

public function LanguageSwitcherExtendedTest::testAlwaysHideCurrentLanguage in Language Switcher Extended 8

Tests that current language link is hidden in switcher.

File

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

Class

LanguageSwitcherExtendedTest
Functional tests for the language_switcher_extended feature.

Namespace

Drupal\Tests\language_switcher_extended\Functional

Code

public function testAlwaysHideCurrentLanguage() {

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

  // Configure to show untranslated translations without a link.
  $edit = [
    'mode' => 'always_link_to_front',
    'current_language_mode' => 'hide_link',
  ];
  $this
    ->submitForm($edit, 'Save configuration');

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

  // Verify that the current language is not in the switcher items.
  $this
    ->assertSession()
    ->elementNotExists('css', '#block-test-language-block li[hreflang="en"]');

  // Verify that other language links lead to the homepage.
  $this
    ->assertSession()
    ->elementAttributeContains('css', '#block-test-language-block li[hreflang="de"] a', 'data-drupal-link-system-path', '<front>');
}