2008-07-21 00:13:24 +04:00
|
|
|
<?php
|
|
|
|
require_once 'lib/DoctrineTestInit.php';
|
|
|
|
|
|
|
|
class Orm_Associations_OneToOneMappingTest extends Doctrine_OrmTestCase
|
|
|
|
{
|
|
|
|
public function testCorrectOneToOneBidirectionalMapping()
|
|
|
|
{
|
|
|
|
$owningSideMapping = array(
|
|
|
|
'fieldName' => 'address',
|
|
|
|
'targetEntity' => 'Address',
|
|
|
|
'joinColumns' => array('address_id' => 'id'),
|
2008-08-16 23:40:59 +04:00
|
|
|
'sourceEntity' => 'Person', // This is normally filled by ClassMetadata
|
2008-07-21 00:13:24 +04:00
|
|
|
);
|
|
|
|
|
2008-09-12 13:26:43 +04:00
|
|
|
$oneToOneMapping = new Doctrine_ORM_Mapping_OneToOneMapping($owningSideMapping);
|
2008-07-21 00:13:24 +04:00
|
|
|
|
|
|
|
$this->assertEquals(array('address_id' => 'id'), $oneToOneMapping->getSourceToTargetKeyColumns());
|
|
|
|
$this->assertEquals(array('id' => 'address_id'), $oneToOneMapping->getTargetToSourceKeyColumns());
|
|
|
|
$this->assertEquals('Address', $oneToOneMapping->getTargetEntityName());
|
|
|
|
$this->assertEquals('Person', $oneToOneMapping->getSourceEntityName());
|
|
|
|
$this->assertEquals('address', $oneToOneMapping->getSourceFieldName());
|
|
|
|
$this->assertTrue($oneToOneMapping->isOwningSide());
|
|
|
|
|
|
|
|
|
|
|
|
$inverseSideMapping = array(
|
2008-08-16 23:40:59 +04:00
|
|
|
'fieldName' => 'person',
|
|
|
|
'sourceEntity' => 'Address',
|
|
|
|
'targetEntity' => 'Person',
|
2008-07-21 00:13:24 +04:00
|
|
|
'mappedBy' => 'address'
|
|
|
|
);
|
|
|
|
|
2008-09-12 13:26:43 +04:00
|
|
|
$oneToOneMapping = new Doctrine_ORM_Mapping_OneToOneMapping($inverseSideMapping);
|
2008-07-21 00:13:24 +04:00
|
|
|
$this->assertEquals('address', $oneToOneMapping->getMappedByFieldName());
|
2008-08-16 23:40:59 +04:00
|
|
|
$this->assertEquals('Address', $oneToOneMapping->getSourceEntityName());
|
|
|
|
$this->assertEquals('Person', $oneToOneMapping->getTargetEntityName());
|
2008-07-21 00:13:24 +04:00
|
|
|
$this->assertTrue($oneToOneMapping->isInverseSide());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
?>
|