public function LanguageSwitcherExtendedTest::testTranslatedLanguageSwitcherItemIsVisible in Language Switcher Extended 8
Tests, that a translated entity language switcher item is visible.
File
- tests/
src/ Functional/ LanguageSwitcherExtendedTest.php, line 198
Class
- LanguageSwitcherExtendedTest
- Functional tests for the language_switcher_extended feature.
Namespace
Drupal\Tests\language_switcher_extended\FunctionalCode
public function testTranslatedLanguageSwitcherItemIsVisible() {
// Open the module's configuration page.
$this
->drupalGet('admin/config/regional/language/language-switcher-extended');
// Configure to hide the link for untranslated entities.
$edit = [
'mode' => 'process_untranslated',
'untranslated_handler' => 'hide_link',
];
$this
->submitForm($edit, 'Save configuration');
// Add a new translation for the node.
$translation = $this->node
->addTranslation('de', $this->node
->toArray());
$translation
->save();
// Open the node.
$this
->drupalGet('node/1');
// Verify, that the translated language switcher item is shown.
$this
->assertSession()
->elementAttributeContains('css', '#block-test-language-block li[hreflang="en"] a', 'data-drupal-link-system-path', 'node/1');
$this
->assertSession()
->elementAttributeContains('css', '#block-test-language-block li[hreflang="de"] a', 'data-drupal-link-system-path', 'node/1');
$this
->assertSession()
->elementAttributeContains('css', '#block-test-language-block li[hreflang="de"] a', 'href', 'de/node/1');
}