You are here

function UserAccountFormFieldsTest::testUserEditForm in Zircon Profile 8

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

Tests the user edit form.

File

core/modules/user/src/Tests/UserAccountFormFieldsTest.php, line 77
Contains \Drupal\user\Tests\UserAccountFormFieldsTest.

Class

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

Namespace

Drupal\user\Tests

Code

function testUserEditForm() {

  // Install default configuration; required for AccountFormController.
  $this
    ->installConfig(array(
    'user',
  ));

  // Install the router table and then rebuild.
  $this
    ->installSchema('system', [
    'router',
  ]);
  \Drupal::service('router.builder')
    ->rebuild();
  $form = $this
    ->buildAccountForm('default');

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

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