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