You are here

public function LanguageAccessTest::testHreflangTagAccess in Language access 8

Test language access in combination with hreflang tags.

File

tests/src/Functional/LanguageAccessTest.php, line 94

Class

LanguageAccessTest
Test language access on the frontend.

Namespace

Drupal\Tests\language_access\Functional

Code

public function testHreflangTagAccess() {
  $this
    ->drupalLogin($this->userEn);
  $this
    ->drupalGet('en/node/1');
  $this
    ->assertSession()
    ->elementExists('css', 'link[rel="alternate"][hreflang="en"]');
  $this
    ->assertSession()
    ->elementNotExists('css', 'link[rel="alternate"][hreflang="nl"]');
  $this
    ->drupalLogin($this->userNl);
  $this
    ->drupalGet('nl/node/1');
  $this
    ->assertSession()
    ->elementExists('css', 'link[rel="alternate"][hreflang="nl"]');
  $this
    ->assertSession()
    ->elementNotExists('css', 'link[rel="alternate"][hreflang="en"]');
}