You are here

public function UserPasswordResetTest::testUserResetPasswordTextboxFilled in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/user/src/Tests/UserPasswordResetTest.php \Drupal\user\Tests\UserPasswordResetTest::testUserResetPasswordTextboxFilled()

Prefill the text box on incorrect login via link to password reset page.

File

core/modules/user/src/Tests/UserPasswordResetTest.php, line 216
Contains \Drupal\user\Tests\UserPasswordResetTest.

Class

UserPasswordResetTest
Ensure that password reset methods work as expected.

Namespace

Drupal\user\Tests

Code

public function testUserResetPasswordTextboxFilled() {
  $this
    ->drupalGet('user/login');
  $edit = array(
    'name' => $this
      ->randomMachineName(),
    'pass' => $this
      ->randomMachineName(),
  );
  $this
    ->drupalPostForm('user/login', $edit, t('Log in'));
  $this
    ->assertRaw(t('Unrecognized username or password. <a href=":password">Have you forgotten your password?</a>', array(
    ':password' => \Drupal::url('user.pass', [], array(
      'query' => array(
        'name' => $edit['name'],
      ),
    )),
  )));
  unset($edit['pass']);
  $this
    ->drupalGet('user/password', array(
    'query' => array(
      'name' => $edit['name'],
    ),
  ));
  $this
    ->assertFieldByName('name', $edit['name'], 'User name found.');
}