public function ViewDataEventTest::testViewsDataEventMultipleAdds in Hook Event Dispatcher 8
ViewsDataEvent multiple adds test.
File
- tests/
src/ Unit/ Views/ ViewDataEventTest.php, line 63
Class
- ViewDataEventTest
- Class ViewDataEventTest.
Namespace
Drupal\Tests\hook_event_dispatcher\Unit\ViewsCode
public function testViewsDataEventMultipleAdds() {
$data1 = [
'test' => [
'test_array_data',
],
];
$data2 = [
'test' => [
'other_test_array_data',
],
];
$data3 = [
'some' => [
'other_data',
],
];
$this->manager
->setEventCallbacks([
HookEventDispatcherInterface::VIEWS_DATA => function (ViewsDataEvent $event) use ($data1, $data2, $data3) {
$event
->addData($data1);
$event
->addData($data2);
$event
->addData($data3);
},
]);
$result = hook_event_dispatcher_views_data();
$expectedResult = [
'test' => [
'test_array_data',
'other_test_array_data',
],
'some' => [
'other_data',
],
];
self::assertSame($expectedResult, $result);
}