You are here

public function AuthcacheAnonymousKeysTestCase::testCustomKeyGenerator in Authenticated User Page Caching (Authcache) 7.2

Test custom key generator.

File

./authcache.test, line 1422
Tests for system.module.

Class

AuthcacheAnonymousKeysTestCase
Test key computation and handling

Code

public function testCustomKeyGenerator() {
  $mock_key = $this
    ->randomName(16);
  $this
    ->setupConfig(array(
    'authcache_key_generator' => 'authcache_test_key_generator',
  ));
  $this
    ->resetTestVariables();
  variable_set('authcache_test_key_generator_key', $mock_key);
  $this
    ->drupalLogout();
  $anon_key = $this
    ->drupalGet('authcache-test-get-key');
  $this
    ->assertEqual($mock_key, $anon_key);
  $this
    ->drupalLogin($this->plainUser);
  $plain_user_key = $this
    ->drupalGet('authcache-test-get-key');
  $this
    ->assertNotEqual($mock_key, $plain_user_key);
  $this
    ->drupalLogout();
  $this
    ->drupalLogin($this->webUser);
  $web_user_key = $this
    ->drupalGet('authcache-test-get-key');
  $this
    ->assertNotEqual($mock_key, $web_user_key);
  $this
    ->drupalLogout();
  $this
    ->drupalLogin($this->adminUser);
  $admin_user_key = $this
    ->drupalGet('authcache-test-get-key');
  $this
    ->assertNotEqual($mock_key, $admin_user_key);
  $this
    ->drupalLogout();
  $this
    ->drupalLogin($this->superUser);
  $super_user_key = $this
    ->drupalGet('authcache-test-get-key');
  $this
    ->assertNotEqual($mock_key, $super_user_key);
  $this
    ->drupalLogout();
}