You are here

public function UserEditTest::testUserWithoutEmailEdit in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/user/tests/src/Functional/UserEditTest.php \Drupal\Tests\user\Functional\UserEditTest::testUserWithoutEmailEdit()
  2. 10 core/modules/user/tests/src/Functional/UserEditTest.php \Drupal\Tests\user\Functional\UserEditTest::testUserWithoutEmailEdit()

Tests editing of a user account without an email address.

File

core/modules/user/tests/src/Functional/UserEditTest.php, line 163

Class

UserEditTest
Tests user edit page.

Namespace

Drupal\Tests\user\Functional

Code

public function testUserWithoutEmailEdit() {

  // Test that an admin can edit users without an email address.
  $admin = $this
    ->drupalCreateUser([
    'administer users',
  ]);
  $this
    ->drupalLogin($admin);

  // Create a regular user.
  $user1 = $this
    ->drupalCreateUser([]);

  // This user has no email address.
  $user1->mail = '';
  $user1
    ->save();
  $this
    ->drupalGet("user/" . $user1
    ->id() . "/edit");
  $this
    ->submitForm([
    'mail' => '',
  ], 'Save');
  $this
    ->assertSession()
    ->pageTextContains("The changes have been saved.");
}