protected function AssertPageCacheContextsAndTagsTrait::assertCacheMaxAge in Drupal 8
Same name in this branch
- 8 core/modules/system/src/Tests/Cache/AssertPageCacheContextsAndTagsTrait.php \Drupal\system\Tests\Cache\AssertPageCacheContextsAndTagsTrait::assertCacheMaxAge()
- 8 core/modules/system/tests/src/Functional/Cache/AssertPageCacheContextsAndTagsTrait.php \Drupal\Tests\system\Functional\Cache\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\CacheCode
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));
}