You are here

public function ViewDataEventTest::testViewsDataAlterEvent 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::testViewsDataAlterEvent()

ViewsDataAlterEvent test.

File

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

Class

ViewDataEventTest
Class ViewDataEventTest.

Namespace

Drupal\Tests\views_event_dispatcher\Unit\Views

Code

public function testViewsDataAlterEvent() : void {
  $this->manager
    ->setEventCallbacks([
    HookEventDispatcherInterface::VIEWS_DATA_ALTER => static function (ViewsDataAlterEvent $event) {
      $data =& $event
        ->getData();
      $data['test']['other_test'] = [
        'some_data',
      ];
    },
  ]);
  $data = $expectedData = [
    'test' => [
      'test' => 'test_array_data',
    ],
  ];
  views_event_dispatcher_views_data_alter($data);
  $expectedData['test']['other_test'] = [
    'some_data',
  ];
  self::assertSame($expectedData, $data);
}