function UserAccountFormFieldsTest::buildAccountForm

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

2 calls to UserAccountFormFieldsTest::buildAccountForm()
UserAccountFormFieldsTest::testUserEditForm in core/modules/user/tests/src/Kernel/UserAccountFormFieldsTest.php
Tests the user edit form.
UserAccountFormFieldsTest::testUserRegistrationForm in core/modules/user/tests/src/Kernel/UserAccountFormFieldsTest.php
Tests the user registration form.

File

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

Class

UserAccountFormFieldsTest
Verifies the field order in user account forms.

Namespace

Drupal\Tests\user\Kernel

Code

protected function buildAccountForm($operation) {
    // @see HtmlEntityFormController::getFormObject()
    $entity_type = 'user';
    if ($operation != 'register') {
        // Use an existing user.
        $entity = $this->user;
    }
    else {
        $entity = $this->container
            ->get('entity_type.manager')
            ->getStorage($entity_type)
            ->create();
    }
    // @see EntityFormBuilder::getForm()
    return $this->container
        ->get('entity.form_builder')
        ->getForm($entity, $operation);
}

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