You are here

public function SimplesitemapTest::testCacheability in Simple XML sitemap 8.2

Test cacheability of the response.

File

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

Class

SimplesitemapTest
Tests Simple XML sitemap functional integration.

Namespace

Drupal\Tests\simple_sitemap\Functional

Code

public function testCacheability() {
  $this->generator
    ->setBundleSettings('node', 'page')
    ->generateSitemap('nobatch');

  // Verify the cache was flushed and node is in the sitemap.
  $this
    ->drupalGet('sitemap.xml');
  $this
    ->assertEquals('MISS', $this
    ->drupalGetHeader('X-Drupal-Cache'));
  $this
    ->assertSession()
    ->responseContains('node/' . $this->node
    ->id());

  // Verify the sitemap is taken from cache on second call and node is in the
  // sitemap.
  $this
    ->drupalGet('sitemap.xml');
  $this
    ->assertEquals('HIT', $this
    ->drupalGetHeader('X-Drupal-Cache'));
  $this
    ->assertSession()
    ->responseContains('node/' . $this->node
    ->id());
}