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