You are here

public function AutologoutTest::testAutologoutSettingsCache in Automated Logout 8

Tests that the settings update is reflected on cached front pages.

File

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

Class

AutologoutTest
Tests the autologout's features.

Namespace

Drupal\Tests\autologout\Functional

Code

public function testAutologoutSettingsCache() {

  // Visit the user profile page to cache it and test JS timeout variable.
  $this
    ->drupalGet('user');
  $jsSettings = $this
    ->getDrupalSettings();
  $this
    ->assertEquals(10000, $jsSettings['autologout']['timeout']);

  // Update the timeout variable and reload the user profile page.
  $autologout_settings = $this->configFactory
    ->getEditable('autologout.settings');
  $autologout_settings
    ->set('timeout', 5)
    ->save();
  $this
    ->drupalGet('user');

  // Test that the JS timeout variable is updated.
  $jsSettings = $this
    ->getDrupalSettings();
  $this
    ->assertEquals(5000, $jsSettings['autologout']['timeout']);
}