private function EntityEventVariablesTest::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\AbstractEntityEventVariables Variables object.
5 calls to EntityEventVariablesTest::getVariablesFromCreatedEvent()
- EntityEventVariablesTest::testCommentEvent in tests/
src/ Unit/ Preprocess/ EntityEventVariablesTest.php - Test a CommentPreprocessEvent.
- EntityEventVariablesTest::testEckEntityEvent in tests/
src/ Unit/ Preprocess/ EntityEventVariablesTest.php - Test a EckEntityPreprocessEvent.
- EntityEventVariablesTest::testNodeEvent in tests/
src/ Unit/ Preprocess/ EntityEventVariablesTest.php - Test a NodePreprocessEvent.
- EntityEventVariablesTest::testParagraphEvent in tests/
src/ Unit/ Preprocess/ EntityEventVariablesTest.php - Test a ParagraphPreprocessEvent.
- EntityEventVariablesTest::testTaxonomyTermEvent in tests/
src/ Unit/ Preprocess/ EntityEventVariablesTest.php - Test a TaxonomyTermPreprocessEvent.
File
- tests/
src/ Unit/ Preprocess/ EntityEventVariablesTest.php, line 186
Class
- EntityEventVariablesTest
- Class EntityEventVariablesTest.
Namespace
Drupal\Tests\hook_event_dispatcher\Unit\PreprocessCode
private function getVariablesFromCreatedEvent($class, array $variablesArray) {
/** @var \Drupal\hook_event_dispatcher\Event\Preprocess\PreprocessEventInterface $class */
$hook = $class::getHook();
$this
->assertEquals(AbstractPreprocessEvent::DISPATCH_NAME_PREFIX . $hook, $class::name());
$factory = $this->mapper
->getFactory($hook);
$this
->assertEquals($hook, $factory
->getEventHook());
/** @var \Drupal\hook_event_dispatcher\Event\Preprocess\PreprocessEntityEventInterface $event*/
$event = $factory
->createEvent($variablesArray);
$this
->assertInstanceOf(PreprocessEntityEventInterface::class, $event);
$this
->assertInstanceOf($class, $event);
/** @var \Drupal\hook_event_dispatcher\Event\Preprocess\Variables\AbstractEntityEventVariables $variables */
$variables = $event
->getVariables();
$this
->assertInstanceOf(AbstractEntityEventVariables::class, $variables);
return $variables;
}