You are here

public function sessionCookieLifetimeTestCase::testLifetimeTimebased in Session cookie lifetime 7

Test time based session cookie functionality.

File

tests/session_cookie_lifetime.test, line 41

Class

sessionCookieLifetimeTestCase

Code

public function testLifetimeTimebased() {
  $this
    ->drupalLogin($this->adminUser);
  $number_of_days = rand(10, 1000);
  $post = array(
    'session_cookie_lifetime_type' => 'time',
    'session_cookie_lifetime_amount' => $number_of_days,
    // Days.
    'session_cookie_lifetime_multiplier' => 60 * 60 * 24,
  );
  $this
    ->drupalPost('admin/config/system/session_cookie_lifetime', $post, t('Save configuration'));
  $this
    ->drupalLogout();
  $this
    ->drupalLogin($this->adminUser);
  $expiry_time = $number_of_days * 60 * 60 * 24;
  $this
    ->assertSessionExpiry($expiry_time, t('Expires tag is set to !amount days', array(
    '!amount' => $number_of_days,
  )));
}