function UserRegistrationTest::testUniqueFields
Same name in other branches
- 8.9.x core/modules/user/tests/src/Functional/UserRegistrationTest.php \Drupal\Tests\user\Functional\UserRegistrationTest::testUniqueFields()
- 10 core/modules/user/tests/src/Functional/UserRegistrationTest.php \Drupal\Tests\user\Functional\UserRegistrationTest::testUniqueFields()
- 11.x core/modules/user/tests/src/Functional/UserRegistrationTest.php \Drupal\Tests\user\Functional\UserRegistrationTest::testUniqueFields()
Tests username and email field constraints on user registration.
See also
\Drupal\user\Plugin\Validation\Constraint\UserNameUnique
\Drupal\user\Plugin\Validation\Constraint\UserMailUnique
File
-
core/
modules/ user/ tests/ src/ Functional/ UserRegistrationTest.php, line 289
Class
- UserRegistrationTest
- Tests registration of user under different configurations.
Namespace
Drupal\Tests\user\FunctionalCode
public function testUniqueFields() {
$account = $this->drupalCreateUser();
$edit = [
'mail' => 'test@example.com',
'name' => $account->getAccountName(),
];
$this->drupalGet('user/register');
$this->submitForm($edit, 'Create new account');
$this->assertSession()
->pageTextContains("The username {$account->getAccountName()} is already taken.");
$edit = [
'mail' => $account->getEmail(),
'name' => $this->randomString(),
];
$this->drupalGet('user/register');
$this->submitForm($edit, 'Create new account');
$this->assertSession()
->pageTextContains("The email address {$account->getEmail()} is already taken.");
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.