You are here

public function SimplesitemapTest::testHrefLangRemoval in Simple XML sitemap 8.3

Same name and namespace in other branches
  1. 4.x tests/src/Functional/SimplesitemapTest.php \Drupal\Tests\simple_sitemap\Functional\SimplesitemapTest::testHrefLangRemoval()

Test the removal of hreflang tags in HTML.

File

tests/src/Functional/SimplesitemapTest.php, line 670

Class

SimplesitemapTest
Tests Simple XML Sitemap functional integration.

Namespace

Drupal\Tests\simple_sitemap\Functional

Code

public function testHrefLangRemoval() {

  // Test the nodes markup contains hreflang with default settings.
  $this->generator
    ->saveSetting('disable_language_hreflang', FALSE);
  $this
    ->drupalGet('node/' . $this->node
    ->id());
  $this
    ->assertNotEmpty($this
    ->xpath("//link[@hreflang]"));
  Cache::invalidateTags($this->node
    ->getCacheTags());

  // Test the hreflang markup gets removed.
  $this->generator
    ->saveSetting('disable_language_hreflang', TRUE);
  $this
    ->drupalGet('node/' . $this->node
    ->id());
  $this
    ->assertEmpty($this
    ->xpath("//link[@hreflang]"));
}