You are here

function DrupalSolrQueryTests::testRemoveTerm in Apache Solr Search 6.2

Same name and namespace in other branches
  1. 5 tests/solr_base_query.test \DrupalSolrQueryTests::testRemoveTerm()

File

tests/solr_base_query.test, line 59
Tests for the apachsolr module: base query.

Class

DrupalSolrQueryTests
JacobSingh: Warning! This test is totally broken because of the addition of the "hash" in apachesolr_search.module. Needs to be moved out.

Code

function testRemoveTerm() {
  $string = 'foo';
  $query = apachesolr_drupal_query($string);
  $query
    ->remove_filter('', 'foo');
  $this
    ->assertEqual('foo', $query
    ->get_query_basic());
  $string = 'foo bar';
  $query = apachesolr_drupal_query($string);
  $query
    ->remove_filter('', 'foo');
  $this
    ->assertEqual('foo bar', $query
    ->get_query_basic());
  $string = 'foo bar';
  $query = apachesolr_drupal_query($string, 'uid:1');
  $query
    ->remove_filter('uid', '1');
  $this
    ->assertEqual('foo bar', $query
    ->get_query_basic());
  $string = 'foo bar';
  $query = apachesolr_drupal_query($string);
  $query
    ->remove_filter('uid', 'uid:1');
  $this
    ->assertEqual('foo bar', $query
    ->get_query_basic());
  $string = 'foo bar';
  $query = apachesolr_drupal_query($string, 'uid:1 uid:2 tid:3');
  $query
    ->remove_filter('uid', '1');
  $this
    ->assertEqual('foo bar', $query
    ->get_query_basic());
  $this
    ->assertEqual(array(
    'filters' => 'uid:2 tid:3',
  ), $query
    ->get_url_queryvalues());
  $string = 'foo bar';
  $query = apachesolr_drupal_query($string, 'uid:1 uid:2 tid:3');
  $query
    ->remove_filter('uid');
  $this
    ->assertEqual('foo bar', $query
    ->get_query_basic());
  $this
    ->assertEqual(array(
    'filters' => 'tid:3',
  ), $query
    ->get_url_queryvalues());
}