You are here

public function AutologoutTest::testAutologoutDefaultTimeout in Automated Logout 8

Tests a user is logged out after the default timeout period.

File

tests/src/Functional/AutologoutTest.php, line 93

Class

AutologoutTest
Tests the autologout's features.

Namespace

Drupal\Tests\autologout\Functional

Code

public function testAutologoutDefaultTimeout() {

  // Check that the user can access the page after login.
  $this
    ->drupalGet('node');
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  self::assertTrue($this
    ->drupalUserIsLoggedIn($this->privilegedUser));

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

  // Check we are now logged out.
  $this
    ->drupalGet('node');
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  self::assertFalse($this
    ->drupalUserIsLoggedIn($this->privilegedUser));
}