function FormBuilderTest::testGetFormIdWithString

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

Tests the getFormId() method with a string based form ID.

@covers ::getFormId

File

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

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 testGetFormIdWithString() : void {
    $form_arg = 'foo';
    $form_state = new FormState();
    $this->expectException(\InvalidArgumentException::class);
    $this->expectExceptionMessage('The form class foo could not be found or loaded.');
    $this->formBuilder
        ->getFormId($form_arg, $form_state);
}

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