You are here

public function SimplesitemapTest::testLastmod in Simple XML sitemap 8.3

Same name and namespace in other branches
  1. 8.2 tests/src/Functional/SimplesitemapTest.php \Drupal\Tests\simple_sitemap\Functional\SimplesitemapTest::testLastmod()
  2. 4.x 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 275

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
    ->setBundleSettings('node', 'page')
    ->removeCustomLinks()
    ->generateSitemap(QueueWorker::GENERATE_TYPE_BACKEND);
  $this
    ->drupalGet($this->defaultSitemapUrl);
  $this
    ->assertSession()
    ->responseContains('lastmod');

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

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