You are here

protected function FormTestBase::assertFormElement in Drupal 8

Same name and namespace in other branches
  1. 9 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 273

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);
}