public function PasswordPolicyExpirationTestCase::testUnblockingExpiredAccountViaUserEditForm in Password Policy 7
Tests unblocking an expired account via user edit form.
File
- tests/
password_policy_expiration.test, line 196 - Tests for Password policy module expiration functionality.
Class
- PasswordPolicyExpirationTestCase
- Tests of password expiration.
Code
public function testUnblockingExpiredAccountViaUserEditForm() {
// Create an account to test with.
$account = $this
->drupalCreateUser();
$expiration_rid = $this
->assignToNewRole($account);
// Set 180-day expiration policy.
$expiration_days = 180;
$this
->setExpirationPolicy($expiration_days, $expiration_rid);
// Advance to at least one second past expiration.
$one_day = 24 * 60 * 60;
_password_policy_advance_test_clock($expiration_days * $one_day + 1);
// Run cron to trigger password expirations.
$this
->cronRun();
// Confirm account blocked.
$edit = array(
'name' => $account->name,
'pass' => $account->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' => $account->name,
)), 'Account blocked from logging in.');
// Unblock account using user edit form.
$admin = $this->admin;
$this
->drupalLogin($admin);
$edit = array(
'status' => 1,
);
$this
->drupalPost("user/{$account->uid}/edit", $edit, t('Save'));
$this
->drupalLogout();
// Run cron since it could errantly reblock account.
$this
->cronRun();
// Confirm account unblocked.
$edit = array(
'name' => $account->name,
'pass' => $account->pass_raw,
);
$this
->drupalPost('user/login', $edit, t('Log in'));
$this
->assertNoText(t('The username !name has not been activated or is blocked.', array(
'!name' => $account->name,
)), 'Account not blocked from logging in.');
}