You are here

public function EmailRegistrationLoginTest::testFailedLoginWithMailAddressWithBlockedUser in Email Registration 8

Tests trying to login in with an mail address belonging to a blocked user.

File

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

Class

EmailRegistrationLoginTest
Tests the login checkout pane.

Namespace

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

Code

public function testFailedLoginWithMailAddressWithBlockedUser() {

  // Create an user to login with.
  $account = $this
    ->drupalCreateUser();
  $account->status = FALSE;
  $account
    ->save();
  $this
    ->goToCheckout();
  $this
    ->assertCheckoutProgressStep('Login');

  // Try logging in with wrong pass first.
  $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('The account with email address ' . $account
    ->getEmail() . ' has not been activated or is blocked.');

  // Now try to login with right password. Same error message should come up.
  $edit = [
    'email_registration_login[returning_customer][name]' => $account
      ->getEmail(),
    'email_registration_login[returning_customer][password]' => $account->passRaw,
  ];
  $this
    ->submitForm($edit, 'Log in');
  $this
    ->assertSession()
    ->pageTextContains('The account with email address ' . $account
    ->getEmail() . ' has not been activated or is blocked.');
}