You are here

public function SimplesitemapTest::testRemoveCustomLinks in Simple XML sitemap 4.x

Same name and namespace in other branches
  1. 8.3 tests/src/Functional/SimplesitemapTest.php \Drupal\Tests\simple_sitemap\Functional\SimplesitemapTest::testRemoveCustomLinks()
  2. 8.2 tests/src/Functional/SimplesitemapTest.php \Drupal\Tests\simple_sitemap\Functional\SimplesitemapTest::testRemoveCustomLinks()

Test removing custom paths from the sitemap settings.

Throws

\Drupal\Component\Plugin\Exception\PluginException

\Behat\Mink\Exception\ExpectationException

File

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

Class

SimplesitemapTest
Tests Simple XML Sitemap functional integration.

Namespace

Drupal\Tests\simple_sitemap\Functional

Code

public function testRemoveCustomLinks() {

  // Test removing one custom path from the sitemap.
  $this->generator
    ->customLinkManager()
    ->add('/node/' . $this->node
    ->id())
    ->remove('/node/' . $this->node
    ->id());
  $this->generator
    ->generateSitemap(QueueWorker::GENERATE_TYPE_BACKEND);
  $this
    ->drupalGet($this->defaultSitemapUrl);
  $this
    ->assertSession()
    ->responseNotContains('node/' . $this->node
    ->id());

  // Test removing all custom paths from the sitemap.
  $this->generator
    ->customLinkManager()
    ->remove();
  $this->generator
    ->generateSitemap(QueueWorker::GENERATE_TYPE_BACKEND);
  $this
    ->drupalGet($this->defaultSitemapUrl);
  $this
    ->assertSession()
    ->responseNotContains(Url::fromRoute('<front>')
    ->setAbsolute()
    ->toString());
}