$t->diag('sfDoctrineFinderPager issues with GroupBy'); $finder = sfDoctrineFinder::from('DArticle')->groupBy('Title'); $pager = new sfDoctrineFinderPager('DArticle', 2); $pager->setFinder($finder); $pager->init(); //$t->is($finder->getLatestQuery(), 'SELECT COUNT(DISTINCT d.id) AS num_results FROM d_article d', 'sfDoctrineFinderPager::init() removes groupBy clauses and issues a count()'); $t->skip('sfDoctrineFinderPager::init() removes groupBy clauses and issues a count() (bug in sfDoctrinePager)'); $pager->getResults(); $t->is($finder->getLatestQuery(), 'SELECT d.id AS d__id, d.title AS d__title, d.category_id AS d__category_id FROM d_article d GROUP BY d.title LIMIT 2', 'sfDoctrineFinderPager::getResults() does not remove groupBy clauses and issues a select()'); $t->diag('sfDoctrineFinderPager issues with object finders classes'); class DArticleFinder extends sfDoctrineFinder { protected $class = 'DArticle'; } $finder = new DArticleFinder(); try { $pager = $finder->paginate(); $t->pass('Children of sfDoctrineFinder can use paginate()'); } catch(sfException $e) { $t->fail('Children of sfDoctrineFinder can use paginate()'); } $t->diag('sfDoctrineFinderPager issues with repeated criterions'); $finder = sfDoctrineFinder::from('DArticle')-> where('Title', 'foo')-> where('CategoryId', 1);
$finder = new sfDoctrineFinder(); $finder->setClass('DArticle'); $t->is($finder->getClass(), 'DArticle', 'setClass() and getClass() are accesors to the protected $class property'); $article = $finder->findOne(); $t->isa_ok($article, 'DArticle', 'A finder instanciated directly with a Record class returns the correct objects'); $t->is($article->getTitle(), 'foo', 'A finder can be instanciated without parameter, and initialized later after defining its class'); $articles = sfDoctrineFinder::from('DArticle')->find(); $t->is(count($articles), 3, 'from() allows direct chaining of conditions'); class DArticleFinder extends sfDoctrineFinder { protected $class = 'DArticle'; } $finder = new DArticleFinder(); $article = $finder->findOne(); $t->isa_ok($article, 'DArticle', 'A finder extending sfDoctrineFinder can be used directly if defining the $class property'); $finder = new DArticleFinder(); $articles = $finder->find(); $t->is(count($articles), 3, 'A finder extending sfDoctrineFinder can be used directly if defining the $class property'); Doctrine_Query::create()->delete()->from('DArticle')->execute(); Doctrine_Query::create()->delete()->from('DCategory')->execute(); $category1 = new DCategory(); $category1->setName('cat1'); $category1->save(); $category2 = new DCategory(); $category2->setName('cat2'); $category2->save(); $article1 = new DArticle(); $article1->setTitle('aaaaa'); $article1->setCategory($category1); $article1->save(); $article2 = new DArticle();