You are here

public function SimplesitemapTest::testLastmod in Simple XML sitemap 8.2

Same name and namespace in other branches
  1. 8.3 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.

File

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

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('nobatch');
  $this
    ->drupalGet('sitemap.xml');
  $this
    ->assertSession()
    ->responseContains('lastmod');

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

  // Non-entity custom links should not have 'lastmod'.
  $this->generator
    ->removeCustomLinks()
    ->addCustomLink('/')
    ->generateSitemap('nobatch');
  $this
    ->drupalGet('sitemap.xml');
  $this
    ->assertSession()
    ->responseNotContains('lastmod');
}