You are here

private function AbstractFormEntityDisplayEditAlterEventSubscriberTestCase::alterForm 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::alterForm()

Alter both $form and $expectedForm for a test.

Parameters

array &$form: This is the form array to be passed to FormEntityDisplayEditAlterEventSubscriber for it to alter.

array &$expectedForm: This is a duplicate of $form that is altered here in this method to match the expected changes FormEntityDisplayEditAlterEventSubscriber performs on $form.

See also

\Drupal\field_event_dispatcher\EventSubscriber\Form\FormEntityDisplayEditAlterEventSubscriber::formAlter()

4 calls to AbstractFormEntityDisplayEditAlterEventSubscriberTestCase::alterForm()
AbstractFormEntityDisplayEditAlterEventSubscriberTestCase::testFormAlterMultipleMerges in modules/field_event_dispatcher/tests/src/Unit/Field/AbstractFormEntityDisplayEditAlterEventSubscriberTestCase.php
FormEntityDisplayEditAlterEventSubscriber test with multiple merges.
AbstractFormEntityDisplayEditAlterEventSubscriberTestCase::testFormAlterNoFields in modules/field_event_dispatcher/tests/src/Unit/Field/AbstractFormEntityDisplayEditAlterEventSubscriberTestCase.php
FormEntityDisplayEditAlterEventSubscriber test with no fields.
AbstractFormEntityDisplayEditAlterEventSubscriberTestCase::testFormAlterOneField in modules/field_event_dispatcher/tests/src/Unit/Field/AbstractFormEntityDisplayEditAlterEventSubscriberTestCase.php
FormEntityDisplayEditAlterEventSubscriber test with one field.
AbstractFormEntityDisplayEditAlterEventSubscriberTestCase::testFormAlterTwoFields in modules/field_event_dispatcher/tests/src/Unit/Field/AbstractFormEntityDisplayEditAlterEventSubscriberTestCase.php
FormEntityDisplayEditAlterEventSubscriber test with two fields.

File

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

Class

AbstractFormEntityDisplayEditAlterEventSubscriberTestCase
Class AbstractFormEntityDisplayEditAlterEventSubscriberTestCase.

Namespace

Drupal\Tests\field_event_dispatcher\Unit\Field

Code

private function alterForm(array &$form, array &$expectedForm) : void {
  $eventSubscriber = new FormEntityDisplayEditAlterEventSubscriber();
  $formState = $this
    ->createMock(FormStateInterface::class);
  $event = new FormIdAlterEvent($form, $formState, $this->formId);
  $eventSubscriber
    ->formAlter($event);
  foreach ($expectedForm['#fields'] as $fieldName) {

    // Skip any fields that have no field_event_dispatcher third-party
    // settings.
    if (!isset($expectedForm['fields'][$fieldName]['plugin']['settings_edit_form']['third_party_settings']['field_event_dispatcher'])) {
      continue;
    }
    $thirdPartySettings =& $expectedForm['fields'][$fieldName]['plugin']['settings_edit_form']['third_party_settings'];
    $thirdPartySettings = NestedArray::mergeDeep($thirdPartySettings, $thirdPartySettings['field_event_dispatcher']);
    unset($thirdPartySettings['field_event_dispatcher']);
  }
  $form = $event
    ->getForm();
}