Example #1
0
 /**
  * Test replaceTerm() method
  *
  * @return void
  */
 public function testReplaceTerm()
 {
     $q = new Query('test query we<(ird and/or');
     $q->replaceTerm('we<(ird', 'we>(ird');
     $q->replaceTerm('and/or', 'and-or');
     $this->assertEquals('test query we>(ird and-or', $q->getString());
     $q = new Query('test query we<(ird and/or');
     $q->replaceTerm('and', 'not');
     $this->assertEquals('test query we<(ird not/or', $q->getString());
 }
Example #2
0
 /**
  * Return a query string for the current search with a search term replaced.
  *
  * @param string $oldTerm The old term to replace
  * @param string $newTerm The new term to search
  *
  * @return string         query string
  */
 public function getDisplayQueryWithReplacedTerm($oldTerm, $newTerm)
 {
     // Stash our old data for a minute
     $oldTerms = clone $this->query;
     // Replace the search term
     $this->query->replaceTerm($oldTerm, $newTerm);
     // Get the new query string
     $query = $this->getDisplayQuery();
     // Restore the old data
     $this->query = $oldTerms;
     // Return the query string
     return $query;
 }