You are here

private function OtherEventTest::createAndAssertEvent in Hook Event Dispatcher 8.2

Same name and namespace in other branches
  1. 3.x modules/preprocess_event_dispatcher/tests/src/Unit/OtherEventTest.php \Drupal\Tests\preprocess_event_dispatcher\Unit\OtherEventTest::createAndAssertEvent()

Create and assert the given event class.

Parameters

string $class: Event class name.

9 calls to OtherEventTest::createAndAssertEvent()
OtherEventTest::testBlockEvent in modules/preprocess_event_dispatcher/tests/src/Unit/OtherEventTest.php
Test a BlockPreprocessEvent.
OtherEventTest::testFieldEvent in modules/preprocess_event_dispatcher/tests/src/Unit/OtherEventTest.php
Test a FieldPreprocessEvent.
OtherEventTest::testFormEvent in modules/preprocess_event_dispatcher/tests/src/Unit/OtherEventTest.php
Test a FormPreprocessEvent.
OtherEventTest::testHtmlEvent in modules/preprocess_event_dispatcher/tests/src/Unit/OtherEventTest.php
Test a HtmlPreprocessEvent.
OtherEventTest::testImageEvent in modules/preprocess_event_dispatcher/tests/src/Unit/OtherEventTest.php
Test a ImagePreprocessEvent.

... See full list

File

modules/preprocess_event_dispatcher/tests/src/Unit/OtherEventTest.php, line 141

Class

OtherEventTest
Class OtherEventTest.

Namespace

Drupal\Tests\preprocess_event_dispatcher\Unit

Code

private function createAndAssertEvent(string $class) : void {

  /** @var \Drupal\preprocess_event_dispatcher\Event\AbstractPreprocessEvent $class */
  $this->service
    ->createAndDispatchKnownEvents($class::getHook(), $this->variables);
  self::assertSame($class::name(), $this->dispatcher
    ->getLastEventName());

  /** @var \Drupal\preprocess_event_dispatcher\Event\AbstractPreprocessEvent $event */
  $event = $this->dispatcher
    ->getLastEvent();
  self::assertInstanceOf($class, $event);
  $variablesClass = str_replace([
    '\\Event\\',
    'PreprocessEvent',
  ], [
    '\\Variables\\',
    'EventVariables',
  ], $class);
  self::assertInstanceOf($variablesClass, $event
    ->getVariables());
}