public function AuthcachePolicyTestCase::testOtherOptions in Authenticated User Page Caching (Authcache) 7.2
Test rest of custom options (authcache_http200, authcache_noajax).
File
- ./
authcache.test, line 1291 - Tests for system.module.
Class
- AuthcachePolicyTestCase
- Test cache policy rules, i.e. exclusion and cancelation.
Code
public function testOtherOptions() {
// Ensure that requests are not cached when status != 200 and
// authcache_http200 is set.
$this
->setupConfig(array(
'authcache_roles' => drupal_map_assoc(array_keys(user_roles())),
));
$this
->resetTestVariables();
$save_stub = $this->stubbackend
->hook('authcache_backend_cache_save');
$this
->authcacheGet('authcache-test-403', $this->plainUser);
$this
->assertAuthcacheNotCanceled();
$this
->assertAuthcacheNotExcluded();
$this
->assertStub($save_stub, HookStub::any());
$this
->setupConfig(array(
'authcache_roles' => drupal_map_assoc(array_keys(user_roles())),
'authcache_http200' => TRUE,
));
$this
->resetTestVariables();
$this
->authcacheGet('authcache-test-403', $this->plainUser);
$this
->assertAuthcacheCanceled(t('HTTP status 404/403s/etc'));
// Ensure that Ajax requests are not cached when authcache_noajax is set.
$this
->setupConfig(array(
'authcache_roles' => drupal_map_assoc(array_keys(user_roles())),
));
$this
->resetTestVariables();
$save_stub = $this->stubbackend
->hook('authcache_backend_cache_save');
$this
->authcacheGet('authcache-test-page-one', $this->plainUser, array(), array(
'X-Requested-With: XMLHttpRequest',
));
$this
->assertAuthcacheNotCanceled();
$this
->assertAuthcacheNotExcluded();
$this
->assertStub($save_stub, HookStub::any());
$this
->setupConfig(array(
'authcache_roles' => drupal_map_assoc(array_keys(user_roles())),
'authcache_noajax' => TRUE,
));
$this
->resetTestVariables();
$this
->authcacheGet('authcache-test-page-one', $this->plainUser, array(), array(
'X-Requested-With: XMLHttpRequest',
));
$this
->assertAuthcacheExcluded(t('Ajax request'));
}