1
0
Fork 0
mirror of synced 2025-04-03 13:23:37 +03:00

Fix bug introduced in recent XmlDriver commit

This commit is contained in:
Benjamin Eberlei 2011-11-15 20:03:13 +01:00
parent 14f20c16bc
commit a0ee72f264
2 changed files with 48 additions and 47 deletions

View file

@ -171,7 +171,7 @@ class XmlDriver extends AbstractFileDriver
if (isset($fieldMapping['type'])) { if (isset($fieldMapping['type'])) {
$mapping['type'] = (string)$fieldMapping['type']; $mapping['type'] = (string)$fieldMapping['type'];
} }
if (isset($fieldMapping['column'])) { if (isset($fieldMapping['column'])) {
$mapping['columnName'] = (string)$fieldMapping['column']; $mapping['columnName'] = (string)$fieldMapping['column'];
} }
@ -224,8 +224,8 @@ class XmlDriver extends AbstractFileDriver
'id' => true, 'id' => true,
'fieldName' => (string)$idElement['name'] 'fieldName' => (string)$idElement['name']
); );
if (isset($fieldMapping['type'])) { if (isset($idElement['type'])) {
$mapping['type'] = (string)$idElement['type']; $mapping['type'] = (string)$idElement['type'];
} }

View file

@ -64,7 +64,7 @@ abstract class AbstractMappingDriverTest extends \Doctrine\Tests\OrmTestCase
{ {
$this->assertArrayHasKey('uniqueConstraints', $class->table, $this->assertArrayHasKey('uniqueConstraints', $class->table,
'ClassMetadata should have uniqueConstraints key in table property when Unique Constraints are set.'); 'ClassMetadata should have uniqueConstraints key in table property when Unique Constraints are set.');
$this->assertEquals(array( $this->assertEquals(array(
"search_idx" => array("columns" => array("name", "user_email")) "search_idx" => array("columns" => array("name", "user_email"))
), $class->table['uniqueConstraints']); ), $class->table['uniqueConstraints']);
@ -138,6 +138,7 @@ abstract class AbstractMappingDriverTest extends \Doctrine\Tests\OrmTestCase
public function testIdentifier($class) public function testIdentifier($class)
{ {
$this->assertEquals(array('id'), $class->identifier); $this->assertEquals(array('id'), $class->identifier);
$this->assertEquals('integer', $class->fieldMappings['id']['type']);
$this->assertEquals(ClassMetadata::GENERATOR_TYPE_AUTO, $class->generatorType, "ID-Generator is not ClassMetadata::GENERATOR_TYPE_AUTO"); $this->assertEquals(ClassMetadata::GENERATOR_TYPE_AUTO, $class->generatorType, "ID-Generator is not ClassMetadata::GENERATOR_TYPE_AUTO");
return $class; return $class;
@ -291,7 +292,7 @@ abstract class AbstractMappingDriverTest extends \Doctrine\Tests\OrmTestCase
$class->discriminatorColumn $class->discriminatorColumn
); );
} }
/** /**
* @group DDC-869 * @group DDC-869
*/ */
@ -300,34 +301,34 @@ abstract class AbstractMappingDriverTest extends \Doctrine\Tests\OrmTestCase
$driver = $this->_loadDriver(); $driver = $this->_loadDriver();
$em = $this->_getTestEntityManager(); $em = $this->_getTestEntityManager();
$factory = new \Doctrine\ORM\Mapping\ClassMetadataFactory(); $factory = new \Doctrine\ORM\Mapping\ClassMetadataFactory();
$em->getConfiguration()->setMetadataDriverImpl($driver); $em->getConfiguration()->setMetadataDriverImpl($driver);
$factory->setEntityManager($em); $factory->setEntityManager($em);
$class = $factory->getMetadataFor('Doctrine\Tests\Models\DDC869\DDC869CreditCardPayment'); $class = $factory->getMetadataFor('Doctrine\Tests\Models\DDC869\DDC869CreditCardPayment');
$this->assertTrue(isset($class->fieldMappings['id'])); $this->assertTrue(isset($class->fieldMappings['id']));
$this->assertTrue(isset($class->fieldMappings['value'])); $this->assertTrue(isset($class->fieldMappings['value']));
$this->assertTrue(isset($class->fieldMappings['creditCardNumber'])); $this->assertTrue(isset($class->fieldMappings['creditCardNumber']));
$this->assertEquals($class->customRepositoryClassName, "Doctrine\Tests\Models\DDC869\DDC869PaymentRepository"); $this->assertEquals($class->customRepositoryClassName, "Doctrine\Tests\Models\DDC869\DDC869PaymentRepository");
$this->assertInstanceOf("Doctrine\Tests\Models\DDC869\DDC869PaymentRepository", $this->assertInstanceOf("Doctrine\Tests\Models\DDC869\DDC869PaymentRepository",
$em->getRepository("Doctrine\Tests\Models\DDC869\DDC869CreditCardPayment")); $em->getRepository("Doctrine\Tests\Models\DDC869\DDC869CreditCardPayment"));
$this->assertTrue($em->getRepository("Doctrine\Tests\Models\DDC869\DDC869ChequePayment")->isTrue()); $this->assertTrue($em->getRepository("Doctrine\Tests\Models\DDC869\DDC869ChequePayment")->isTrue());
$class = $factory->getMetadataFor('Doctrine\Tests\Models\DDC869\DDC869ChequePayment'); $class = $factory->getMetadataFor('Doctrine\Tests\Models\DDC869\DDC869ChequePayment');
$this->assertTrue(isset($class->fieldMappings['id'])); $this->assertTrue(isset($class->fieldMappings['id']));
$this->assertTrue(isset($class->fieldMappings['value'])); $this->assertTrue(isset($class->fieldMappings['value']));
$this->assertTrue(isset($class->fieldMappings['serialNumber'])); $this->assertTrue(isset($class->fieldMappings['serialNumber']));
$this->assertEquals($class->customRepositoryClassName, "Doctrine\Tests\Models\DDC869\DDC869PaymentRepository"); $this->assertEquals($class->customRepositoryClassName, "Doctrine\Tests\Models\DDC869\DDC869PaymentRepository");
$this->assertInstanceOf("Doctrine\Tests\Models\DDC869\DDC869PaymentRepository", $this->assertInstanceOf("Doctrine\Tests\Models\DDC869\DDC869PaymentRepository",
$em->getRepository("Doctrine\Tests\Models\DDC869\DDC869ChequePayment")); $em->getRepository("Doctrine\Tests\Models\DDC869\DDC869ChequePayment"));
$this->assertTrue($em->getRepository("Doctrine\Tests\Models\DDC869\DDC869ChequePayment")->isTrue()); $this->assertTrue($em->getRepository("Doctrine\Tests\Models\DDC869\DDC869ChequePayment")->isTrue());
} }
/** /**
* @group DDC-1476 * @group DDC-1476
*/ */
@ -336,40 +337,40 @@ abstract class AbstractMappingDriverTest extends \Doctrine\Tests\OrmTestCase
$driver = $this->_loadDriver(); $driver = $this->_loadDriver();
$em = $this->_getTestEntityManager(); $em = $this->_getTestEntityManager();
$factory = new \Doctrine\ORM\Mapping\ClassMetadataFactory(); $factory = new \Doctrine\ORM\Mapping\ClassMetadataFactory();
$em->getConfiguration()->setMetadataDriverImpl($driver); $em->getConfiguration()->setMetadataDriverImpl($driver);
$factory->setEntityManager($em); $factory->setEntityManager($em);
$class = $factory->getMetadataFor('Doctrine\Tests\Models\DDC1476\DDC1476EntityWithDefaultFieldType'); $class = $factory->getMetadataFor('Doctrine\Tests\Models\DDC1476\DDC1476EntityWithDefaultFieldType');
$this->assertArrayHasKey('id', $class->fieldMappings); $this->assertArrayHasKey('id', $class->fieldMappings);
$this->assertArrayHasKey('name', $class->fieldMappings); $this->assertArrayHasKey('name', $class->fieldMappings);
$this->assertArrayHasKey('type', $class->fieldMappings['id']); $this->assertArrayHasKey('type', $class->fieldMappings['id']);
$this->assertArrayHasKey('type', $class->fieldMappings['name']); $this->assertArrayHasKey('type', $class->fieldMappings['name']);
$this->assertEquals('string', $class->fieldMappings['id']['type']); $this->assertEquals('string', $class->fieldMappings['id']['type']);
$this->assertEquals('string', $class->fieldMappings['name']['type']); $this->assertEquals('string', $class->fieldMappings['name']['type']);
$this->assertArrayHasKey('fieldName', $class->fieldMappings['id']); $this->assertArrayHasKey('fieldName', $class->fieldMappings['id']);
$this->assertArrayHasKey('fieldName', $class->fieldMappings['name']); $this->assertArrayHasKey('fieldName', $class->fieldMappings['name']);
$this->assertEquals('id', $class->fieldMappings['id']['fieldName']); $this->assertEquals('id', $class->fieldMappings['id']['fieldName']);
$this->assertEquals('name', $class->fieldMappings['name']['fieldName']); $this->assertEquals('name', $class->fieldMappings['name']['fieldName']);
$this->assertArrayHasKey('columnName', $class->fieldMappings['id']); $this->assertArrayHasKey('columnName', $class->fieldMappings['id']);
$this->assertArrayHasKey('columnName', $class->fieldMappings['name']); $this->assertArrayHasKey('columnName', $class->fieldMappings['name']);
$this->assertEquals('id', $class->fieldMappings['id']['columnName']); $this->assertEquals('id', $class->fieldMappings['id']['columnName']);
$this->assertEquals('name', $class->fieldMappings['name']['columnName']); $this->assertEquals('name', $class->fieldMappings['name']['columnName']);
$this->assertEquals(ClassMetadataInfo::GENERATOR_TYPE_NONE, $class->generatorType); $this->assertEquals(ClassMetadataInfo::GENERATOR_TYPE_NONE, $class->generatorType);
} }
} }
@ -480,15 +481,15 @@ class User
$metadata->mapOneToOne(array( $metadata->mapOneToOne(array(
'fieldName' => 'address', 'fieldName' => 'address',
'targetEntity' => 'Doctrine\\Tests\\ORM\\Mapping\\Address', 'targetEntity' => 'Doctrine\\Tests\\ORM\\Mapping\\Address',
'cascade' => 'cascade' =>
array( array(
0 => 'remove', 0 => 'remove',
), ),
'mappedBy' => NULL, 'mappedBy' => NULL,
'inversedBy' => 'user', 'inversedBy' => 'user',
'joinColumns' => 'joinColumns' =>
array( array(
0 => 0 =>
array( array(
'name' => 'address_id', 'name' => 'address_id',
'referencedColumnName' => 'id', 'referencedColumnName' => 'id',
@ -500,13 +501,13 @@ class User
$metadata->mapOneToMany(array( $metadata->mapOneToMany(array(
'fieldName' => 'phonenumbers', 'fieldName' => 'phonenumbers',
'targetEntity' => 'Doctrine\\Tests\\ORM\\Mapping\\Phonenumber', 'targetEntity' => 'Doctrine\\Tests\\ORM\\Mapping\\Phonenumber',
'cascade' => 'cascade' =>
array( array(
1 => 'persist', 1 => 'persist',
), ),
'mappedBy' => 'user', 'mappedBy' => 'user',
'orphanRemoval' => true, 'orphanRemoval' => true,
'orderBy' => 'orderBy' =>
array( array(
'number' => 'ASC', 'number' => 'ASC',
), ),
@ -514,7 +515,7 @@ class User
$metadata->mapManyToMany(array( $metadata->mapManyToMany(array(
'fieldName' => 'groups', 'fieldName' => 'groups',
'targetEntity' => 'Doctrine\\Tests\\ORM\\Mapping\\Group', 'targetEntity' => 'Doctrine\\Tests\\ORM\\Mapping\\Group',
'cascade' => 'cascade' =>
array( array(
0 => 'remove', 0 => 'remove',
1 => 'persist', 1 => 'persist',
@ -523,12 +524,12 @@ class User
4 => 'detach', 4 => 'detach',
), ),
'mappedBy' => NULL, 'mappedBy' => NULL,
'joinTable' => 'joinTable' =>
array( array(
'name' => 'cms_users_groups', 'name' => 'cms_users_groups',
'joinColumns' => 'joinColumns' =>
array( array(
0 => 0 =>
array( array(
'name' => 'user_id', 'name' => 'user_id',
'referencedColumnName' => 'id', 'referencedColumnName' => 'id',
@ -536,9 +537,9 @@ class User
'nullable' => false, 'nullable' => false,
), ),
), ),
'inverseJoinColumns' => 'inverseJoinColumns' =>
array( array(
0 => 0 =>
array( array(
'name' => 'group_id', 'name' => 'group_id',
'referencedColumnName' => 'id', 'referencedColumnName' => 'id',
@ -576,7 +577,7 @@ abstract class Animal
public static function loadMetadata(ClassMetadataInfo $metadata) public static function loadMetadata(ClassMetadataInfo $metadata)
{ {
} }
} }
@ -585,7 +586,7 @@ class Cat extends Animal
{ {
public static function loadMetadata(ClassMetadataInfo $metadata) public static function loadMetadata(ClassMetadataInfo $metadata)
{ {
} }
} }
@ -594,6 +595,6 @@ class Dog extends Animal
{ {
public static function loadMetadata(ClassMetadataInfo $metadata) public static function loadMetadata(ClassMetadataInfo $metadata)
{ {
} }
} }