You are here

public function FormBuilderTest::testGetFormIdWithObject in Drupal 8

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

Tests the getFormId() method with a form object.

File

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

Class

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

Namespace

Drupal\Tests\Core\Form

Code

public function testGetFormIdWithObject() {
  $expected_form_id = 'my_module_form_id';
  $form_arg = $this
    ->getMockForm($expected_form_id);
  $form_state = new FormState();
  $form_id = $this->formBuilder
    ->getFormId($form_arg, $form_state);
  $this
    ->assertSame($expected_form_id, $form_id);
  $this
    ->assertSame($form_arg, $form_state
    ->getFormObject());
}