function PageCacheTest::testPageCacheWithoutVaryCookie

Same name in other branches
  1. 9 core/modules/page_cache/tests/src/Functional/PageCacheTest.php \Drupal\Tests\page_cache\Functional\PageCacheTest::testPageCacheWithoutVaryCookie()
  2. 8.9.x core/modules/page_cache/tests/src/Functional/PageCacheTest.php \Drupal\Tests\page_cache\Functional\PageCacheTest::testPageCacheWithoutVaryCookie()
  3. 10 core/modules/page_cache/tests/src/Functional/PageCacheTest.php \Drupal\Tests\page_cache\Functional\PageCacheTest::testPageCacheWithoutVaryCookie()

Tests the omit_vary_cookie setting.

1 call to PageCacheTest::testPageCacheWithoutVaryCookie()
PageCacheTest::testPageCache in core/modules/page_cache/tests/src/Functional/PageCacheTest.php
Tests page caching.

File

core/modules/page_cache/tests/src/Functional/PageCacheTest.php, line 441

Class

PageCacheTest
Enables the page cache and tests it with various HTTP requests.

Namespace

Drupal\Tests\page_cache\Functional

Code

protected function testPageCacheWithoutVaryCookie() : void {
    $this->enablePageCaching();
    $settings['settings']['omit_vary_cookie'] = (object) [
        'value' => TRUE,
        'required' => TRUE,
    ];
    $this->writeSettings($settings);
    // Fill the cache.
    $this->drupalGet('');
    $this->assertSession()
        ->responseHeaderEquals('X-Drupal-Cache', 'MISS');
    $this->assertSession()
        ->responseHeaderNotContains('Vary', 'cookie');
    $this->assertCacheMaxAge(300);
    // Check cache.
    $this->drupalGet('');
    $this->assertSession()
        ->responseHeaderEquals('X-Drupal-Cache', 'HIT');
    $this->assertSession()
        ->responseHeaderNotContains('Vary', 'cookie');
    $this->assertCacheMaxAge(300);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.