You are here

public function AuthcacheBackendKeyManagementTestCase::testKeyRenewDuringLogin in Authenticated User Page Caching (Authcache) 7.2

Call hook_authcache_backend_key_set during login and logout.

File

tests/authcache.backend.test, line 301
Test cases for pluggable cache backends.

Class

AuthcacheBackendKeyManagementTestCase
Test key management.

Code

public function testKeyRenewDuringLogin() {
  variable_set('simpletest_maximum_redirects', 0);
  $this
    ->drupalGet('user');
  $backend_boot = $this->stubbackend
    ->hook('boot', array(
    'authcache_backend_test',
    'Cookie',
    authcache_backend_anonymous_key(),
  ));
  $key_set = $this->stubbackend
    ->hook('authcache_backend_key_set');
  $edit = array(
    'name' => $this->member->name,
    'pass' => $this->member->pass_raw,
  );
  $this
    ->drupalPost(NULL, $edit, t('Log in'));
  $user_key = $this
    ->drupalGetHeader('X-Authcache-Backend-Test-Key-Exit');
  $this
    ->assertTrue($user_key, 'User key is not empty');
  $this
    ->assertNotEqual(authcache_backend_anonymous_key(), $user_key, 'User key is not same as the anonymous key');
  $this
    ->assertStub($backend_boot, HookStub::once());
  $this
    ->assertStub($key_set, HookStub::once());
  $this
    ->assertStub($key_set, HookStub::args(array(
    $user_key,
    authcache_key_lifetime(),
    TRUE,
  )));
}