Merge branch 'DDC-1799'
This commit is contained in:
commit
9ae5b8f442
@ -171,7 +171,13 @@ class YamlExporter extends AbstractExporter
|
||||
);
|
||||
|
||||
$associationMappingArray = array_merge($associationMappingArray, $oneToOneMappingArray);
|
||||
$array['oneToOne'][$name] = $associationMappingArray;
|
||||
|
||||
if ($associationMapping['type'] & ClassMetadataInfo::ONE_TO_ONE) {
|
||||
$array['oneToOne'][$name] = $associationMappingArray;
|
||||
} else {
|
||||
$array['manyToOne'][$name] = $associationMappingArray;
|
||||
}
|
||||
|
||||
} else if ($associationMapping['type'] == ClassMetadataInfo::ONE_TO_MANY) {
|
||||
$oneToManyMappingArray = array(
|
||||
'mappedBy' => $associationMapping['mappedBy'],
|
||||
|
@ -68,10 +68,10 @@ abstract class AbstractClassMetadataExporterTest extends \Doctrine\Tests\OrmTest
|
||||
protected function _createMetadataDriver($type, $path)
|
||||
{
|
||||
$mappingDriver = array(
|
||||
'php' => 'PHPDriver',
|
||||
'php' => 'PHPDriver',
|
||||
'annotation' => 'AnnotationDriver',
|
||||
'xml' => 'XmlDriver',
|
||||
'yaml' => 'YamlDriver',
|
||||
'xml' => 'XmlDriver',
|
||||
'yaml' => 'YamlDriver',
|
||||
);
|
||||
$this->assertArrayHasKey($type, $mappingDriver, "There is no metadata driver for the type '" . $type . "'.");
|
||||
$driverName = $mappingDriver[$type];
|
||||
@ -190,7 +190,7 @@ abstract class AbstractClassMetadataExporterTest extends \Doctrine\Tests\OrmTest
|
||||
* @depends testIdentifierIsExported
|
||||
* @param ClassMetadataInfo $class
|
||||
*/
|
||||
public function testFieldsAreExpored($class)
|
||||
public function testFieldsAreExported($class)
|
||||
{
|
||||
$this->assertTrue(isset($class->fieldMappings['id']['id']) && $class->fieldMappings['id']['id'] === true);
|
||||
$this->assertEquals('id', $class->fieldMappings['id']['fieldName']);
|
||||
@ -211,13 +211,12 @@ abstract class AbstractClassMetadataExporterTest extends \Doctrine\Tests\OrmTest
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testFieldsAreExpored
|
||||
* @depends testFieldsAreExported
|
||||
* @param ClassMetadataInfo $class
|
||||
*/
|
||||
public function testOneToOneAssociationsAreExported($class)
|
||||
{
|
||||
$this->assertTrue(isset($class->associationMappings['address']));
|
||||
//$this->assertInstanceOf('Doctrine\ORM\Mapping\OneToOneMapping', $class->associationMappings['address']);
|
||||
$this->assertEquals('Doctrine\Tests\ORM\Tools\Export\Address', $class->associationMappings['address']['targetEntity']);
|
||||
$this->assertEquals('address_id', $class->associationMappings['address']['joinColumns'][0]['name']);
|
||||
$this->assertEquals('id', $class->associationMappings['address']['joinColumns'][0]['referencedColumnName']);
|
||||
@ -233,6 +232,15 @@ abstract class AbstractClassMetadataExporterTest extends \Doctrine\Tests\OrmTest
|
||||
return $class;
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testFieldsAreExported
|
||||
*/
|
||||
public function testManyToOneAssociationsAreExported($class)
|
||||
{
|
||||
$this->assertTrue(isset($class->associationMappings['mainGroup']));
|
||||
$this->assertEquals('Doctrine\Tests\ORM\Tools\Export\Group', $class->associationMappings['mainGroup']['targetEntity']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testOneToOneAssociationsAreExported
|
||||
* @param ClassMetadataInfo $class
|
||||
|
@ -28,6 +28,11 @@ class User
|
||||
*/
|
||||
public $address;
|
||||
|
||||
/**
|
||||
* @ManyToOne(targetEntity="Doctrine\Tests\ORM\Tools\Export\Group")
|
||||
*/
|
||||
public $mainGroup;
|
||||
|
||||
/**
|
||||
*
|
||||
* @OneToMany(targetEntity="Doctrine\Tests\ORM\Tools\Export\Phonenumber", mappedBy="user", cascade={"persist", "merge"}, orphanRemoval=true)
|
||||
|
@ -31,6 +31,10 @@ $metadata->mapField(array(
|
||||
'columnDefinition' => 'CHAR(32) NOT NULL',
|
||||
));
|
||||
$metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_AUTO);
|
||||
$metadata->mapManyToOne(array(
|
||||
'fieldName' => 'mainGroup',
|
||||
'targetEntity' => 'Doctrine\\Tests\\ORM\Tools\\Export\\Group',
|
||||
));
|
||||
$metadata->mapOneToOne(array(
|
||||
'fieldName' => 'address',
|
||||
'targetEntity' => 'Doctrine\\Tests\\ORM\\Tools\\Export\\Address',
|
||||
|
@ -25,6 +25,8 @@
|
||||
<join-column name="address_id" referenced-column-name="id" on-delete="CASCADE" on-update="CASCADE"/>
|
||||
</one-to-one>
|
||||
|
||||
<many-to-one field="mainGroup" target-entity="Doctrine\Tests\ORM\Tools\Export\Group" />
|
||||
|
||||
<one-to-many field="phonenumbers" target-entity="Doctrine\Tests\ORM\Tools\Export\Phonenumber" mapped-by="user" orphan-removal="true">
|
||||
<cascade>
|
||||
<cascade-persist/>
|
||||
|
@ -26,6 +26,9 @@ Doctrine\Tests\ORM\Tools\Export\User:
|
||||
cascade: [ persist ]
|
||||
inversedBy: user
|
||||
orphanRemoval: true
|
||||
manyToOne:
|
||||
mainGroup:
|
||||
targetEntity: Doctrine\Tests\ORM\Tools\Export\Group
|
||||
oneToMany:
|
||||
phonenumbers:
|
||||
targetEntity: Doctrine\Tests\ORM\Tools\Export\Phonenumber
|
||||
|
Loading…
Reference in New Issue
Block a user