You are here

private function EntityEventVariablesTest::getVariablesFromCreatedEvent in Hook Event Dispatcher 3.x

Same name and namespace in other branches
  1. 8.2 modules/preprocess_event_dispatcher/tests/src/Unit/EntityEventVariablesTest.php \Drupal\Tests\preprocess_event_dispatcher\Unit\EntityEventVariablesTest::getVariablesFromCreatedEvent()

Get the variables from the created event.

Parameters

string $class: Event class name.

array $variablesArray: Variables array.

Return value

\Drupal\preprocess_event_dispatcher\Variables\AbstractEntityEventVariables Variables object.

5 calls to EntityEventVariablesTest::getVariablesFromCreatedEvent()
EntityEventVariablesTest::testCommentEvent in modules/preprocess_event_dispatcher/tests/src/Unit/EntityEventVariablesTest.php
Test a CommentPreprocessEvent.
EntityEventVariablesTest::testEckEntityEvent in modules/preprocess_event_dispatcher/tests/src/Unit/EntityEventVariablesTest.php
Test a EckEntityPreprocessEvent.
EntityEventVariablesTest::testNodeEvent in modules/preprocess_event_dispatcher/tests/src/Unit/EntityEventVariablesTest.php
Test a NodePreprocessEvent.
EntityEventVariablesTest::testParagraphEvent in modules/preprocess_event_dispatcher/tests/src/Unit/EntityEventVariablesTest.php
Test a ParagraphPreprocessEvent.
EntityEventVariablesTest::testTaxonomyTermEvent in modules/preprocess_event_dispatcher/tests/src/Unit/EntityEventVariablesTest.php
Test a TaxonomyTermPreprocessEvent.

File

modules/preprocess_event_dispatcher/tests/src/Unit/EntityEventVariablesTest.php, line 195

Class

EntityEventVariablesTest
Class EntityEventVariablesTest.

Namespace

Drupal\Tests\preprocess_event_dispatcher\Unit

Code

private function getVariablesFromCreatedEvent(string $class, array $variablesArray) : AbstractEntityEventVariables {

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

  /** @var \Drupal\preprocess_event_dispatcher\Event\PreprocessEntityEventInterface $event*/
  $event = $factory
    ->createEvent($variablesArray);
  self::assertInstanceOf(PreprocessEntityEventInterface::class, $event);
  self::assertInstanceOf($class, $event);

  /** @var \Drupal\preprocess_event_dispatcher\Variables\AbstractEntityEventVariables $variables */
  $variables = $event
    ->getVariables();
  self::assertInstanceOf(AbstractEntityEventVariables::class, $variables);
  return $variables;
}