You are here

protected function UserAccountFormFieldsTest::buildAccountForm in Drupal 10

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

Builds the user account form for a given operation.

Parameters

string $operation: The entity operation; one of 'register' or 'default'.

Return value

array The form array.

File

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

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

protected function buildAccountForm($operation) {

  // @see HtmlEntityFormController::getFormObject()
  $entity_type = 'user';
  $fields = [];
  if ($operation != 'register') {
    $fields['uid'] = 2;
  }
  $entity = $this->container
    ->get('entity_type.manager')
    ->getStorage($entity_type)
    ->create($fields);

  // @see EntityFormBuilder::getForm()
  return $this->container
    ->get('entity.form_builder')
    ->getForm($entity, $operation);
}