You are here

protected function AuthcacheTestAdminWidgets::testGetRoleRestrict in Authenticated User Page Caching (Authcache) 7.2

Cover authcache_get_role_restrict_roles().

File

tests/authcache.widget.test, line 85
Test cases for pluggable cache backends.

Class

AuthcacheTestAdminWidgets
Cover authcache module.

Code

protected function testGetRoleRestrict() {
  $roles = authcache_get_role_restrict_roles(array());
  $this
    ->assertEqual(authcache_get_roles(), $roles, 'Role restrict defaults to all enabled authcache roles');
  $roles = authcache_get_role_restrict_roles(array(
    'custom' => FALSE,
  ));
  $this
    ->assertEqual(authcache_get_roles(), $roles, 'Role restrict defaults to all enabled authcache roles');
  $roles = authcache_get_role_restrict_roles(array(
    'custom' => TRUE,
  ));
  $this
    ->assertEqual(array(), $roles, 'Default to no roles when role restrict is enabled');
  $roles = authcache_get_role_restrict_roles(array(
    'custom' => TRUE,
    'roles' => $this->authcacheRoles,
  ));
  $this
    ->assertEqual(array_keys($this->authcacheRoles), array_keys($roles), 'Should return enabled roles');
  $admin_roles = $this->admin->roles;
  unset($admin_roles[DRUPAL_AUTHENTICATED_RID]);
  $roles = authcache_get_role_restrict_roles(array(
    'custom' => TRUE,
    'roles' => $admin_roles,
  ));
  $this
    ->assertEqual(array(), array_keys($roles), 'Should not return non-enabled roles');
}