You are here

public function PasswordPolicyExpirationTestCase::testAdminExpirationEnabled in Password Policy 7

Tests "Admin (UID=1) password expires" being enabled (i.e., checked).

This is the default setting.

File

tests/password_policy_expiration.test, line 333
Tests for Password policy module expiration functionality.

Class

PasswordPolicyExpirationTestCase
Tests of password expiration.

Code

public function testAdminExpirationEnabled() {

  // Set an expiration policy.
  $expiration_days = 30;
  $this
    ->setExpirationPolicy($expiration_days);
  $this
    ->cronRun();

  // Advance to at least one second past expiration.
  $one_day = 24 * 60 * 60;
  _password_policy_advance_test_clock($expiration_days * $one_day + 1);
  $this
    ->cronRun();

  // Attempt login as admin and confirm password expired.
  $admin = $this->admin;
  $edit = array(
    'name' => $admin->name,
    'pass' => $admin->pass_raw,
  );
  $this
    ->drupalPost('user/login', $edit, t('Log in'));
  $this
    ->assertText(t('The username !name has not been activated or is blocked.', array(
    '!name' => $admin->name,
  )), 'Admin blocked from logging in.');
}