function SearchMatchTest::_test_query_scores in SimpleTest 6
Same name and namespace in other branches
- 5 tests/search_match.test \SearchMatchTest::_test_query_scores()
Test the scoring abilities of the engine.
Verify if a query produces normalized, monotonous scores.
1 call to SearchMatchTest::_test_query_scores()
File
- tests/
search_match.test, line 153
Class
Code
function _test_query_scores($query, $set, $results) {
// Get result scores.
$scores = array();
foreach ($set as $item) {
$scores[] = $item->score;
}
$this
->_cleanup_query();
// 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}'");
}