You are here

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

Test preclusion rules.

Try to prevent that the next request from the same client is served from the cache when one of the following conditions are met:

  • after a POST request
  • when messages are pending after rendering the page
  • hook_authcache_preclude implementation triggered preclusion

File

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

Class

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

Code

public function testPreclusionRules() {
  $this
    ->setupConfig(array(
    'authcache_roles' => drupal_map_assoc(array_keys(user_roles())),
  ));
  $this
    ->resetTestVariables();
  variable_set('authcache_test_status_message_exit', TRUE);
  $this
    ->authcacheGet('authcache-test-page-one', $this->plainUser);
  $this
    ->assertAuthcachePrecluded(t('Pending messages'));
  $this
    ->resetTestVariables();
  $reason = $this
    ->randomName(16);
  variable_set('authcache_test_authcache_preclude', $reason);
  $this
    ->authcacheGet('authcache-test-page-one', $this->plainUser);
  $this
    ->assertAuthcachePrecluded(t('Trigger preclusion: @reason', array(
    '@reason' => $reason,
  )));
}