public function SessionLimitBaseTestCase::sessionLimitMakeRoles in Session Limit 7.2
Same name and namespace in other branches
- 8 tests/session_limit.test \SessionLimitBaseTestCase::sessionLimitMakeRoles()
- 6.2 tests/session_limit.test \SessionLimitBaseTestCase::sessionLimitMakeRoles()
- 2.x tests/session_limit.test \SessionLimitBaseTestCase::sessionLimitMakeRoles()
Session limit helper function to create 3 roles.
Parameters
stdClass $user: (optional) If provided the user will be added to the three roles.
Return value
array An array of the three roles.
6 calls to SessionLimitBaseTestCase::sessionLimitMakeRoles()
- SessionLimitLogoutTestCase::testSessionLimitRoles in tests/
session_limit.test - Checks that the session limit is returned correctly by a role.
- SessionLimitLogoutTestCase::testSessionLimitUser in tests/
session_limit.test - Checks that the session limit is returned correctly by a user override.
- SessionLimitLogoutTestCase::testSessionLimitUserMaxPrecedence in tests/
session_limit.test - Check that user override takes precedence over default and role regardless of max.
- SessionLimitPreventTestCase::testSessionLimitRoles in tests/
session_limit.test - Checks that the session limit is returned correctly by a role.
- SessionLimitPreventTestCase::testSessionLimitUser in tests/
session_limit.test - Checks that the session limit is returned correctly by a user override.
File
- tests/
session_limit.test, line 32 - Simpletest tests for session_limit.
Class
- SessionLimitBaseTestCase
- Base test for session limits.
Code
public function sessionLimitMakeRoles($user = NULL) {
// Create roles.
$roles = array();
$roles[] = (object) array(
'name' => 'role1',
);
$roles[] = (object) array(
'name' => 'role2',
);
$roles[] = (object) array(
'name' => 'role3',
);
user_role_save($roles[0]);
user_role_save($roles[1]);
user_role_save($roles[2]);
if (!empty($user)) {
$user->roles[$roles[0]->rid] = $roles[0]->name;
$user->roles[$roles[1]->rid] = $roles[1]->name;
$user->roles[$roles[2]->rid] = $roles[2]->name;
user_save($user);
}
return $roles;
}