You are here

public function AutologoutTest::testCustomMessage in Automated Logout 8

Tests the behaviour of custom message displayed on autologout.

File

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

Class

AutologoutTest
Tests the autologout's features.

Namespace

Drupal\Tests\autologout\Functional

Code

public function testCustomMessage() {
  $autologout_settings = $this->configFactory
    ->getEditable('autologout.settings');
  $inactivity_message = 'Custom message for test';

  // Update message string in configuration.
  $autologout_settings
    ->set('inactivity_message', $inactivity_message)
    ->save();

  // Set time out for 5 seconds.
  $autologout_settings
    ->set('timeout', 5)
    ->save();

  // Wait for 20 seconds for timeout.
  sleep(20);

  // Access the admin page and verify user is logged out and custom message
  // is displayed.
  $this
    ->drupalGet('admin/reports/status');
  self::assertFalse($this
    ->drupalUserIsLoggedIn($this->privilegedUser));
  $this
    ->assertSession()
    ->pageTextContains($inactivity_message);
}