You are here

public function AuthcachePolicyTestCase::testExcludeCancelHooks in Authenticated User Page Caching (Authcache) 7.2

Test API for exclusion and cancelation.

File

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

Class

AuthcachePolicyTestCase
Test cache policy rules, i.e. exclusion and cancelation.

Code

public function testExcludeCancelHooks() {
  $this
    ->setupConfig(array(
    'authcache_roles' => drupal_map_assoc(array_keys(user_roles())),
  ));

  // Test hook_authcache_request_exclude.
  $this
    ->resetTestVariables();
  $reason = $this
    ->randomName(16);
  variable_set('authcache_test_authcache_request_exclude', $reason);
  $this
    ->authcacheGet('authcache-test-page-one', $this->plainUser);
  $this
    ->assertAuthcacheExcluded(t('Trigger request exclude: @reason', array(
    '@reason' => $reason,
  )));

  // Test hook_authcache_account_exclude.
  $this
    ->resetTestVariables();
  $reason = $this
    ->randomName(16);
  variable_set('authcache_test_authcache_account_exclude', $reason);
  $this
    ->authcacheGet('authcache-test-page-one', $this->plainUser);
  $this
    ->assertAuthcacheExcluded(t('Trigger account exclude for uid=@uid: @reason', array(
    '@uid' => $this->plainUser->uid,
    '@reason' => $reason,
  )));

  // Test hook_authcache_cancel.
  $this
    ->resetTestVariables();
  $reason = $this
    ->randomName(16);
  variable_set('authcache_test_authcache_cancel', $reason);
  $this
    ->authcacheGet('authcache-test-page-one', $this->plainUser);
  $this
    ->assertAuthcacheCanceled(t('Trigger cancelation: @reason', array(
    '@reason' => $reason,
  )));
}