You are here

private function OtherEventVariablesTest::getVariablesFromCreatedEvent in Hook Event Dispatcher 8

Get the variables from the created event.

Parameters

string $class: Event class name.

array $variablesArray: Variables array.

Return value

\Drupal\hook_event_dispatcher\Event\Preprocess\Variables\AbstractEventVariables Variables object.

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

... See full list

File

tests/src/Unit/Preprocess/OtherEventVariablesTest.php, line 268

Class

OtherEventVariablesTest
Class OtherEventVariablesTest.

Namespace

Drupal\Tests\hook_event_dispatcher\Unit\Preprocess

Code

private function getVariablesFromCreatedEvent($class, array $variablesArray) {

  /** @var \Drupal\hook_event_dispatcher\Event\Preprocess\PreprocessEventInterface $class */
  $hook = $class::getHook();
  self::assertEquals(AbstractPreprocessEvent::DISPATCH_NAME_PREFIX . $hook, $class::name());
  $factory = $this->mapper
    ->getFactory($hook);
  self::assertEquals($hook, $factory
    ->getEventHook());

  /** @var \Drupal\hook_event_dispatcher\Event\Preprocess\PreprocessEventInterface $event*/
  $event = $factory
    ->createEvent($variablesArray);
  self::assertInstanceOf($class, $event);
  return $event
    ->getVariables();
}