You are here

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

Cover authcache_role_restrict_members_access().

File

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

Class

AuthcacheTestAdminWidgets
Cover authcache module.

Code

protected function testRoleRestrictMembersAccess() {
  $config = array();
  $this
    ->assertFalse(authcache_role_restrict_members_access($config, drupal_anonymous_user()));
  $this
    ->assertTrue(authcache_role_restrict_members_access($config, $this->plainUser));
  $this
    ->assertTrue(authcache_role_restrict_members_access($config, $this->member));
  $this
    ->assertFalse(authcache_role_restrict_members_access($config, $this->admin));
  $config = array(
    'custom' => FALSE,
  );
  $this
    ->assertFalse(authcache_role_restrict_members_access($config, drupal_anonymous_user()));
  $this
    ->assertTrue(authcache_role_restrict_members_access($config, $this->plainUser));
  $this
    ->assertTrue(authcache_role_restrict_members_access($config, $this->member));
  $this
    ->assertFalse(authcache_role_restrict_members_access($config, $this->admin));
  $config = array(
    'custom' => TRUE,
  );
  $this
    ->assertFalse(authcache_role_restrict_members_access($config, drupal_anonymous_user()));
  $this
    ->assertFalse(authcache_role_restrict_members_access($config, $this->plainUser));
  $this
    ->assertFalse(authcache_role_restrict_members_access($config, $this->member));
  $this
    ->assertFalse(authcache_role_restrict_members_access($config, $this->admin));
  $config = array(
    'custom' => TRUE,
    'roles' => $this->authcacheRoles,
  );
  $this
    ->assertFalse(authcache_role_restrict_members_access($config, drupal_anonymous_user()));
  $this
    ->assertTrue(authcache_role_restrict_members_access($config, $this->plainUser));
  $this
    ->assertTrue(authcache_role_restrict_members_access($config, $this->member));
  $this
    ->assertFalse(authcache_role_restrict_members_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_members_access($config, drupal_anonymous_user()));
  $this
    ->assertFalse(authcache_role_restrict_members_access($config, $this->plainUser));
  $this
    ->assertFalse(authcache_role_restrict_members_access($config, $this->member));
  $this
    ->assertFalse(authcache_role_restrict_members_access($config, $this->admin));
}