You are here

public function AutologoutTestCase::testAutologoutTimeoutPrecedence in Automated Logout 7.4

Same name and namespace in other branches
  1. 6.4 tests/autologout.test \AutologoutTestCase::testAutologoutTimeoutPrecedence()

Test the precedence of the timeouts.

This tests the following function: _autologout_get_user_timeout();

File

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

Class

AutologoutTestCase
Tests the autologout's features.

Code

public function testAutologoutTimeoutPrecedence() {
  $uid = $this->privileged_user->uid;

  // Default used if no role is specified.
  variable_set('autologout_timeout', 100);
  variable_set('autologout_role_logout', FALSE);
  variable_set('autologout_role_2', FALSE);
  variable_set('autologout_role_2_timeout', 200);
  $this
    ->assertAutotimeout($uid, 100, t('User timeout uses default if no other option set'));

  // Default used if role selected but no user's role is selected.
  variable_set('autologout_role_logout', TRUE);
  variable_set('autologout_role_2', FALSE);
  variable_set('autologout_role_2_timeout', 200);
  $this
    ->assertAutotimeout($uid, 100, t('User timeout uses default if  role timeouts are used but not one of the current user.'));

  // Role timeout is used if user's role is selected.
  variable_set('autologout_role_logout', TRUE);
  variable_set('autologout_role_2', TRUE);
  variable_set('autologout_role_2_timeout', 200);
  $this
    ->assertAutotimeout($uid, 200, t('User timeout uses role value'));

  // Role timeout is used if user's role is selected.
  variable_set('autologout_role_logout', TRUE);
  variable_set('autologout_role_2', TRUE);
  variable_set('autologout_role_2_timeout', 0);
  $this
    ->assertAutotimeout($uid, 0, t('User timeout uses role value of 0 if set for one of the user roles.'));

  // Role timeout used if personal timeout is empty string.
  variable_set('autologout_role_logout', TRUE);
  variable_set('autologout_role_2', TRUE);
  variable_set('autologout_role_2_timeout', 200);
  variable_set('autologout_user_' . $uid, '');
  $this
    ->assertAutotimeout($uid, 200, t('User timeout uses role value if personal value is the empty string.'));

  // Default timeout used if personal timeout is empty string.
  variable_set('autologout_role_logout', TRUE);
  variable_set('autologout_role_2', FALSE);
  variable_set('autologout_role_2_timeout', 200);
  variable_set('autologout_user_' . $uid, '');
  $this
    ->assertAutotimeout($uid, 100, t('User timeout uses default value if personal value is the empty string and no role timeout is specified.'));

  // Personal timeout used if set.
  variable_set('autologout_role_logout', TRUE);
  variable_set('autologout_role_2', TRUE);
  variable_set('autologout_role_2_timeout', 200);
  variable_set('autologout_user_' . $uid, 300);
  $this
    ->assertAutotimeout($uid, 300, t('User timeout uses default value if personal value is the empty string and no role timeout is specified.'));
}