function UserAccountFormFieldsTest::testUserEditForm

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

Class

UserAccountFormFieldsTest
Verifies the field order in user account forms.

Namespace

Drupal\Tests\user\Kernel

Code

public function testUserEditForm() : void {
    // Install default configuration; required for AccountFormController.
    $this->installConfig([
        'user',
    ]);
    $this->installEntitySchema('user');
    $this->user = User::create([
        'name' => 'test',
    ]);
    $this->user
        ->save();
    $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.