$articleRelation->relateObject($comment1, $article1); $t->is($comment1->getArticleId(), $article1->getId(), 'relateObject() creates a relation between two Propel objects'); $categoryRelation->relateObject($comment1, $category1); $t->is($article1->getCategoryId(), $category1->getId(), 'relateObject() creates a relation between two Propel objects via another relation'); /********************************************************************/ /* sfPropelFinderRelation::relateObject() and multiple foreign keys */ /********************************************************************/ $t->diag('sfPropelFinderRelation::relateObject() and multiple foreign keys'); CivilityPeer::doDeleteAll(); HumanPeer::doDeleteAll(); HousePeer::doDeleteAll(); $civility1 = new Civility(); $civility1->setIsMan(true); $civility1->save(); $human1 = new Human(); $human1->setName('John'); $human1->save(); $house1 = new House(); $house1->setName('Home1'); $house1->save(); $manager = new sfPropelFinderRelationManager('House'); $ownerRelation = $manager->addRelationFromColumns('House', HousePeer::OWNER_ID, 'Human', HumanPeer::ID, 'owner'); $civilityRelation = $manager->guessRelation('Civility'); $manager[] = $civilityRelation; $ownerRelation->relateObject($house1, $human1);
leftJoin('Article')->with('Article'); $comments = $finder->find(); $latestQuery = $finder->getLatestQuery(); $t->is($comments[0]->getAuthor(), null, 'First object has no author'); $t->is(Propel::getConnection()->getLastExecutedQuery(), $latestQuery, 'Related hydration occurred correctly'); $t->isnt($comments[0]->getArticle(), null, 'First object has an article'); $t->is(Propel::getConnection()->getLastExecutedQuery(), $latestQuery, 'Related hydration occurred correctly'); $t->isnt($comments[1]->getAuthor(), null, 'Second object has an author'); $t->is(Propel::getConnection()->getLastExecutedQuery(), $latestQuery, 'Related hydration occurred correctly'); $t->isnt($comments[1]->getArticle(), null, 'Second object has an article'); $t->is(Propel::getConnection()->getLastExecutedQuery(), $latestQuery, 'Related hydration occurred correctly'); $t->diag('sfPropelFinder::with() and exotic phpNames'); CivilityPeer::doDeleteAll(); HumanPeer::doDeleteAll(); $civility1 = new Civility(); $civility1->setIsMan(true); $civility1->save(); $person1 = new Person(); $person1->setName('John'); $person1->setCivility($civility1); $person1->save(); $finder = sfPropelFinder::from('Person')-> with('Civility'); $person = $finder->findOne(); $latestQuery = $finder->getLatestQuery(); $t->is($person->getCivility()->getIsMan(), true, 'Related Objects with a non-natural phpName get hydrated correctly'); $t->is(Propel::getConnection()->getLastExecutedQuery(), $latestQuery, 'Related hydration occurred correctly');