You are here

public function ViewEventTest::testQueryAlterEvent in Hook Event Dispatcher 8

Query alter event.

File

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

Class

ViewEventTest
Class ViewEventTest.

Namespace

Drupal\Tests\hook_event_dispatcher\Unit\Views

Code

public function testQueryAlterEvent() {

  /** @var \Drupal\views\ViewExecutable $view */
  $view = $this
    ->createMock(ViewExecutable::class);

  /** @var \Drupal\views\Plugin\views\query\QueryPluginBase $query */
  $query = $this
    ->createMock(QueryPluginBase::class);
  hook_event_dispatcher_views_query_alter($view, $query);

  /** @var \Drupal\hook_event_dispatcher\Event\Views\ViewsQueryAlterEvent $event */
  $event = $this->manager
    ->getRegisteredEvent(HookEventDispatcherInterface::VIEWS_QUERY_ALTER);
  self::assertSame($view, $event
    ->getView());
  self::assertSame($query, $event
    ->getQuery());
}