function SearchMatchTestCase::_testQueryScores

Test the scoring abilities of the engine.

Verify if a query produces normalized, monotonous scores.

2 calls to SearchMatchTestCase::_testQueryScores()
SearchMatchTestCase::_testQueries in drupal-7.x/modules/search/search.test
Run predefine queries looking for indexed terms.
SearchMatchTestCase::_testQueries in drupal-7.x/modules/search/search.test
Run predefine queries looking for indexed terms.

Archivo

drupal-7.x/modules/search/search.test, line 226
Tests for search.module.

Class

SearchMatchTestCase

Código

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