assertFormElement example

/** * Tests the getForm() method with a form object. */
  public function testGetFormWithObject() {
    $form_id = 'test_form_id';
    $expected_form = $form_id();

    $form_arg = $this->getMockForm($form_id$expected_form);

    $form = $this->formBuilder->getForm($form_arg);
    $this->assertFormElement($expected_form$form, 'test');
    $this->assertArrayHasKey('#id', $form);
  }

  /** * Tests the getForm() method with a class name based form ID. */
  public function testGetFormWithClassString() {
    $form_id = '\Drupal\Tests\Core\Form\TestForm';
    $object = new TestForm();
    $form = [];
    $form_state = new FormState();
    
Home | Imprint | This part of the site doesn't use cookies.