You are here

function UserAccountFormFieldsTest::testUserRegistrationForm 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::testUserRegistrationForm()

Tests the user registration form.

File

core/modules/user/src/Tests/UserAccountFormFieldsTest.php, line 53
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 testUserRegistrationForm() {

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

  // Disable email confirmation to unlock the password field.
  $this
    ->config('user.settings')
    ->set('verify_mail', FALSE)
    ->save();
  $form = $this
    ->buildAccountForm('register');

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

  // Verify that web browsers may autocomplete the email value and
  // autofill/prefill the name and pass values.
  foreach (array(
    'mail',
    'name',
    'pass',
  ) as $key) {
    $this
      ->assertFalse(isset($form['account'][$key]['#attributes']['autocomplete']), "'{$key}' field: 'autocomplete' attribute not found.");
  }
}