function SearchMatchTest::_testQueryMatching

Same name in other branches
  1. 9 core/modules/search/tests/src/Kernel/SearchMatchTest.php \Drupal\Tests\search\Kernel\SearchMatchTest::_testQueryMatching()
  2. 8.9.x core/modules/search/tests/src/Kernel/SearchMatchTest.php \Drupal\Tests\search\Kernel\SearchMatchTest::_testQueryMatching()
  3. 11.x core/modules/search/tests/src/Kernel/SearchMatchTest.php \Drupal\Tests\search\Kernel\SearchMatchTest::_testQueryMatching()

Tests the matching abilities of the engine.

Verify if a query produces the correct results.

1 call to SearchMatchTest::_testQueryMatching()
SearchMatchTest::_testQueries in core/modules/search/tests/src/Kernel/SearchMatchTest.php
Run predefine queries looking for indexed terms.

File

core/modules/search/tests/src/Kernel/SearchMatchTest.php, line 228

Class

SearchMatchTest
Indexes content and queries it.

Namespace

Drupal\Tests\search\Kernel

Code

public function _testQueryMatching($query, $set, $results) {
    // Get result IDs.
    $found = [];
    foreach ($set as $item) {
        $found[] = $item->sid;
    }
    // Compare $results and $found.
    sort($found);
    sort($results);
    $this->assertEquals($found, $results, "Query matching '{$query}'");
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.