You are here

public function UserAccountFormFieldsTest::testUserEditForm in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/user/tests/src/Kernel/UserAccountFormFieldsTest.php \Drupal\Tests\user\Kernel\UserAccountFormFieldsTest::testUserEditForm()

Tests the user edit form.

File

core/modules/user/tests/src/Kernel/UserAccountFormFieldsTest.php, line 72

Class

UserAccountFormFieldsTest
Verifies that the field order in user account forms is compatible with password managers of web browsers.

Namespace

Drupal\Tests\user\Kernel

Code

public function testUserEditForm() {

  // Install default configuration; required for AccountFormController.
  $this
    ->installConfig([
    'user',
  ]);
  $form = $this
    ->buildAccountForm('default');

  // Verify name and pass field order.
  $this
    ->assertFieldOrder($form['account']);

  // Verify that autocomplete is off on all account fields.
  foreach ([
    'mail',
    'name',
    'pass',
  ] as $key) {
    $this
      ->assertSame('off', $form['account'][$key]['#attributes']['autocomplete'], "'{$key}' field: 'autocomplete' attribute is 'off'.");
  }
}