$article1->setTitle('foo'); $article1->save(); $article2 = new DArticle(); $article2->setTitle('foo2'); $article2->save(); $article3 = new DArticle(); $article3->setTitle('foo3'); $article3->save(); $finder = new sfDoctrineFinder('DArticle'); $t->is($finder->getClass(), 'DArticle', 'Record Class can be set during instanciation, in which case the finder is automatically initialized'); $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 instanciated directly with a Record class returns the correct objects'); $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');