public function AutoLogoutByRoleTestCase::testAutoLogoutTimeoutByRoleWhenRoleTimeoutIsGreaterThanStandard in Automated Logout 7.4
Check the role timeout has precedence over the basic timeout.
File
- tests/
autologout.test, line 683 - Simpletest tests for autologout.
Class
- AutoLogoutByRoleTestCase
- Tests the autologout's features.
Code
public function testAutoLogoutTimeoutByRoleWhenRoleTimeoutIsGreaterThanStandard() {
// Standard logout time is 10 seconds.
variable_set("autologout_timeout", '10');
// Enable role based logouts.
variable_set("autologout_role_logout", '1');
// Role logout time is set to 15 seconds.
variable_set("autologout_role_{$this->role->rid}", '1');
variable_set("autologout_role_{$this->role->rid}_timeout", '15');
$user_timeout = _autologout_get_user_timeout($this->user->uid);
$this
->assertEqual($user_timeout, 15, "The users timeout {$user_timeout} is equal to their role timeout of 15");
// Check that the user can access the page after initial login.
$this
->drupalGet('/');
$this
->assertText(t('Log out'), t('User is still logged in.'));
// Wait for the standard timeout period to elapse.
sleep(16);
// Check that the user is still logged in.
$this
->drupalGet('/');
$this
->assertText(t('Log out'), t('User is still logged in.'));
// Wait for the role timeout period to elapse.
sleep(21);
// Check we are now logged out.
$this
->drupalGet('/');
$this
->assertNoText(t('Log out'), t('User is no longer logged in.'));
$this
->assertText(t('You have been logged out due to inactivity.'), t('User sees inactivity message.'));
}