You are here

public function LanguageSwitcherExtendedTest::testShowButNotLinkUntranslatedEntityLanguage in Language Switcher Extended 8

Tests, to show/no link language switcher item for an untranslated entity.

File

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

Class

LanguageSwitcherExtendedTest
Functional tests for the language_switcher_extended feature.

Namespace

Drupal\Tests\language_switcher_extended\Functional

Code

public function testShowButNotLinkUntranslatedEntityLanguage() {

  // 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' => 'process_untranslated',
    'untranslated_handler' => 'no_link',
  ];
  $this
    ->submitForm($edit, 'Save configuration');

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

  // Verify, that the untranslated language switcher is shown, but has no
  // link.
  $this
    ->assertSession()
    ->elementAttributeContains('css', '#block-test-language-block li[hreflang="en"] a', 'data-drupal-link-system-path', 'node/1');
  $this
    ->assertSession()
    ->elementNotExists('css', '#block-test-language-block li.de a');
  $this
    ->assertSession()
    ->elementTextContains('css', '#block-test-language-block li.de', 'German');
}