1 search.test SearchRankingTestCase::testDoubleRankings()

Verifies that if we combine two rankings, search still works.

See issue http://drupal.org/node/771596

File

core/modules/search/tests/search.test, line 515
Tests for search.module.

Class

SearchRankingTestCase
Indexes content and tests ranking factors.

Code

function testDoubleRankings() {
  // Login with sufficient privileges.
  $this->backdropLogin($this->backdropCreateUser(array('skip comment approval', 'create page content')));

  // See testRankings() above - build a node that will rank high for sticky.
  $settings = array(
    'type' => 'page',
    'title' => 'Backdrop rocks',
    'body' => array(LANGUAGE_NONE => array(array('value' => "Backdrop's search rocks"))),
    'sticky' => 1,
  );

  $node = $this->backdropCreateNode($settings);

  // Update the search index.
  module_invoke_all('update_index');
  search_update_totals();

  // Refresh variables after the treatment.
  $this->refreshVariables();

  // Set up for ranking sticky and lots of comments; make sure others are
  // disabled.
  $node_ranks = array('sticky', 'promote', 'relevance', 'recent', 'comments');
  foreach ($node_ranks as $var) {
    $value = ($var == 'sticky' || $var == 'comments') ? 10 : 0;
    config_set('search.settings', 'node_rank_' . $var, $value);
  }

  // Do the search and assert the results.
  $set = node_search_execute('rocks');
  $this->assertEqual($set[0]['node']->nid, $node->nid, 'Search double ranking order.');
}