You are here

public function PageCacheTest::testCacheableWithCustomCacheControl in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/page_cache/tests/src/Functional/PageCacheTest.php \Drupal\Tests\page_cache\Functional\PageCacheTest::testCacheableWithCustomCacheControl()
  2. 10 core/modules/page_cache/tests/src/Functional/PageCacheTest.php \Drupal\Tests\page_cache\Functional\PageCacheTest::testCacheableWithCustomCacheControl()

Tests a cacheable response with custom cache control.

File

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

Class

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

Namespace

Drupal\Tests\page_cache\Functional

Code

public function testCacheableWithCustomCacheControl() {
  $config = $this
    ->config('system.performance');
  $config
    ->set('cache.page.max_age', 300);
  $config
    ->save();
  $this
    ->drupalGet('/system-test/custom-cache-control');
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->assertSession()
    ->responseHeaderEquals('Cache-Control', 'bar, private');
}