You are here

public function ViewEventTest::testPreViewEvent in Hook Event Dispatcher 8

Pre view event.

File

tests/src/Unit/Views/ViewEventTest.php, line 46

Class

ViewEventTest
Class ViewEventTest.

Namespace

Drupal\Tests\hook_event_dispatcher\Unit\Views

Code

public function testPreViewEvent() {

  /** @var \Drupal\views\ViewExecutable $view */
  $view = $this
    ->createMock(ViewExecutable::class);
  $displayId = 'test';
  $arguments = [
    'test',
  ];
  $this->manager
    ->setEventCallbacks([
    HookEventDispatcherInterface::VIEWS_PRE_VIEW => function (ViewsPreViewEvent $event) {
      $arguments =& $event
        ->getArguments();
      $arguments[0] = 'test2';
    },
  ]);
  hook_event_dispatcher_views_pre_view($view, $displayId, $arguments);
  self::assertEquals('test2', $arguments[0]);
}