You are here

protected function BackendTest::checkDbQueryAlter in Search API 8

Checks whether the module's specific alter hook and event work correctly.

1 call to BackendTest::checkDbQueryAlter()
BackendTest::checkBackendSpecificFeatures in modules/search_api_db/tests/src/Kernel/BackendTest.php
Checks backend specific features.

File

modules/search_api_db/tests/src/Kernel/BackendTest.php, line 515

Class

BackendTest
Tests index and search capabilities using the Database search backend.

Namespace

Drupal\Tests\search_api_db\Kernel

Code

protected function checkDbQueryAlter() {
  $query = $this
    ->buildSearch();
  $query
    ->setOption('search_api_test_db_search_api_db_query_alter', TRUE);
  $results = $query
    ->execute();
  $this
    ->assertResults([], $results, 'Query triggering custom alter hook');
  $query = $this
    ->buildSearch();
  $query
    ->setOption('search_api_test_db.event.query_pre_execute.1', TRUE);
  $results = $query
    ->execute();
  $this
    ->assertResults([], $results, 'Query triggering custom alter event 1');
  $query = $this
    ->buildSearch();
  $query
    ->setOption('search_api_test_db.event.query_pre_execute.2', TRUE);
  $results = $query
    ->execute();
  $this
    ->assertResults([], $results, 'Query triggering custom alter event 2');
}