You are here

public function PasswordPolicyForcePasswordChangeTestCase::testForms in Password Policy 6

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

File

tests/password_policy.test, line 295
Unit tests for Password policy module.

Class

PasswordPolicyForcePasswordChangeTestCase

Code

public function testForms() {

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

  // test user edit form with perms
  $this
    ->drupalGet("user/{$user->uid}/edit");
  $this
    ->assertFieldByName('force_password_change', '', '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', '', 'Force password change checkbox is hidden for normal users.');
  $this
    ->drupalLogout();
}