You are here

public function UserEditTest::testUserWithoutEmailEdit in Drupal 8

Same name and namespace in other branches
  1. 9 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 146

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
    ->drupalPostForm("user/" . $user1
    ->id() . "/edit", [
    'mail' => '',
  ], t('Save'));
  $this
    ->assertRaw(t("The changes have been saved."));
}