You are here

public function FormBuilderTest::testBuildFormWithObject in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php \Drupal\Tests\Core\Form\FormBuilderTest::testBuildFormWithObject()
  2. 9 core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php \Drupal\Tests\Core\Form\FormBuilderTest::testBuildFormWithObject()

Tests the buildForm() method with a form object.

File

core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php, line 281
Contains \Drupal\Tests\Core\Form\FormBuilderTest.

Class

FormBuilderTest
@coversDefaultClass \Drupal\Core\Form\FormBuilder @group Form

Namespace

Drupal\Tests\Core\Form

Code

public function testBuildFormWithObject() {
  $form_id = 'test_form_id';
  $expected_form = $form_id();
  $form_arg = $this
    ->getMockForm($form_id, $expected_form);
  $form_state = new FormState();
  $form = $this->formBuilder
    ->buildForm($form_arg, $form_state);
  $this
    ->assertFormElement($expected_form, $form, 'test');
  $this
    ->assertSame($form_id, $form_state
    ->getBuildInfo()['form_id']);
  $this
    ->assertArrayHasKey('#id', $form);
}