You are here

public function UserRegistrationPasswordUserPasswordResetForm::testUserRegistrationPasswordUserPasswordResetForm in User registration password 8

Implements testUserRegistrationPasswordUserPasswordResetForm().

File

tests/src/Functional/UserRegistrationPasswordUserPasswordResetForm.php, line 45

Class

UserRegistrationPasswordUserPasswordResetForm
Functionality tests for User registration password module privacy feature.

Namespace

Drupal\Tests\user_registrationpassword\Functional

Code

public function testUserRegistrationPasswordUserPasswordResetForm() {

  // Register a new account.
  $edit1 = [];
  $edit1['name'] = $this
    ->randomMachineName();
  $edit1['mail'] = $edit1['name'] . '@example.com';
  $edit1['pass[pass1]'] = $new_pass = $this
    ->randomMachineName();
  $edit1['pass[pass2]'] = $new_pass;
  $this
    ->drupalPostForm('user/register', $edit1, 'Create new account');
  $this
    ->assertText('A welcome message with further instructions has been sent to your email address.', 'User registered successfully.');

  // Request a new activation email.
  $edit2 = [];
  $edit2['name'] = $edit1['name'];
  $this
    ->drupalPostForm('user/password', $edit2, 'Submit');
  $this
    ->assertText('Further instructions have been sent to your email address.', 'Password reset form submitted successfully.');
  $_emails = $this
    ->getMails();
  $email = end($_emails);
  $this
    ->assertNotEmpty($email['subject']);
  $this
    ->assertNotEmpty($email['body']);
  $this
    ->assertNotEqual($email['send'], 0);
}