function SearchMatchTest::_testQueryScores in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/search/src/Tests/SearchMatchTest.php \Drupal\search\Tests\SearchMatchTest::_testQueryScores()
Test the scoring abilities of the engine.
Verify if a query produces normalized, monotonous scores.
1 call to SearchMatchTest::_testQueryScores()
- SearchMatchTest::_testQueries in core/
modules/ search/ src/ Tests/ SearchMatchTest.php - Run predefine queries looking for indexed terms.
File
- core/
modules/ search/ src/ Tests/ SearchMatchTest.php, line 244 - Contains \Drupal\search\Tests\SearchMatchTest.
Class
- SearchMatchTest
- Indexes content and queries it.
Namespace
Drupal\search\TestsCode
function _testQueryScores($query, $set, $results) {
// Get result scores.
$scores = array();
foreach ($set as $item) {
$scores[] = $item->calculated_score;
}
// Check order.
$sorted = $scores;
sort($sorted);
$this
->assertEqual($scores, array_reverse($sorted), "Query order '{$query}'");
// Check range.
$this
->assertEqual(!count($scores) || min($scores) > 0.0 && max($scores) <= 1.0001, TRUE, "Query scoring '{$query}'");
}