From bd1aa5d3cdab509780eec55c8874bb8fb9395677 Mon Sep 17 00:00:00 2001 From: rurban Date: Sun, 11 Sep 2005 13:16:39 +0000 Subject: [PATCH] fulltext enhancements git-svn-id: svn://svn.code.sf.net/p/phpwiki/code/trunk@4808 96ab9672-09ca-45d6-a79d-3d69d39ca109 --- tests/unit/lib/TextSearchTest.php | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/tests/unit/lib/TextSearchTest.php b/tests/unit/lib/TextSearchTest.php index 217c145ba..e59013d5b 100644 --- a/tests/unit/lib/TextSearchTest.php +++ b/tests/unit/lib/TextSearchTest.php @@ -14,14 +14,20 @@ class TextSearchTest extends phpwiki_TestCase { $dbi = $request->getDbh(); $subpages = $dbi->titleSearch($query, $sortby, $limit, $exclude); - $this->assertTrue($subpages->count() > 0, "glob count > 0"); + $result = array(); + while ($page = $subpages->next()) + $result[] = $page->getName(); + $this->assertTrue(count($result) > 0, "glob count > 0"); // apply limit $sortby = false; $limit = 5; $exclude = ""; $subpages = $dbi->titleSearch($query, $sortby, $limit, $exclude); - // don't trust count() - $this->assertEquals(5, $subpages->count(), "count() limit 5"); + // don't trust count() with limit + $this->assertTrue($subpages->count() > 0 and $subpages->count() <= 7, + "0 < count() <= 7"); + $result = array(); + // but the iterator should limit while ($page = $subpages->next()) $result[] = $page->getName(); $this->assertEquals(5, count($result), "limit 5"); @@ -30,13 +36,23 @@ class TextSearchTest extends phpwiki_TestCase { function testFulltextSearch() { global $request; - $query = new TextSearchQuery('Indent the paragraph*', true); // auto $dbi = $request->getDbh(); + + $query = new TextSearchQuery('Indent the paragraph*', true); // auto + $pages = $dbi->fullSearch($query); + $result = array(); + while ($page = $pages->next()) + $result[] = $page->getName(); + + $this->assertTrue(in_array("TextFormattingRules", $result), "found all"); + + $query = new TextSearchQuery('"Indent the paragraph"', false); // case-insensitive, auto $pages = $dbi->fullSearch($query); + $result = array(); while ($page = $pages->next()) $result[] = $page->getName(); + $this->assertTrue(in_array("TextFormattingRules", $result), "found phrase"); - $this->assertTrue(in_array("TextFormattingRules", $result), "found TextFormattingRules"); } } -- 2.45.0