function FormBuilderTest::testGetFormIdWithInjectedClassName

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php \Drupal\Tests\Core\Form\FormBuilderTest::testGetFormIdWithInjectedClassName()
  2. 8.9.x core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php \Drupal\Tests\Core\Form\FormBuilderTest::testGetFormIdWithInjectedClassName()
  3. 10 core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php \Drupal\Tests\Core\Form\FormBuilderTest::testGetFormIdWithInjectedClassName()

Tests the getFormId() method with an injected class name form ID.

File

core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php, line 93

Class

FormBuilderTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Form%21FormBuilder.php/class/FormBuilder/11.x" title="Provides form building and processing." class="local">\Drupal\Core\Form\FormBuilder</a> @group Form

Namespace

Drupal\Tests\Core\Form

Code

public function testGetFormIdWithInjectedClassName() : void {
    $container = $this->createMock('Symfony\\Component\\DependencyInjection\\ContainerInterface');
    \Drupal::setContainer($container);
    $form_arg = 'Drupal\\Tests\\Core\\Form\\TestFormInjected';
    $form_state = new FormState();
    $form_id = $this->formBuilder
        ->getFormId($form_arg, $form_state);
    $this->assertSame('test_form', $form_id);
    $this->assertSame($form_arg, get_class($form_state->getFormObject()));
}

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