function UserRolesAssignmentTestCase::userLoadAndCheckRoleAssigned
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.
2 calls to UserRolesAssignmentTestCase::userLoadAndCheckRoleAssigned()
- UserRolesAssignmentTestCase::testAssignAndRemoveRole in modules/
user/ user.test - Tests that a user can be assigned a role and that the role can be removed again.
- UserRolesAssignmentTestCase::testCreateUserWithRole in modules/
user/ user.test - Tests that when creating a user the role can be assigned. And that it can be removed again.
File
-
modules/
user/ user.test, line 2781
Class
- UserRolesAssignmentTestCase
- Test role assignment.
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.');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.