You are here

public function EmailRegistrationLoginTest::testFailedLoginWithMailAddressWhenUsernameIsAllowed in Email Registration 8

Tests failed login using mail when logging in with username is allowed.

When the option 'login_with_username' is enabled and trying to login with an existing mail address, the error message should say "Unrecognized username or password."

File

tests/src/Functional/Plugin/Commerce/CheckoutPane/EmailRegistrationLoginTest.php, line 197

Class

EmailRegistrationLoginTest
Tests the login checkout pane.

Namespace

Drupal\Tests\email_registration\Functional\Plugin\Commerce\CheckoutPane

Code

public function testFailedLoginWithMailAddressWhenUsernameIsAllowed() {

  // Create an user to login with.
  $account = $this
    ->drupalCreateUser();

  // Don't allow users to login with their username.
  $this
    ->config('email_registration.settings')
    ->set('login_with_username', TRUE)
    ->save();
  $this
    ->goToCheckout();
  $this
    ->assertCheckoutProgressStep('Login');
  $edit = [
    'email_registration_login[returning_customer][name]' => $account
      ->getEmail(),
    'email_registration_login[returning_customer][password]' => $account->passRaw . 'foo',
  ];
  $this
    ->submitForm($edit, 'Log in');
  $this
    ->assertSession()
    ->pageTextContains('Unrecognized username, email, or password. Have you forgotten your password?');
}