public function SessionLimitPreventTestCase::testSessionLimitUser in Session Limit 6.2
Same name and namespace in other branches
- 8 tests/session_limit.test \SessionLimitPreventTestCase::testSessionLimitUser()
- 7.2 tests/session_limit.test \SessionLimitPreventTestCase::testSessionLimitUser()
- 2.x tests/session_limit.test \SessionLimitPreventTestCase::testSessionLimitUser()
Checks that the session limit is returned correctly by a user override.
File
- tests/
session_limit.test, line 576 - Simpletest tests for session_limit.
Class
- SessionLimitPreventTestCase
- Session limit functionality when behaviour is to prevent login at limit.
Code
public function testSessionLimitUser() {
// Create a test user.
$user = $this
->drupalCreateUser();
$roles = $this
->sessionLimitMakeRoles($user);
// Add a personal session limit.
user_save($user, array(
'session_limit' => 5,
));
// Set the session limits for the roles.
variable_set('session_limit_rid_' . $roles[0]->rid, 2);
variable_set('session_limit_rid_' . $roles[1]->rid, 3);
variable_set('session_limit_rid_' . $roles[2]->rid, 4);
// Set the default session limit.
variable_set('session_limit_max', 1);
// Check if the user has access to 5 sessions.
$this
->assertSessionPrevent(5, $user);
}