catch (Exception $e)
{
  $exceptionThrown = true;
}
$t->is($exceptionThrown, false, 'guessRelation() guesses relationships via already related classes (2 steps)');

/*****************************************************************************/
/* sfPropelFinderRelationManager::guessRelation() and unusual class phpNames */
/*****************************************************************************/

$t->diag('sfPropelFinderRelationManager::guessRelation() and unusual class phpNames');

$manager = new sfPropelFinderRelationManager('Person');
try 
{
  $manager->guessRelation('Club');
  $exceptionThrown = false;
} 
catch (Exception $e) 
{
  $exceptionThrown = true;
}
$t->is($exceptionThrown, false, 'guessRelation() can find a relation when the local name is not foreign_table_id');

try 
{
  $manager->guessRelation('Civility');
  $exceptionThrown = false;
} 
catch (Exception $e) 
{
コード例 #2
0
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);
$t->is($house1->getOwnerId(), $human1->getId(), 'relateObject() creates a relation between two Propel objects');
$civilityRelation->relateObject($house1, $civility1);
$t->is($human1->getTheSex(), $civility1->getId(), 'relateObject() creates a relation between two Propel objects via another relation');

/******************************************************/
/* sfPropelFinderRelation::relateObject() and aliases */
/******************************************************/

$t->diag('sfPropelFinderRelation::relateObject() and aliases');

HumanPeer::doDeleteAll();
$human1 = new Human();