You are here

public function LanguageSwitcherExtendedTest::testLinkAlwaysToFrontpage in Language Switcher Extended 8

Tests, that language switcher link always link to frontpage.

File

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

Class

LanguageSwitcherExtendedTest
Functional tests for the language_switcher_extended feature.

Namespace

Drupal\Tests\language_switcher_extended\Functional

Code

public function testLinkAlwaysToFrontpage() {

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

  // Configure to always link to the front.
  $edit = [
    'mode' => 'always_link_to_front',
  ];
  $this
    ->submitForm($edit, 'Save configuration');

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

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