You are here

public function XmlSitemapFunctionalTest::testSitemapCaching in XML sitemap 8

Same name and namespace in other branches
  1. 2.x tests/src/Functional/XmlSitemapFunctionalTest.php \Drupal\Tests\xmlsitemap\Functional\XmlSitemapFunctionalTest::testSitemapCaching()

Test the sitemap file caching.

File

tests/src/Functional/XmlSitemapFunctionalTest.php, line 31

Class

XmlSitemapFunctionalTest
Tests the generation of sitemaps.

Namespace

Drupal\Tests\xmlsitemap\Functional

Code

public function testSitemapCaching() {
  $this
    ->drupalLogin($this->admin_user);
  $this
    ->regenerateSitemap();
  $this
    ->drupalGetSitemap();
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $etag = $this
    ->drupalGetHeader('etag');
  $last_modified = $this
    ->drupalGetHeader('last-modified');
  $this
    ->assertNotEmpty($etag, t('Etag header found.'));
  $this
    ->assertNotEmpty($last_modified, t('Last-modified header found.'));
  $this
    ->drupalGetSitemap([], [], [
    'If-Modified-Since' => $last_modified,
    'If-None-Match' => $etag,
  ]);
  $this
    ->assertSession()
    ->statusCodeEquals(304);
}