You are here

public function EmailTest::editUserWithAlreadyExistingEmailTest in Apigee Edge 8

Tests changing user's email to an already existing email address in Edge.

1 call to EmailTest::editUserWithAlreadyExistingEmailTest()
EmailTest::testEmailValidator in tests/src/Functional/EmailTest.php
Tests developer email already exists in Apigee Edge.

File

tests/src/Functional/EmailTest.php, line 93

Class

EmailTest
Developer email already exists in Apigee Edge related tests.

Namespace

Drupal\Tests\apigee_edge\Functional

Code

public function editUserWithAlreadyExistingEmailTest() {

  // Create a new user in Drupal. It is not necessary to create a developer
  // for this user, so skip apigee_edge_user_presave().
  $this
    ->disableUserPresave();
  $account = $this
    ->createAccount();
  $this
    ->enableUserPresave();
  $this
    ->drupalLogin($account);

  // Stack developer response.
  $this
    ->queueDeveloperResponseFromDeveloper($this->developer);
  $this
    ->drupalPostForm(Url::fromRoute('entity.user.edit_form', [
    'user' => $account
      ->id(),
  ]), [
    'mail' => $this->developer
      ->getEmail(),
    'current_pass' => $account->passRaw,
  ], 'Save');
  $this
    ->assertSession()
    ->pageTextContains('This email address already exists in our system. You can register a new account if you would like to use it on the Developer Portal.');
  $this
    ->drupalLogin($this->rootUser);
  $this
    ->drupalPostForm(Url::fromRoute('entity.user.edit_form', [
    'user' => $account
      ->id(),
  ]), [
    'mail' => $this->developer
      ->getEmail(),
  ], 'Save');
  $this
    ->assertSession()
    ->pageTextContains('This email address already belongs to a developer on Apigee Edge.');
}