You are here

public function SimplesitemapTest::testLastmod 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::testLastmod()
  2. 8.2 tests/src/Functional/SimplesitemapTest.php \Drupal\Tests\simple_sitemap\Functional\SimplesitemapTest::testLastmod()

Test the lastmod parameter in different scenarios.

Throws

\Drupal\Component\Plugin\Exception\PluginException

\Behat\Mink\Exception\ExpectationException

File

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

Class

SimplesitemapTest
Tests Simple XML Sitemap functional integration.

Namespace

Drupal\Tests\simple_sitemap\Functional

Code

public function testLastmod() {

  // Entity links should have 'lastmod'.
  $this->generator
    ->entityManager()
    ->setBundleSettings('node', 'page');
  $this->generator
    ->customLinkManager()
    ->remove();
  $this->generator
    ->generateSitemap(QueueWorker::GENERATE_TYPE_BACKEND);
  $this
    ->drupalGet($this->defaultSitemapUrl);
  $this
    ->assertSession()
    ->responseContains('lastmod');

  // Entity custom links should have 'lastmod'.
  $this->generator
    ->entityManager()
    ->setBundleSettings('node', 'page', [
    'index' => FALSE,
  ]);
  $this->generator
    ->customLinkManager()
    ->add('/node/' . $this->node
    ->id());
  $this->generator
    ->generateSitemap(QueueWorker::GENERATE_TYPE_BACKEND);
  $this
    ->drupalGet($this->defaultSitemapUrl);
  $this
    ->assertSession()
    ->responseContains('lastmod');

  // Non-entity custom links should not have 'lastmod'.
  $this->generator
    ->customLinkManager()
    ->remove()
    ->add('/');
  $this->generator
    ->generateSitemap(QueueWorker::GENERATE_TYPE_BACKEND);
  $this
    ->drupalGet($this->defaultSitemapUrl);
  $this
    ->assertSession()
    ->responseNotContains('lastmod');
}