1.20.x user.test UserRegistrationTestCase::testRegistrationEmailAsUsernameDisabled()

Tests new users username not matching their email if username is an email.

File

modules/user/tests/user.test, line 356
Tests for user.module.

Class

UserRegistrationTestCase

Code

function testRegistrationEmailAsUsernameDisabled() {
  // Test that 'user_email_match' turned off allows emails that don't match.
  config('system.core')
    ->set('user_email_match', FALSE)
    ->set('user_email_verification', FALSE)
    ->set('user_register', USER_REGISTER_VISITORS)
    ->save();

  $mail = $this->randomName() . '@example.com';
  $different = $this->randomName() . $mail;

  $edit = array();
  $edit['mail'] = $mail;
  $edit['name'] = $different;
  $edit['pass'] = $this->randomName();

  // Attempt to create an account using an email that doesn't match the name.
  // This should be OK, as 'user_email_match' is disabled.
  $this->backdropPost('user/register', $edit, t('Create new account'));
  $this->assertNoText(t('An email address was provided as a username, but does not match the account email address.'), 'Email username does not match user email - error message found.');
  $this->assertText(t('Registration successful. You are now logged in.'), 'The user was not created and logged in.');
}