public function EntityEventVariablesTest::testNodeEvent in Hook Event Dispatcher 8
Test a NodePreprocessEvent.
File
- tests/
src/ Unit/ Preprocess/ EntityEventVariablesTest.php, line 88
Class
- EntityEventVariablesTest
- Class EntityEventVariablesTest.
Namespace
Drupal\Tests\hook_event_dispatcher\Unit\PreprocessCode
public function testNodeEvent() {
$node = new EntityMock('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\hook_event_dispatcher\Event\Preprocess\Variables\NodeEventVariables $variables */
$variables = $this
->getVariablesFromCreatedEvent(NodePreprocessEvent::class, $variablesArray);
$this
->assertInstanceOf(NodeEventVariables::class, $variables);
$this
->assertAbstractEntityEventVariables($variables, $node);
$this
->assertSame($node, $variables
->getNode());
}