You are here

public function AutologoutTest::setUp in Automated Logout 8

Performs any pre-requisite tasks that need to happen.

Overrides BrowserTestBase::setUp

File

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

Class

AutologoutTest
Tests the autologout's features.

Namespace

Drupal\Tests\autologout\Functional

Code

public function setUp() {
  parent::setUp();

  // Create and log in our privileged user.
  $this->privilegedUser = $this
    ->drupalCreateUser([
    'access content',
    'administer site configuration',
    'access site reports',
    'access administration pages',
    'bypass node access',
    'administer content types',
    'administer nodes',
    'administer autologout',
    'change own logout threshold',
    'access site reports',
    'view the administration theme',
  ]);
  $this->configFactory = $this->container
    ->get('config.factory');
  $this->userData = $this->container
    ->get('user.data');

  // For the purposes of the test, set the timeout periods to 10 seconds.
  $this->configFactory
    ->getEditable('autologout.settings')
    ->set('timeout', 10)
    ->set('padding', 0)
    ->save();

  // Make node page default.
  $this->configFactory
    ->getEditable('system.site')
    ->set('page.front', 'node')
    ->save();
  $this
    ->drupalLogin($this->privilegedUser);
}