You are here

public function PasswordPolicyForcePasswordChangeTestCase::testForms in Password Policy 7

Same name and namespace in other branches
  1. 6 tests/password_policy.test \PasswordPolicyForcePasswordChangeTestCase::testForms()

Tests form elements.

File

tests/password_policy.test, line 401
Functional tests for Password policy module.

Class

PasswordPolicyForcePasswordChangeTestCase
Tests of forcing password changes.

Code

public function testForms() {

  // Test admin form.
  $user = $this
    ->drupalCreateUser(array(
    'force password change',
    'administer users',
  ));
  $this
    ->drupalLogin($user);
  $this
    ->drupalGet('admin/config/people/password_policy/password_change');
  $this
    ->assertFieldByName('password_policy_new_login_change', NULL, 'Found first time login change checkbox.');
  $this
    ->assertFieldByName('password_policy_force_change_roles[2]', NULL, 'Found roles checkboxes.');
  $this
    ->assertFieldById('edit-submit', NULL, 'Found submit button.');

  // Test user edit form with perms.
  $this
    ->drupalGet("user/{$user->uid}/edit");
  $this
    ->assertFieldByName('force_password_change', NULL, 'Force password change checkbox is visible to admin.');
  $this
    ->drupalLogout();

  // Test user edit form without perms.
  $user = $this
    ->drupalCreateUser();
  $this
    ->drupalLogin($user);
  $this
    ->drupalGet("user/{$user->uid}/edit");
  $this
    ->assertNoFieldByName('force_password_change', NULL, 'Force password change checkbox is hidden for normal users.');
  $this
    ->drupalLogout();
}