$t->is($human->getName(), 'Albert', 'with() with self-referenced foreign keys does not change the main object hyration'); $t->is($human->getHumanRelatedByFatherId()->getName(), 'John', 'with() with self-referenced foreign keys hydrates the related objects'); $t->is(Propel::getConnection()->getLastExecutedQuery(), $sql, 'with() with self-referenced foreign keys avoids subsequent queries'); /******************************/ /* sfPropelFinder::withI18n() */ /******************************/ $t->diag('sfPropelFinder::withI18n()'); CommentPeer::doDeleteAll(); ArticlePeer::doDeleteAll(); ArticleI18nPeer::doDeleteAll(); $article1 = new Article(); $article1->setTitle('aaa'); $article1->setCulture('en'); $article1->setContent('english content'); $article1->setCulture('fr'); $article1->setContent('contenu français'); $article1->save(); $baseSQL = 'SELECT article.ID, article.TITLE, article.CATEGORY_ID, article_i18n.CONTENT, article_i18n.ID, article_i18n.CULTURE FROM article INNER JOIN article_i18n ON (article.ID=article_i18n.ID) '; sfContext::getInstance()->getUser()->setCulture('en'); $finder = sfPropelFinder::from('Article')-> withI18n(); $article = $finder->findOne(); $query = $baseSQL . 'WHERE article_i18n.CULTURE=\'en\' LIMIT 1'; $t->is($finder->getLatestQuery(), $query, 'withI18n() hydrates the related I18n object with a culture taken from the user object'); $t->is($article->getContent(), 'english content', 'withI18n() considers the current user culture for hydration'); $t->is(Propel::getConnection()->getLastExecutedQuery(), $query, 'withI18n() hydrates the i18n object so that no further query is necessary');