public function EntityEventVariablesTest::testNodeEvent in Hook Event Dispatcher 3.x
Same name and namespace in other branches
- 8.2 modules/preprocess_event_dispatcher/tests/src/Unit/EntityEventVariablesTest.php \Drupal\Tests\preprocess_event_dispatcher\Unit\EntityEventVariablesTest::testNodeEvent()
Test a NodePreprocessEvent.
File
- modules/
preprocess_event_dispatcher/ tests/ src/ Unit/ EntityEventVariablesTest.php, line 97
Class
- EntityEventVariablesTest
- Class EntityEventVariablesTest.
Namespace
Drupal\Tests\preprocess_event_dispatcher\UnitCode
public function testNodeEvent() : void {
$node = EntityMockFactory::getMock(NodeInterface::class, 'node', 'node_bundle', 'node_view_mode');
$variablesArray = $this
->createVariablesArray();
$variablesArray['node'] = $node;
$variablesArray['theme_hook_original'] = $node
->getEntityType();
$variablesArray['view_mode'] = $node
->getViewMode();
/** @var \Drupal\preprocess_event_dispatcher\Variables\NodeEventVariables $variables */
$variables = $this
->getVariablesFromCreatedEvent(NodePreprocessEvent::class, $variablesArray);
self::assertInstanceOf(NodeEventVariables::class, $variables);
$this
->assertAbstractEntityEventVariables($variables, $node);
self::assertSame($node, $variables
->getNode());
}