You are here

public function ViewEventTest::testQueryAlterEvent in Hook Event Dispatcher 3.x

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

Query alter event.

File

modules/views_event_dispatcher/tests/src/Unit/Views/ViewEventTest.php, line 191

Class

ViewEventTest
Class ViewEventTest.

Namespace

Drupal\Tests\views_event_dispatcher\Unit\Views

Code

public function testQueryAlterEvent() : void {

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

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

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