public function UserRegistrationTest::testRegistrationEmailDuplicates in Drupal 8
Same name and namespace in other branches
- 9 core/modules/user/tests/src/Functional/UserRegistrationTest.php \Drupal\Tests\user\Functional\UserRegistrationTest::testRegistrationEmailDuplicates()
File
- core/modules/user/tests/src/Functional/UserRegistrationTest.php, line 138
Class
- UserRegistrationTest
- Tests registration of user under different configurations.
Namespace
Drupal\Tests\user\Functional
Code
public function testRegistrationEmailDuplicates() {
$this
->config('user.settings')
->set('verify_mail', FALSE)
->set('register', UserInterface::REGISTER_VISITORS)
->save();
$duplicate_user = $this
->drupalCreateUser();
$edit = [];
$edit['name'] = $this
->randomMachineName();
$edit['mail'] = $duplicate_user
->getEmail();
$this
->drupalPostForm('user/register', $edit, t('Create new account'));
$this
->assertText(t('The email address @email is already taken.', [
'@email' => $duplicate_user
->getEmail(),
]), 'Supplying an exact duplicate email address displays an error message');
$edit['mail'] = ' ' . $duplicate_user
->getEmail() . ' ';
$this
->drupalPostForm('user/register', $edit, t('Create new account'));
$this
->assertText(t('The email address @email is already taken.', [
'@email' => $duplicate_user
->getEmail(),
]), 'Supplying a duplicate email address with added whitespace displays an error message');
}