You are here

protected function AssertPageCacheContextsAndTagsTrait::assertCacheMaxAge in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Cache/AssertPageCacheContextsAndTagsTrait.php \Drupal\system\Tests\Cache\AssertPageCacheContextsAndTagsTrait::assertCacheMaxAge()

Asserts the max age header.

Parameters

int $max_age:

File

core/modules/system/src/Tests/Cache/AssertPageCacheContextsAndTagsTrait.php, line 158
Contains \Drupal\system\Tests\Cache\AssertPageCacheContextsAndTagsTrait.

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));
}