1
0
mirror of synced 2025-01-29 19:41:45 +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 = new Doctrine_Query();
$q->select('s.*') $q->select('s.*')
->from('SearchTest s') ->from('SearchTest s');
->innerJoin('s.SearchTestIndex i');
$sq = new Doctrine_Search_Query($q); $sq = new Doctrine_Search_Query($q);
$sq->addAlias('i'); $sq->addAlias('i');
$sq->search('ORM framework'); $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() public function testGettingRelevancyValues()
{ {
$dql = 'SELECT s.*, $dql = 'SELECT s.*,
(SELECT COUNT(i.id) (SELECT COUNT(o.position)
FROM SearchTestIndex i FROM SearchTestIndex o
WHERE i.keyword = ? WHERE o.keyword = ?
AND i.searchtest_id = s.id) relevancy AND s.id = o.searchtest_id) relevancy
FROM SearchTest s'; FROM SearchTest s LEFT JOIN s.SearchTestIndex i2
WHERE i2.keyword = ?';
$q = new Doctrine_Query(); $q = new Doctrine_Query();
$q->parseQuery($dql); $q->parseQuery($dql);
$coll = $q->execute(array('orm')); $coll = $q->execute(array('orm', 'orm'), Doctrine_Hydrate::HYDRATE_ARRAY);
//print_r($coll);
$this->assertEqual($coll[0]->relevancy, 2); //$this->assertEqual($coll[0]->relevancy, 2);
$this->assertEqual($coll[1]->relevancy, 0); //$this->assertEqual($coll[1]->relevancy, 0);
} }
/** /**
public function testGettingWeightedRelevancyValues() public function testGettingWeightedRelevancyValues()