You are here

public function AutoLogoutByRoleTestCase::testAutologoutTimeoutByRoleWhenRoleTimeoutIsLessThanStandard in Automated Logout 7.4

Check the role timeout has precedence over the basic timeout.

File

tests/autologout.test, line 650
Simpletest tests for autologout.

Class

AutoLogoutByRoleTestCase
Tests the autologout's features.

Code

public function testAutologoutTimeoutByRoleWhenRoleTimeoutIsLessThanStandard() {

  // Standard logout time is 60 seconds.
  variable_set("autologout_timeout", '60');

  // Enable role based logouts.
  variable_set("autologout_role_logout", '1');

  // Role logout time is set to 10 seconds.
  variable_set("autologout_role_{$this->role->rid}", '1');
  variable_set("autologout_role_{$this->role->rid}_timeout", '10');
  $user_timeout = _autologout_get_user_timeout($this->user->uid);
  $roles = _autologout_get_role_timeout();
  $this
    ->assertEqual($user_timeout, 10, "The users timeout {$user_timeout} is equal to their role timeout of 10");

  // Check that the user can access the page after login.
  $this
    ->drupalGet('/');
  $this
    ->assertText(t('Log out'), t('User is still logged in.'));

  // Wait for timeout period to elapse.
  sleep(16);

  // 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.'));
}