You are here

private function RoleAssignWebTestCase::userLoadAndCheckRoleAssigned in RoleAssign 7

Check role on user object.

Parameters

object $account: The user account to check.

string $rid: The role ID to search for.

bool $is_assigned: (optional) Whether to assert that $rid exists (TRUE) or not (FALSE). Defaults to TRUE.

1 call to RoleAssignWebTestCase::userLoadAndCheckRoleAssigned()
RoleAssignWebTestCase::testRoleAssignIssue1954332 in ./roleassign.test
Check for loss of unassignable/restricted roles.

File

./roleassign.test, line 116
Tests for the RoleAssign module.

Class

RoleAssignWebTestCase
Test case for RoleAssign module.

Code

private function userLoadAndCheckRoleAssigned($account, $rid, $is_assigned = TRUE) {
  $account = user_load($account->uid, TRUE);
  if ($is_assigned) {
    $this
      ->assertTrue(array_key_exists($rid, $account->roles), 'The role is present in the user object.');
  }
  else {
    $this
      ->assertFalse(array_key_exists($rid, $account->roles), 'The role is not present in the user object.');
  }
}