public function AutologoutTest::testAutologoutAdminPages in Automated Logout 8
Tests the behaviour of application when Autologout is enabled for admin.
File
- tests/
src/ Functional/ AutologoutTest.php, line 222
Class
- AutologoutTest
- Tests the autologout's features.
Namespace
Drupal\Tests\autologout\FunctionalCode
public function testAutologoutAdminPages() {
$autologout_settings = $this->configFactory
->getEditable('autologout.settings');
// Enforce auto logout of admin pages.
$autologout_settings
->set('enforce_admin', TRUE)
->save();
// Set time out as 5 seconds.
$autologout_settings
->set('timeout', 5)
->save();
// Verify admin should not be logged out.
$this
->drupalGet('admin/reports/status');
$this
->assertSession()
->statusCodeEquals('200');
// Wait until timeout.
sleep(20);
// Verify admin should be logged out.
$this
->drupalGet('admin/reports/status');
self::assertFalse($this
->drupalUserIsLoggedIn($this->privilegedUser));
$this
->assertSession()
->pageTextContains($this
->t('You have been logged out due to inactivity.'));
}