public function ViewDataEventTest::testViewsDataAlterEventByReference in Hook Event Dispatcher 8
ViewsDataAlterEvent by reference test.
File
- tests/
src/ Unit/ Views/ ViewDataEventTest.php, line 107
Class
- ViewDataEventTest
- Class ViewDataEventTest.
Namespace
Drupal\Tests\hook_event_dispatcher\Unit\ViewsCode
public function testViewsDataAlterEventByReference() {
$this->manager
->setEventCallbacks([
HookEventDispatcherInterface::VIEWS_DATA_ALTER => function (ViewsDataAlterEvent $event) {
$data =& $event
->getData();
$data['test']['other_test'] = [
'some_data',
];
},
]);
$data = $expectedData = [
'test' => [
'test' => 'test_array_data',
],
];
hook_event_dispatcher_views_data_alter($data);
$expectedData['test']['other_test'] = [
'some_data',
];
self::assertSame($expectedData, $data);
}