protected function AuthcacheTestAdminWidgets::testRoleRestrictAccess in Authenticated User Page Caching (Authcache) 7.2
Cover authcache_role_restrict_access().
File
- tests/
authcache.widget.test, line 113 - Test cases for pluggable cache backends.
Class
- AuthcacheTestAdminWidgets
- Cover authcache module.
Code
protected function testRoleRestrictAccess() {
$config = array();
$this
->assertTrue(authcache_role_restrict_access($config, drupal_anonymous_user()));
$this
->assertTrue(authcache_role_restrict_access($config, $this->plainUser));
$this
->assertTrue(authcache_role_restrict_access($config, $this->member));
$this
->assertFalse(authcache_role_restrict_access($config, $this->admin));
$config = array(
'custom' => FALSE,
);
$this
->assertTrue(authcache_role_restrict_access($config, drupal_anonymous_user()));
$this
->assertTrue(authcache_role_restrict_access($config, $this->plainUser));
$this
->assertTrue(authcache_role_restrict_access($config, $this->member));
$this
->assertFalse(authcache_role_restrict_access($config, $this->admin));
$config = array(
'custom' => TRUE,
);
$this
->assertFalse(authcache_role_restrict_access($config, drupal_anonymous_user()));
$this
->assertFalse(authcache_role_restrict_access($config, $this->plainUser));
$this
->assertFalse(authcache_role_restrict_access($config, $this->member));
$this
->assertFalse(authcache_role_restrict_access($config, $this->admin));
$config = array(
'custom' => TRUE,
'roles' => $this->authcacheRoles,
);
$this
->assertTrue(authcache_role_restrict_access($config, drupal_anonymous_user()));
$this
->assertTrue(authcache_role_restrict_access($config, $this->plainUser));
$this
->assertTrue(authcache_role_restrict_access($config, $this->member));
$this
->assertFalse(authcache_role_restrict_access($config, $this->admin));
$admin_roles = $this->admin->roles;
unset($admin_roles[DRUPAL_AUTHENTICATED_RID]);
$config = array(
'custom' => TRUE,
'roles' => $admin_roles,
);
$this
->assertFalse(authcache_role_restrict_access($config, drupal_anonymous_user()));
$this
->assertFalse(authcache_role_restrict_access($config, $this->plainUser));
$this
->assertFalse(authcache_role_restrict_access($config, $this->member));
$this
->assertFalse(authcache_role_restrict_access($config, $this->admin));
}