1
0
mirror of synced 2025-01-17 22:11:41 +03:00
This commit is contained in:
zYne 2007-07-16 18:46:25 +00:00
parent 5b4c4ffd65
commit ca9b3fb66b

View File

@ -62,33 +62,38 @@ class Doctrine_Search_Query_TestCase extends Doctrine_UnitTestCase
{
$q = new Doctrine_Query();
$q->select('s.*')
->from('SearchTest s')
->innerJoin('s.SearchTestIndex i');
->from('SearchTest s');
$sq = new Doctrine_Search_Query($q);
$sq->addAlias('i');
$sq->search('ORM framework');
$coll = $sq->execute();
//print $q->getDql();
//$coll = $sq->execute();
//$this->assertEqual($coll[0]->relevancy, 2);
//$this->assertEqual($coll[1]->relevancy, 0);
}
public function testGettingRelevancyValues()
{
$dql = 'SELECT s.*,
(SELECT COUNT(i.id)
FROM SearchTestIndex i
WHERE i.keyword = ?
AND i.searchtest_id = s.id) relevancy
FROM SearchTest s';
$dql = 'SELECT s.*,
(SELECT COUNT(o.position)
FROM SearchTestIndex o
WHERE o.keyword = ?
AND s.id = o.searchtest_id) relevancy
FROM SearchTest s LEFT JOIN s.SearchTestIndex i2
WHERE i2.keyword = ?';
$q = new Doctrine_Query();
$q->parseQuery($dql);
$coll = $q->execute(array('orm'));
$this->assertEqual($coll[0]->relevancy, 2);
$this->assertEqual($coll[1]->relevancy, 0);
$coll = $q->execute(array('orm', 'orm'), Doctrine_Hydrate::HYDRATE_ARRAY);
//print_r($coll);
//$this->assertEqual($coll[0]->relevancy, 2);
//$this->assertEqual($coll[1]->relevancy, 0);
}
/**
public function testGettingWeightedRelevancyValues()