public function AuthcacheTestBackend::testVaryHeaderWithoutAuthcacheConfig in Authenticated User Page Caching (Authcache) 7.2
Test presence of Vary header when authcache is disabled (per config).
File
- tests/
authcache.backend.test, line 149 - Test cases for pluggable cache backends.
Class
- AuthcacheTestBackend
- Cover authcache module.
Code
public function testVaryHeaderWithoutAuthcacheConfig() {
// Setup backend.
$vary_header = $this
->randomName(8);
$params = array(
'authcache_backend_test',
$vary_header,
);
// Disable authcache.
variable_del('authcache_roles');
// Test whether Vary header is present, even when caching is not enabled for
// anonymous users.
$hook_boot = $this->stubbackend
->hook('boot', $params);
$hook_save = $this->stubbackend
->hook('authcache_backend_cache_save');
$this
->drupalGet('<front>');
$this
->assertVary($vary_header);
$this
->assertCacheControl('must-revalidate');
$this
->assertCacheControl('no-cache');
$this
->assertNoCacheControl('public');
$this
->assertStub($hook_boot, HookStub::once());
$this
->assertStub($hook_save, HookStub::never());
// Test whether Vary header is present, even when caching is not enabled for
// authenticated users.
$this
->drupalLogin($this->member);
$hook_boot = $this->stubbackend
->hook('boot', $params);
$hook_save = $this->stubbackend
->hook('authcache_backend_cache_save');
$this
->drupalGet('<front>');
$this
->assertVary($vary_header);
$this
->assertCacheControl('must-revalidate');
$this
->assertCacheControl('no-cache');
$this
->assertNoCacheControl('public');
$this
->assertStub($hook_boot, HookStub::once());
$this
->assertStub($hook_save, HookStub::never());
}