You are here

public function XmlSitemapUnitTest::testDuplicatePaths in XML sitemap 2.x

Same name and namespace in other branches
  1. 8 tests/src/Functional/XmlSitemapUnitTest.php \Drupal\Tests\xmlsitemap\Functional\XmlSitemapUnitTest::testDuplicatePaths()

Test that duplicate paths are skipped during generation.

File

tests/src/Functional/XmlSitemapUnitTest.php, line 299

Class

XmlSitemapUnitTest
Unit tests for the XML sitemap module.

Namespace

Drupal\Tests\xmlsitemap\Functional

Code

public function testDuplicatePaths() {
  $this
    ->drupalLogin($this->admin_user);

  // @codingStandardsIgnoreStart
  $link1 = $this
    ->addSitemapLink([
    'loc' => '/duplicate',
  ]);
  $link2 = $this
    ->addSitemapLink([
    'loc' => '/duplicate',
  ]);

  // @codingStandardsIgnoreEnd
  $this
    ->regenerateSitemap();
  $this
    ->drupalGetSitemap();
  $page_text = $this
    ->getSession()
    ->getPage()
    ->getContent();
  $nr_found = substr_count($page_text, 'duplicate');
  $this
    ->assertSame(1, $nr_found);
}