You are here

public function FormBuilderTest::testGetFormWithClassString in Drupal 9

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

Tests the getForm() method with a class name based form ID.

File

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

Class

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

Namespace

Drupal\Tests\Core\Form

Code

public function testGetFormWithClassString() {
  $form_id = '\\Drupal\\Tests\\Core\\Form\\TestForm';
  $object = new TestForm();
  $form = [];
  $form_state = new FormState();
  $expected_form = $object
    ->buildForm($form, $form_state);
  $form = $this->formBuilder
    ->getForm($form_id);
  $this
    ->assertFormElement($expected_form, $form, 'test');
  $this
    ->assertSame('test-form', $form['#id']);
}