You are here

function SearchMatchTest::_test_query_scores in SimpleTest 5

Same name and namespace in other branches
  1. 6 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()
SearchMatchTest::_test_queries in tests/search_match.test

File

tests/search_match.test, line 153

Class

SearchMatchTest

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}'");
}