public function UserRegistrationPasswordTestCase::testPasswordResetFormResendActivation in User registration password 7
Implements testPasswordResetFormResendActivation().
File
- tests/
user_registrationpassword.test, line 136  - Functionality tests for user_registrationpassword.module.
 
Class
- UserRegistrationPasswordTestCase
 - Class UserRegistrationPasswordTestCase.
 
Code
public function testPasswordResetFormResendActivation() {
  // Allow registration by site visitors without administrator
  // approval and set password during registration.
  variable_set('user_register', USER_REGISTER_VISITORS);
  // Disable e-mail verification.
  variable_set('user_email_verification', FALSE);
  // Prevent standard notification email to administrators and to user.
  variable_set('user_mail_register_pending_approval_notify', FALSE);
  // Set the registration variable to 2, register with pass, but require
  // confirmation.
  variable_set('user_registrationpassword_registration', USER_REGISTRATIONPASSWORD_VERIFICATION_PASS);
  // Register a new account.
  $edit1 = array();
  $edit1['name'] = $name = $this
    ->randomName();
  $edit1['mail'] = $mail = $edit1['name'] . '@example.com';
  $edit1['pass[pass1]'] = $new_pass = $this
    ->randomName();
  $edit1['pass[pass2]'] = $new_pass;
  $pass = $new_pass;
  $this
    ->drupalPost('user/register', $edit1, t('Create new account'));
  $this
    ->assertText(t('A welcome message with further instructions has been sent to your e-mail address.'), t('User registered successfully.'));
  // Load the new user.
  $accounts = user_load_multiple(array(), array(
    'name' => $name,
    'mail' => $mail,
    'status' => 0,
  ));
  $account = reset($accounts);
  // Request a new activation e-mail.
  $edit2 = array();
  $edit2['name'] = $edit1['name'];
  $this
    ->drupalPost('user/password', $edit2, t('E-mail new password'));
  $this
    ->assertText(t('Further instructions have been sent to your e-mail address.'), t('Password rest form submitted successfully.'));
  // Request a new activation e-mail for a non-existing user name.
  $edit3 = array();
  $edit3['name'] = $this
    ->randomName();
  $this
    ->drupalPost('user/password', $edit3, t('E-mail new password'));
  $this
    ->assertText(t('Sorry, !name is not recognized as a user name or an e-mail address.', array(
    '!name' => $edit3['name'],
  )), t('Password rest form failed correctly.'));
  // Request a new activation e-mail for a non-existing user e-mail.
  $edit4 = array();
  $edit4['name'] = $this
    ->randomName() . '@example.com';
  $this
    ->drupalPost('user/password', $edit4, t('E-mail new password'));
  $this
    ->assertText(t('Sorry, !mail is not recognized as a user name or an e-mail address.', array(
    '!mail' => $edit4['name'],
  )), t('Password rest form failed correctly.'));
}