You are here

private function OtherEventTest::createAndAssertEvent in Hook Event Dispatcher 8

Create and assert the given event class.

Parameters

string $class: Event class name.

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

... See full list

File

tests/src/Unit/Preprocess/OtherEventTest.php, line 141

Class

OtherEventTest
Class OtherEventTest.

Namespace

Drupal\Tests\hook_event_dispatcher\Unit\Preprocess

Code

private function createAndAssertEvent($class) {

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

  /** @var \Drupal\hook_event_dispatcher\Event\Preprocess\AbstractPreprocessEvent $event */
  $event = $this->dispatcher
    ->getLastEvent();
  self::assertInstanceOf($class, $event);
  self::assertInstanceOf(AbstractEventVariables::class, $event
    ->getVariables());
}