public function SharedEmailTest::testCannotDuplicateEmail in Shared Email 8.2
Test that a user w/o sufficient permission cannot duplicate email address.
File
- tests/
src/ Functional/ SharedEmailTest.php, line 110
Class
- SharedEmailTest
- Tests for the sharedemail module.
Namespace
Drupal\Tests\sharedemail\FunctionalCode
public function testCannotDuplicateEmail() {
$notAllowedUser = $this
->drupalCreateUser([
'administer users',
]);
$this
->drupalLogin($notAllowedUser);
// Set up a user to check for duplicates.
$duplicateUser = $this
->drupalCreateUser();
$edit = [
'name' => $this
->randomMachineName(),
'mail' => $duplicateUser
->getEmail(),
'pass[pass1]' => 'Test1Password',
'pass[pass2]' => 'Test1Password',
];
// Attempt to create a new account using an existing email address.
$this
->drupalPostForm('admin/people/create', $edit, t('Create new account'));
$this
->assertSession()
->pageTextContains(t('The email address @email is already taken.', [
'@email' => $duplicateUser
->getEmail(),
]));
}