summaryrefslogtreecommitdiff
path: root/modules/search/search.test
diff options
context:
space:
mode:
Diffstat (limited to 'modules/search/search.test')
-rw-r--r--modules/search/search.test34
1 files changed, 34 insertions, 0 deletions
diff --git a/modules/search/search.test b/modules/search/search.test
index 4f18e96c5..02bcdeeae 100644
--- a/modules/search/search.test
+++ b/modules/search/search.test
@@ -566,3 +566,37 @@ class SearchCommentTestCase extends DrupalWebTestCase {
$this->assertNoText($comment_body, t('Comment body text not found in search results.'));
}
}
+
+/**
+ * Test search_simplify() on every Unicode character.
+ */
+class SearchSimplifyTestCase extends DrupalWebTestCase {
+ public static function getInfo() {
+ return array(
+ 'name' => 'Search simplify',
+ 'description' => 'Check that simplification works as intended.',
+ 'group' => 'Search',
+ );
+ }
+
+ function testSearchSimplify() {
+ $input = file_get_contents(DRUPAL_ROOT . '/modules/search/tests/UnicodeTest.txt');
+ $strings = explode(chr(10), $input);
+ foreach ($strings as $key => $string) {
+ $simplified = search_simplify($string);
+ if ($key % 2) {
+ $this->assertIdentical($simplified, ' ', "Line $key is excluded from the index");
+ }
+ else {
+ $this->assertTrue(drupal_strlen($simplified) >= drupal_strlen($string), "Nothing is removed on line $key.");
+ }
+ }
+ $string = '';
+ for ($i = 0; $i < 32; $i++) {
+ $string .= chr($i);
+ }
+ // Diff really does not like files starting with \0 so test it separately.
+ $this->assertIdentical(' ', search_simplify($string), t('Search simplify works for ASCII control characters.'));
+ }
+}
+ \ No newline at end of file