You are here

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

Cover authcache_is_default_key().

File

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

Class

AuthcacheAnonymousKeysTestCase
Test key computation and handling

Code

public function testIsDefaultKey() {
  global $base_root;

  // For anonymous users authcache key defaults to the base root.
  $result = authcache_is_default_key($base_root);
  $this
    ->assertTrue($result);

  // Expect non-default key for authenticated users.
  $test_key = $this
    ->randomName(8);
  $this
    ->assertNotEqual($base_root, $test_key);
  $result = authcache_is_default_key($test_key);
  $this
    ->assertFalse($result);

  // If authcache_key_generator was customized even anonymous users will not
  // have a default key.
  variable_set('authcache_key_generator', 'authcache_test_key_generator');
  $result = authcache_is_default_key($base_root);
  $this
    ->assertFalse($result);
}