function AssertPageCacheContextsAndTagsTrait::assertCacheMaxAge

Asserts the max age header.

Parameters

int $max_age:

File

core/modules/system/src/Tests/Cache/AssertPageCacheContextsAndTagsTrait.php, line 190

Class

AssertPageCacheContextsAndTagsTrait
Provides test assertions for testing page-level cache contexts & tags.

Namespace

Drupal\system\Tests\Cache

Code

protected function assertCacheMaxAge($max_age) {
  $cache_control_header = $this->drupalGetHeader('Cache-Control');
  if (strpos($cache_control_header, 'max-age:' . $max_age) === FALSE) {
    debug('Expected max-age:' . $max_age . '; Response max-age:' . $cache_control_header);
  }
  $this->assertTrue(strpos($cache_control_header, 'max-age:' . $max_age));
}

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