You are here

public function PasswordPolicyUITestCase::testRegistration in Password Policy 7.2

Tests password policy enforcement on registration.

File

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

Class

PasswordPolicyUITestCase
Test case to verify accuracy of each available policy condition.

Code

public function testRegistration() {

  // Create strong policy.
  $this
    ->createStrongPolicy();

  // Don't require e-mail verification.
  variable_set('user_email_verification', FALSE);

  // Allow registration by site visitors without administrator approval.
  variable_set('user_register', USER_REGISTER_VISITORS);
  $edit = array();
  $edit['name'] = $this
    ->randomName();
  $edit['mail'] = $edit['name'] . '@example.com';

  // Try a weak password.
  $edit['pass[pass1]'] = 'pass';
  $edit['pass[pass2]'] = 'pass';
  $this
    ->drupalPost('user/register', $edit, t('Create new account'));
  $this
    ->assertText('Password must have at least 1 digit(s).');
  $this
    ->assertText('Password must have at least 8 character(s).');
}