diff --git a/core/modules/user/src/AccountForm.php b/core/modules/user/src/AccountForm.php index b7c8723..e86e980 100644 --- a/core/modules/user/src/AccountForm.php +++ b/core/modules/user/src/AccountForm.php @@ -351,7 +351,7 @@ public function validate(array $form, FormStateInterface $form_state) { // Check whether the user name provided is an email address, if so, make // sure it matches the mail value. if (\Drupal::config('user.settings')->get('verify_email_match') && (filter_var($name, FILTER_VALIDATE_EMAIL) && ($name !== $mail))) { - $this->setFormError('name', $form_state, $this->t('You have provided an e-mail address as a username, but this does not match your e-mail address.')); + $this->setFormError('name', $form_state, $this->t('You have provided an email address as a username, but this does not match your email address.')); } } } diff --git a/core/modules/user/src/AccountSettingsForm.php b/core/modules/user/src/AccountSettingsForm.php index 34065b8..4e60dd4 100644 --- a/core/modules/user/src/AccountSettingsForm.php +++ b/core/modules/user/src/AccountSettingsForm.php @@ -134,7 +134,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { ); $form['registration_cancellation']['user_email_match_verification'] = array( '#type' => 'checkbox', - '#title' => $this->t('When an e-mail address is used as username, require a matching e-mail address.'), + '#title' => $this->t('When an email address is used as username, require a matching email address.'), '#default_value' => $config->get('verify_email_match'), ); $form['registration_cancellation']['user_password_strength'] = array( diff --git a/core/modules/user/src/Tests/UserEditedOwnAccountTest.php b/core/modules/user/src/Tests/UserEditedOwnAccountTest.php index 285f6fd..5934db8 100644 --- a/core/modules/user/src/Tests/UserEditedOwnAccountTest.php +++ b/core/modules/user/src/Tests/UserEditedOwnAccountTest.php @@ -16,7 +16,10 @@ */ class UserEditedOwnAccountTest extends WebTestBase { - function testUserEditedOwnAccount() { + /** + * Tests a user editing their own account. + */ + public function testUserEditedOwnAccount() { // Change account setting 'Who can register accounts?' to Administrators // only. \Drupal::config('user.settings')->set('register', USER_REGISTER_ADMINISTRATORS_ONLY)->save(); @@ -38,9 +41,9 @@ function testUserEditedOwnAccount() { $this->drupalLogin($account); // Attempt to change username to an email other than my own. - $edit['name'] = $this->randomName() . '@example.com'; + $edit['name'] = $this->randomMachineName() . '@example.com'; $this->drupalPostForm('user/' . $account->id() . '/edit', $edit, t('Save')); - $this->assertText(t('You have provided an e-mail address as a username, but this does not match your e-mail address.'), 'Error message found when an email username does not match user email.'); + $this->assertText(t('You have provided an email address as a username, but this does not match your email address.'), 'Error message found when an email username does not match user email.'); $this->assertNoText(t('The changes have been saved.'), 'The user account was not saved.'); // Lookup user by name to make sure we didn't actually change the name. @@ -56,7 +59,7 @@ function testUserEditedOwnAccount() { \Drupal::config('user.settings')->set('verify_email_match', FALSE)->save(); // Change username to my email address. - $edit['name'] = $this->randomName() . '@example.com'; + $edit['name'] = $this->randomMachineName() . '@example.com'; $this->drupalPostForm('user/' . $account->id() . '/edit', $edit, t('Save')); $this->assertText(t('The changes have been saved.'), 'The user account was saved.'); } diff --git a/core/modules/user/src/Tests/UserRegistrationTest.php b/core/modules/user/src/Tests/UserRegistrationTest.php index 2c1d8b2..158fae8 100644 --- a/core/modules/user/src/Tests/UserRegistrationTest.php +++ b/core/modules/user/src/Tests/UserRegistrationTest.php @@ -150,7 +150,7 @@ function testRegistrationEmailDuplicates() { /** * Tests new users username matches their email if username is an email. */ - function testRegistrationEmailAsUsername() { + public function testRegistrationEmailAsUsername() { // Don't require e-mail verification. // Allow registration by site visitors without administrator approval. \Drupal::config('user.settings') @@ -158,14 +158,14 @@ function testRegistrationEmailAsUsername() { ->set('register', USER_REGISTER_VISITORS) ->save(); - $mail = $this->randomName() . '@example.com'; - $different = $this->randomName() . $mail; + $mail = $this->randomMachineName() . '@example.com'; + $different = $this->randomMachineName() . $mail; // Set up edit array. $edit = array(); $edit['mail'] = $mail; $edit['name'] = $different; - $edit['pass[pass1]'] = $edit['pass[pass2]'] = $this->randomName(); + $edit['pass[pass1]'] = $edit['pass[pass2]'] = $this->randomMachineName(); // Attempt to create an account using an email that doesn't match the name. $this->drupalPostForm('user/register', $edit, t('Create new account')); @@ -173,7 +173,7 @@ function testRegistrationEmailAsUsername() { $this->assertNoText(t('Registration successful. You are now logged in.'), 'The user was not created and logged in.'); // Attempt to create new account using matching email address. - $edit['name'] = $edit['mail'] = $this->randomName() . '@example.com'; + $edit['name'] = $edit['mail'] = $this->randomMachineName() . '@example.com'; $this->drupalPostForm('user/register', $edit, t('Create new account')); $this->assertText(t('Registration successful. You are now logged in.'), 'The user was created and logged in with matching email.'); @@ -186,7 +186,7 @@ function testRegistrationEmailAsUsername() { /** * Tests new users username not matching their email if username is an email. */ - function testRegistrationEmailAsUsernameDisabled() { + public function testRegistrationEmailAsUsernameDisabled() { // Test that 'verify_email_match' turned off allows emails that don't match. \Drupal::config('user.settings') ->set('verify_email_match', FALSE) @@ -194,13 +194,13 @@ function testRegistrationEmailAsUsernameDisabled() { ->set('register', USER_REGISTER_VISITORS) ->save(); - $mail = $this->randomName() . '@example.com'; - $different = $this->randomName() . $mail; + $mail = $this->randomMachineName() . '@example.com'; + $different = $this->randomMachineName() . $mail; $edit = array(); $edit['mail'] = $mail; $edit['name'] = $different; - $edit['pass[pass1]'] = $edit['pass[pass2]'] = $this->randomName(); + $edit['pass[pass1]'] = $edit['pass[pass2]'] = $this->randomMachineName(); // Attempt to create an account using an email that doesn't match the name. // This should be OK, as 'verify_email_match' is disabled.