From 36fa8016e74c6905e7f5c84a4fc533c29a77e049 Mon Sep 17 00:00:00 2001 From: zYne Date: Thu, 2 Aug 2007 12:01:22 +0000 Subject: [PATCH] tests for wildcards --- tests/Search/QueryTestCase.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/Search/QueryTestCase.php b/tests/Search/QueryTestCase.php index 09c396c3c..8b59b74b2 100644 --- a/tests/Search/QueryTestCase.php +++ b/tests/Search/QueryTestCase.php @@ -269,6 +269,34 @@ class Doctrine_Search_Query_TestCase extends Doctrine_UnitTestCase $this->assertEqual($q->getSql(), $sql); } + public function testQuerySupportsMultiWordSearchAndSingleLetterWildcards() + { + $q = new Doctrine_Search_Query('SearchTestIndex'); + $q->search('doct?ine orm'); + + $sql = 'SELECT COUNT(keyword) AS relevance, search_test_id ' + . 'FROM search_test_index ' + . 'WHERE search_test_id IN (SELECT search_test_id FROM search_test_index WHERE keyword LIKE ?) ' + . 'AND search_test_id IN (SELECT search_test_id FROM search_test_index WHERE keyword = ?) ' + . 'GROUP BY search_test_id ORDER BY relevance'; + + $this->assertEqual($q->getParams(), array('doct?ine', 'orm')); + $this->assertEqual($q->getSql(), $sql); + } + public function testQuerySupportsMultiWordSearchAndMultiLetterWildcards() + { + $q = new Doctrine_Search_Query('SearchTestIndex'); + $q->search('doc* orm'); + + $sql = 'SELECT COUNT(keyword) AS relevance, search_test_id ' + . 'FROM search_test_index ' + . 'WHERE search_test_id IN (SELECT search_test_id FROM search_test_index WHERE keyword LIKE ?) ' + . 'AND search_test_id IN (SELECT search_test_id FROM search_test_index WHERE keyword = ?) ' + . 'GROUP BY search_test_id ORDER BY relevance'; + + $this->assertEqual($q->getParams(), array('doc%', 'orm')); + $this->assertEqual($q->getSql(), $sql); + } public function testSearchSupportsMultipleTermsWithQuotes() { $q = new Doctrine_Search_Query('SearchTestIndex');