You are here

public function AutologoutTestCase::testAutologoutDefaultTimeoutAccessDeniedToAdmin in Automated Logout 7.4

Same name and namespace in other branches
  1. 6.4 tests/autologout.test \AutologoutTestCase::testAutologoutDefaultTimeoutAccessDeniedToAdmin()

Test a user is logged out and denied access to admin pages.

File

tests/autologout.test, line 419
Simpletest tests for autologout.

Class

AutologoutTestCase
Tests the autologout's features.

Code

public function testAutologoutDefaultTimeoutAccessDeniedToAdmin() {

  // Enforce auto logout of admin pages.
  variable_set('autologout_enforce_admin', TRUE);

  // Check that the user can access the page after login.
  $this
    ->drupalGet('admin/reports/status');
  $this
    ->assertResponse(200, t('Admin page is accessible'));
  $this
    ->assertText(t('Log out'), t('User is still logged in.'));
  $this
    ->assertText(t("Here you can find a short overview of your site's parameters as well as any problems detected with your installation."), t('User can access elements of the admin page.'));

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

  // Check we are now logged out.
  $this
    ->drupalGet('admin/reports/status');
  $this
    ->assertResponse(403, t('Admin page returns 403 access denied.'));
  $this
    ->assertNoText(t('Log out'), t('User is no longer logged in.'));
  $this
    ->assertNoText(t("Here you can find a short overview of your site's parameters as well as any problems detected with your installation."), t('User cannot access elements of the admin page.'));
  $this
    ->assertText(t('You have been logged out due to inactivity.'), t('User sees inactivity message.'));
}