function FormTestBase::assertFormElement

Same name in other branches
  1. 8.9.x core/tests/Drupal/Tests/Core/Form/FormTestBase.php \Drupal\Tests\Core\Form\FormTestBase::assertFormElement()
  2. 10 core/tests/Drupal/Tests/Core/Form/FormTestBase.php \Drupal\Tests\Core\Form\FormTestBase::assertFormElement()
  3. 11.x core/tests/Drupal/Tests/Core/Form/FormTestBase.php \Drupal\Tests\Core\Form\FormTestBase::assertFormElement()

Asserts that the expected form structure is found in a form for a given key.

Parameters

array $expected_form: The expected form structure.

array $actual_form: The actual form.

string|null $form_key: (optional) The form key to look in. Otherwise the entire form will be compared.

5 calls to FormTestBase::assertFormElement()
FormBuilderTest::testBuildFormWithClassString in core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php
Tests the buildForm() method with a class name based form ID.
FormBuilderTest::testBuildFormWithObject in core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php
Tests the buildForm() method with a form object.
FormBuilderTest::testGetFormWithClassString in core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php
Tests the getForm() method with a class name based form ID.
FormBuilderTest::testGetFormWithObject in core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php
Tests the getForm() method with a form object.
FormBuilderTest::testGetPostAjaxRequest in core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php
@covers ::buildForm

File

core/tests/Drupal/Tests/Core/Form/FormTestBase.php, line 271

Class

FormTestBase
Provides a base class for testing form functionality.

Namespace

Drupal\Tests\Core\Form

Code

protected function assertFormElement(array $expected_form, array $actual_form, $form_key = NULL) {
    $expected_element = $form_key ? $expected_form[$form_key] : $expected_form;
    $actual_element = $form_key ? $actual_form[$form_key] : $actual_form;
    $this->assertSame(array_intersect_key($expected_element, $actual_element), $expected_element);
}

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