public function AuthcacheBuiltinTestCacheBackend::testMissingUserCacheKey in Authenticated User Page Caching (Authcache) 7.2
Ensure that cache key is regenerated when missing.
File
- modules/
authcache_builtin/ tests/ authcache_builtin.cache-backend.test, line 218 - Test cases for the Authcache Bultin Cache Backend module.
Class
- AuthcacheBuiltinTestCacheBackend
- Tests update functionality unrelated to the database.
Code
public function testMissingUserCacheKey() {
$account = $this
->drupalCreateUser();
variable_set('authcache_roles', array(
DRUPAL_AUTHENTICATED_RID => DRUPAL_AUTHENTICATED_RID,
));
// Login and warm up cache.
$this
->drupalLogin($account);
$this
->drupalGet($this->fcURL . '?q=node', array(), $this
->buildRequestHeaders(0x1));
$this
->assertResponse(200);
$this
->assertEqual('MISS', $this
->drupalGetHeader('X-Drupal-Cache'), t('Cache miss on first request with authenticated user'));
$this
->drupalGet($this->fcURL . '?q=node', array(), $this
->buildRequestHeaders(0x1));
$this
->assertResponse(200);
$this
->assertEqual('HIT', $this
->drupalGetHeader('X-Drupal-Cache'), t('Cache hit on first request with authenticated user'));
// Clear the mapping between session and the authcache key.
cache_clear_all('*', 'cache_authcache_key', TRUE);
$this
->drupalGet($this->fcURL . '?q=node', array(), $this
->buildRequestHeaders(0x1));
$this
->assertResponse(200);
$this
->assertFalse($this
->drupalGetHeader('X-Drupal-Cache'), t('Cache miss on first request after key cache was cleared'));
$this
->drupalGet($this->fcURL . '?q=node', array(), $this
->buildRequestHeaders(0x1));
$this
->assertResponse(200);
$this
->assertEqual('HIT', $this
->drupalGetHeader('X-Drupal-Cache'), t('Cache hit on second request after key cache was cleared'));
$this
->drupalLogout();
}