summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2009-01-22 04:49:58 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2009-01-22 04:49:58 +0000
commit61bbde66f5538d6f2ca8ab39c8c2151683cf7c1a (patch)
tree5b138f7afa2a7a939f5a568a0012301914bcc5f7 /modules
parenta8c0d79fae58b3e0f149c685e1fcf7c0ae6a84ba (diff)
downloadbrdo-61bbde66f5538d6f2ca8ab39c8c2151683cf7c1a.tar.gz
brdo-61bbde66f5538d6f2ca8ab39c8c2151683cf7c1a.tar.bz2
#308277 by robertDouglass: Tests for multiple search engine types.
Diffstat (limited to 'modules')
-rw-r--r--modules/search/search.test38
1 files changed, 37 insertions, 1 deletions
diff --git a/modules/search/search.test b/modules/search/search.test
index 02bde2f5c..2415abe65 100644
--- a/modules/search/search.test
+++ b/modules/search/search.test
@@ -1,7 +1,10 @@
<?php
// $Id$
+// The search index can contain different types of content. Typically the type is 'node'.
+// Here we test with _test_ and _test2_ as the type.
define('SEARCH_TYPE', '_test_');
+define('SEARCH_TYPE_2', '_test2_');
class SearchMatchTestCase extends DrupalWebTestCase {
function getInfo() {
@@ -36,11 +39,14 @@ class SearchMatchTestCase extends DrupalWebTestCase {
for ($i = 1; $i <= 7; ++$i) {
search_index($i, SEARCH_TYPE, $this->getText($i));
}
+ for ($i = 1; $i <= 5; ++$i) {
+ search_index($i + 7, SEARCH_TYPE_2, $this->getText2($i));
+ }
search_update_totals();
}
/**
- * Helper method for generating snippets of content.
+ * _test_: Helper method for generating snippets of content.
*
* Generated items to test against:
* 1 ipsum
@@ -57,6 +63,21 @@ class SearchMatchTestCase extends DrupalWebTestCase {
}
/**
+ * _test2_: Helper method for generating snippets of content.
+ *
+ * Generated items to test against:
+ * 8 dear
+ * 9 king philip
+ * 10 philip came over
+ * 11 came over from germany
+ * 12 over from germany swimming
+ */
+ function getText2($n) {
+ $words = explode(' ', "Dear King Philip came over from Germany swimming.");
+ return implode(' ', array_slice($words, $n - 1, $n));
+ }
+
+ /**
* Run predefine queries looking for indexed terms.
*/
function _testQueries() {
@@ -116,6 +137,21 @@ class SearchMatchTestCase extends DrupalWebTestCase {
$this->_testQueryMatching($query, $set, $results);
$this->_testQueryScores($query, $set, $results);
}
+
+ // These queries are run against the second index type, SEARCH_TYPE_2.
+ $queries = array(
+ // Simple AND queries.
+ 'ipsum' => array(),
+ 'enim' => array(),
+ 'enim minim' => array(),
+ 'dear' => array(8),
+ 'germany' => array(11, 12),
+ );
+ foreach ($queries as $query => $results) {
+ $set = do_search($query, SEARCH_TYPE_2);
+ $this->_testQueryMatching($query, $set, $results);
+ $this->_testQueryScores($query, $set, $results);
+ }
}
/**