You are here

public function AbstractFormEntityDisplayEditAlterEventSubscriberTestCase::testFormAlterMultipleMerges in Hook Event Dispatcher 8.2

Same name and namespace in other branches
  1. 3.x modules/field_event_dispatcher/tests/src/Unit/Field/AbstractFormEntityDisplayEditAlterEventSubscriberTestCase.php \Drupal\Tests\field_event_dispatcher\Unit\Field\AbstractFormEntityDisplayEditAlterEventSubscriberTestCase::testFormAlterMultipleMerges()

FormEntityDisplayEditAlterEventSubscriber test with multiple merges.

This tests that FormEntityDisplayEditAlterEventSubscriber::formAlter() alters the $form array as expected when a field has third-party settings merged in more than once.

File

modules/field_event_dispatcher/tests/src/Unit/Field/AbstractFormEntityDisplayEditAlterEventSubscriberTestCase.php, line 167

Class

AbstractFormEntityDisplayEditAlterEventSubscriberTestCase
Class AbstractFormEntityDisplayEditAlterEventSubscriberTestCase.

Namespace

Drupal\Tests\field_event_dispatcher\Unit\Field

Code

public function testFormAlterMultipleMerges() : void {
  $form = $this
    ->getTestForm([
    'field_test' => [
      'test_module1' => [
        'test',
      ],
    ],
  ]);
  $expectedForm = $form;

  // First merge.
  $this
    ->alterForm($form, $expectedForm);
  $form = NestedArray::mergeDeep($form, $this
    ->getTestForm([
    'field_test' => [
      'test_module2' => [
        'test',
      ],
    ],
  ]));
  $expectedForm = $form;

  // Second merge.
  $this
    ->alterForm($form, $expectedForm);
  self::assertSame($expectedForm, $form);
}