function UserEditTest::testUserWithoutEmailEdit

Same name and namespace in other branches
  1. 9 core/modules/user/tests/src/Functional/UserEditTest.php \Drupal\Tests\user\Functional\UserEditTest::testUserWithoutEmailEdit()
  2. 8.9.x core/modules/user/tests/src/Functional/UserEditTest.php \Drupal\Tests\user\Functional\UserEditTest::testUserWithoutEmailEdit()
  3. 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 166

Class

UserEditTest
Tests user edit page.

Namespace

Drupal\Tests\user\Functional

Code

public function testUserWithoutEmailEdit() : void {
  // 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.");
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.