You are here

public function ViewEventTest::testQuerySubstitions in Hook Event Dispatcher 8

Query substitutions event.

File

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

Class

ViewEventTest
Class ViewEventTest.

Namespace

Drupal\Tests\hook_event_dispatcher\Unit\Views

Code

public function testQuerySubstitions() {

  /** @var \Drupal\views\ViewExecutable $view */
  $view = $this
    ->createMock(ViewExecutable::class);
  $expected = [
    "test" => 1,
  ];
  $this->manager
    ->setEventCallbacks([
    HookEventDispatcherInterface::VIEWS_QUERY_SUBSTITUTIONS => function (ViewsQuerySubstitutionsEvent $event) use ($expected) {
      $event
        ->setSubstitutions($expected);
    },
  ]);
  $result = hook_event_dispatcher_views_query_substitutions($view);
  self::assertSame($expected, $result);
}