You are here

public function ViewDataEventTest::testViewsDataEvent in Hook Event Dispatcher 3.x

Same name and namespace in other branches
  1. 8.2 modules/views_event_dispatcher/tests/src/Unit/Views/ViewDataEventTest.php \Drupal\Tests\views_event_dispatcher\Unit\Views\ViewDataEventTest::testViewsDataEvent()

ViewsDataEvent test.

File

modules/views_event_dispatcher/tests/src/Unit/Views/ViewDataEventTest.php, line 43

Class

ViewDataEventTest
Class ViewDataEventTest.

Namespace

Drupal\Tests\views_event_dispatcher\Unit\Views

Code

public function testViewsDataEvent() : void {
  $data = [
    'test' => [
      'test_array_data',
    ],
  ];
  $this->manager
    ->setEventCallbacks([
    HookEventDispatcherInterface::VIEWS_DATA => static function (ViewsDataEvent $event) use ($data) {
      $event
        ->addData($data);
    },
  ]);
  $result = views_event_dispatcher_views_data();
  self::assertSame($data, $result);
}