You are here

public function UserRegistrationPassword::testPasswordResetFormResendActivation in User registration password 8

Implements testPasswordResetFormResendActivation().

File

tests/src/Functional/UserRegistrationPassword.php, line 118

Class

UserRegistrationPassword
Functionality tests for User registration password module.

Namespace

Drupal\Tests\user_registrationpassword\Functional

Code

public function testPasswordResetFormResendActivation() {

  // 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
    ->assertSession()
    ->pageTextContains('A welcome message with further instructions has been sent to your email address.');

  // Request a new activation email.
  $edit2 = [];
  $edit2['name'] = $edit1['name'];
  $this
    ->drupalPostForm('user/password', $edit2, 'Submit');
  $this
    ->assertSession()
    ->pageTextContains('Further instructions have been sent to your email address.');

  // Request a new activation email for a non-existing user name.
  $edit3 = [];
  $edit3['name'] = $this
    ->randomMachineName();
  $this
    ->drupalPostForm('user/password', $edit3, 'Submit');
  $this
    ->assertSession()
    ->pageTextContains($edit3['name'] . ' is not recognized as a username or an email address.');

  // Request a new activation email for a non-existing user email.
  $edit4 = [];
  $edit4['name'] = $this
    ->randomMachineName() . '@example.com';
  $this
    ->drupalPostForm('user/password', $edit4, 'Submit');
  $this
    ->assertSession()
    ->pageTextContains($edit4['name'] . ' is not recognized as a username or an email address.');
}