You are here

public function SharedEmailTest::testCanDuplicateEmail in Shared Email 8.2

Test that a user with sufficient permission can duplicate email address.

File

tests/src/Functional/SharedEmailTest.php, line 137

Class

SharedEmailTest
Tests for the sharedemail module.

Namespace

Drupal\Tests\sharedemail\Functional

Code

public function testCanDuplicateEmail() {
  $this
    ->drupalLogin($this->user);

  // 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('Created a new user account for @name. No email has been sent.', [
    '@name' => $edit['name'],
  ]));
}