function UserAccountFormFieldsTest::testUserEditForm

Same name in other branches
  1. 8.9.x core/modules/user/tests/src/Kernel/UserAccountFormFieldsTest.php \Drupal\Tests\user\Kernel\UserAccountFormFieldsTest::testUserEditForm()
  2. 10 core/modules/user/tests/src/Kernel/UserAccountFormFieldsTest.php \Drupal\Tests\user\Kernel\UserAccountFormFieldsTest::testUserEditForm()
  3. 11.x 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 71

Class

UserAccountFormFieldsTest
Verifies the field order in user account forms.

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'.");
    }
}

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