You are here

public function EmailRegistrationLoginTest::testFailedLoginWithUsername in Email Registration 8

Tests if an user cannot login with their username when that is forbidden.

Thus when the option 'login_with_username' is disabled.

File

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

Class

EmailRegistrationLoginTest
Tests the login checkout pane.

Namespace

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

Code

public function testFailedLoginWithUsername() {

  // 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', FALSE)
    ->save();
  $this
    ->goToCheckout();
  $this
    ->assertCheckoutProgressStep('Login');
  $this
    ->assertSession()
    ->pageTextContains('Enter your email address.');
  $edit = [
    'email_registration_login[returning_customer][name]' => $account
      ->getAccountName(),
    'email_registration_login[returning_customer][password]' => $account->passRaw,
  ];
  $this
    ->submitForm($edit, 'Log in');
  $this
    ->assertSession()
    ->pageTextContains('Unrecognized email address or password. Forgot your password?');
}