1
0
mirror of synced 2024-12-14 07:06:04 +03:00

tests for wildcards

This commit is contained in:
zYne 2007-08-02 12:01:22 +00:00
parent af100642e1
commit 36fa8016e7

View File

@ -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');