You are here

public function FormEventTest::testFormIdAlterEvent in Hook Event Dispatcher 8

Test FormIdAlterEvent.

File

tests/src/Unit/Form/FormEventTest.php, line 90

Class

FormEventTest
Class FormEventTest.

Namespace

Drupal\Tests\hook_event_dispatcher\Unit\Form

Code

public function testFormIdAlterEvent() {
  $form = [
    'test' => 'form',
  ];
  $formState = $this
    ->createMock(FormStateInterface::class);
  $formId = 'test_form';
  $this->manager
    ->setMaxEventCount(2);
  hook_event_dispatcher_form_alter($form, $formState, $formId);

  /** @var \Drupal\hook_event_dispatcher\Event\Form\FormAlterEvent $event */
  $event = $this->manager
    ->getRegisteredEvent("hook_event_dispatcher.form_{$formId}.alter");
  self::assertEquals($form, $event
    ->getForm());
  self::assertEquals($formState, $event
    ->getFormState());
  self::assertEquals($formId, $event
    ->getFormId());
}