diff --git a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/UniqueFieldValueValidator.php b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/UniqueFieldValueValidator.php index 7f51054..6fbf559 100644 --- a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/UniqueFieldValueValidator.php +++ b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/UniqueFieldValueValidator.php @@ -7,6 +7,7 @@ namespace Drupal\Core\Validation\Plugin\Validation\Constraint; +use Drupal\Component\Utility\Unicode; use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; @@ -40,7 +41,7 @@ public function validate($items, Constraint $constraint) { $this->context->addViolation($constraint->message, [ '%value' => $item->value, '%entity_type' => $entity->getEntityType()->getLowercaseLabel(), - '%field_name' => $items->getFieldDefinition()->getLabel(), + '%field_name' => Unicode::strtolower($items->getFieldDefinition()->getLabel()), ]); } } diff --git a/core/modules/user/src/Tests/UserEditTest.php b/core/modules/user/src/Tests/UserEditTest.php index 46502f4..8883381 100644 --- a/core/modules/user/src/Tests/UserEditTest.php +++ b/core/modules/user/src/Tests/UserEditTest.php @@ -28,7 +28,7 @@ function testUserEdit() { // Test that error message appears when attempting to use a non-unique user name. $edit['name'] = $user2->getUsername(); $this->drupalPostForm("user/" . $user1->id() . "/edit", $edit, t('Save')); - $this->assertRaw(t('The username %name is already taken.', array('%name' => $edit['name']))); + $this->assertRaw(t('The user with the name %name already exists.', array('%name' => $edit['name']))); // Check that filling out a single password field does not validate. $edit = array(); diff --git a/core/modules/user/src/Tests/UserRegistrationTest.php b/core/modules/user/src/Tests/UserRegistrationTest.php index ff3fa30..e7ee6f3 100644 --- a/core/modules/user/src/Tests/UserRegistrationTest.php +++ b/core/modules/user/src/Tests/UserRegistrationTest.php @@ -141,13 +141,13 @@ function testRegistrationEmailDuplicates() { // Attempt to create a new account using an existing email address. $this->drupalPostForm('user/register', $edit, t('Create new account')); - $this->assertText(t('The email address @email is already taken.', array('@email' => $duplicate_user->getEmail())), 'Supplying an exact duplicate email address displays an error message'); + $this->assertText(t('The user with the email @email already exists.', array('@email' => $duplicate_user->getEmail())), 'Supplying an exact duplicate email address displays an error message'); // Attempt to bypass duplicate email registration validation by adding spaces. $edit['mail'] = ' ' . $duplicate_user->getEmail() . ' '; $this->drupalPostForm('user/register', $edit, t('Create new account')); - $this->assertText(t('The email address @email is already taken.', array('@email' => $duplicate_user->getEmail())), 'Supplying a duplicate email address with added whitespace displays an error message'); + $this->assertText(t('The user with the email @email already exists.', array('@email' => $duplicate_user->getEmail())), 'Supplying a duplicate email address with added whitespace displays an error message'); } function testRegistrationDefaultValues() { diff --git a/core/modules/user/src/Tests/UserValidationTest.php b/core/modules/user/src/Tests/UserValidationTest.php index ec44a79..c6512f1 100644 --- a/core/modules/user/src/Tests/UserValidationTest.php +++ b/core/modules/user/src/Tests/UserValidationTest.php @@ -102,7 +102,7 @@ function testValidation() { $violations = $user->validate(); $this->assertEqual(count($violations), 1, 'Violation found on name collision.'); $this->assertEqual($violations[0]->getPropertyPath(), 'name'); - $this->assertEqual($violations[0]->getMessage(), t('The username %name is already taken.', array('%name' => 'existing'))); + $this->assertEqual($violations[0]->getMessage(), t('The user with the name %name already exists.', array('%name' => 'existing'))); // Make the name valid. $user->set('name', $this->randomMachineName()); @@ -131,7 +131,7 @@ function testValidation() { $violations = $user->validate(); $this->assertEqual(count($violations), 1, 'Violation found when email already exists.'); $this->assertEqual($violations[0]->getPropertyPath(), 'mail'); - $this->assertEqual($violations[0]->getMessage(), t('The email address %mail is already taken.', array('%mail' => 'existing@example.com'))); + $this->assertEqual($violations[0]->getMessage(), t('The user with the email %mail already exists.', array('%mail' => 'existing@example.com'))); $user->set('mail', NULL); $violations = $user->validate(); $this->assertEqual(count($violations), 1, 'E-mail addresses may not be removed');