diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadata.php b/lib/Doctrine/ORM/Mapping/ClassMetadata.php index e20dd578e..07c65fd47 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadata.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadata.php @@ -62,12 +62,15 @@ class ClassMetadata extends ClassMetadataInfo implements IClassMetadata * * @param string $entityName The name of the entity class the new instance is used for. */ - public function __construct($entityName) + public function initializeReflection($reflService) { - $this->reflClass = new ReflectionClass($entityName); - $this->namespace = $this->reflClass->getNamespaceName(); - $this->table['name'] = $this->reflClass->getShortName(); - parent::__construct($this->reflClass->getName()); // do not use $entityName, possible case-problems + $this->reflClass = $reflService->getClass($this->name); + $this->namespace = $reflService->getClassNamespace($this->name); + $this->table['name'] = $reflService->getClassShortName($this->name); + + if ($this->reflClass) { + $this->name = $this->rootEntityName = $this->reflClass->getName(); + } } /** @@ -324,37 +327,6 @@ class ClassMetadata extends ClassMetadataInfo implements IClassMetadata return $serialized; } - /** - * Restores some state that can not be serialized/unserialized. - * - * @param ReflectionService $reflService - * @return void - */ - public function wakeupReflection($reflService) - { - // Restore ReflectionClass and properties - $this->reflClass = $reflService->getClass($this->name); - - foreach ($this->fieldMappings as $field => $mapping) { - $reflField = isset($mapping['declared']) - ? $reflService->getAccessibleProperty($mapping['declared'], $field) - : $reflService->getAccessibleProperty($this->name, $field); - $this->reflFields[$field] = $reflField; - } - - foreach ($this->associationMappings as $field => $mapping) { - $reflField = isset($mapping['declared']) - ? $reflService->getAccessibleProperty($mapping['declared'], $field) - : $reflService->getAccessibleProperty($this->name, $field); - $this->reflFields[$field] = $reflField; - } - } - - public function initializeReflection($reflService) - { - - } - /** * Creates a new instance of the mapped class, without invoking the constructor. * diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php index c204f016c..4590b9ee3 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php @@ -588,5 +588,6 @@ class ClassMetadataFactory implements ClassMetadataFactoryInterface */ protected function initializeReflection(ClassMetadataInfo $class, ReflectionService $reflService) { + $class->initializeReflection($reflService); } } diff --git a/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php index 0042259e1..6d14c2ac7 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/AbstractMappingDriverTest.php @@ -18,6 +18,7 @@ abstract class AbstractMappingDriverTest extends \Doctrine\Tests\OrmTestCase $mappingDriver = $this->_loadDriver(); $class = new ClassMetadata($entityClassName); + $class->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); $mappingDriver->loadMetadataForClass($entityClassName, $class); return $class; diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php index 38cecd5cc..888db0d81 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php @@ -40,6 +40,7 @@ class ClassMetadataBuilderTest extends \Doctrine\Tests\OrmTestCase public function setUp() { $this->cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); + $this->cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); $this->builder = new ClassMetadataBuilder($this->cm); } diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php index 223ef8582..cd1e4f3ff 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataFactoryTest.php @@ -27,6 +27,7 @@ class ClassMetadataFactoryTest extends \Doctrine\Tests\OrmTestCase // Self-made metadata $cm1 = new ClassMetadata('Doctrine\Tests\ORM\Mapping\TestEntity1'); + $cm1->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); $cm1->setPrimaryTable(array('name' => '`group`')); // Add a mapped field $cm1->mapField(array('fieldName' => 'name', 'type' => 'varchar')); @@ -43,9 +44,9 @@ class ClassMetadataFactoryTest extends \Doctrine\Tests\OrmTestCase $cm1->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_AUTO); // SUT - $cmf = new ClassMetadataFactoryTestSubject(); + $cmf = new \Doctrine\ORM\Mapping\ClassMetadataFactory(); $cmf->setEntityManager($entityManager); - $cmf->setMetadataForClass('Doctrine\Tests\ORM\Mapping\TestEntity1', $cm1); + $cmf->setMetadataFor('Doctrine\Tests\ORM\Mapping\TestEntity1', $cm1); // Prechecks $this->assertEquals(array(), $cm1->parentClasses); @@ -53,15 +54,16 @@ class ClassMetadataFactoryTest extends \Doctrine\Tests\OrmTestCase $this->assertTrue($cm1->hasField('name')); $this->assertEquals(2, count($cm1->associationMappings)); $this->assertEquals(ClassMetadata::GENERATOR_TYPE_AUTO, $cm1->generatorType); + $this->assertEquals('group', $cm1->table['name']); // Go - $cm1 = $cmf->getMetadataFor('Doctrine\Tests\ORM\Mapping\TestEntity1'); + $cmMap1 = $cmf->getMetadataFor('Doctrine\Tests\ORM\Mapping\TestEntity1'); - $this->assertEquals('group', $cm1->table['name']); - $this->assertTrue($cm1->table['quoted']); - $this->assertEquals(array(), $cm1->parentClasses); - $this->assertTrue($cm1->hasField('name')); - $this->assertEquals(ClassMetadata::GENERATOR_TYPE_SEQUENCE, $cm1->generatorType); + $this->assertSame($cm1, $cmMap1); + $this->assertEquals('group', $cmMap1->table['name']); + $this->assertTrue($cmMap1->table['quoted']); + $this->assertEquals(array(), $cmMap1->parentClasses); + $this->assertTrue($cmMap1->hasField('name')); } public function testHasGetMetadata_NamespaceSeperatorIsNotNormalized() diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php index 88af7f2ae..f663522a6 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php @@ -13,6 +13,7 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase public function testClassMetadataInstanceSerialization() { $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); // Test initial state $this->assertTrue(count($cm->getReflectionProperties()) == 0); @@ -61,6 +62,7 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase public function testFieldIsNullable() { $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); // Explicit Nullable $cm->mapField(array('fieldName' => 'status', 'nullable' => true, 'type' => 'string', 'length' => 50)); @@ -83,6 +85,7 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase require_once __DIR__."/../../Models/Global/GlobalNamespaceModel.php"; $cm = new ClassMetadata('DoctrineGlobal_Article'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); $cm->mapManyToMany(array( 'fieldName' => 'author', 'targetEntity' => 'DoctrineGlobal_User', @@ -99,6 +102,7 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase public function testMapManyToManyJoinTableDefaults() { $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); $cm->mapManyToMany( array( 'fieldName' => 'groups', @@ -118,6 +122,7 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase public function testSerializeManyToManyJoinTableCascade() { $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); $cm->mapManyToMany( array( 'fieldName' => 'groups', @@ -139,6 +144,7 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase require_once __DIR__."/../../Models/Global/GlobalNamespaceModel.php"; $cm = new ClassMetadata('DoctrineGlobal_User'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); $cm->setDiscriminatorMap(array('descr' => 'DoctrineGlobal_Article', 'foo' => 'DoctrineGlobal_User')); $this->assertEquals("DoctrineGlobal_Article", $cm->discriminatorMap['descr']); @@ -153,6 +159,7 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase require_once __DIR__."/../../Models/Global/GlobalNamespaceModel.php"; $cm = new ClassMetadata('DoctrineGlobal_User'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); $cm->setSubclasses(array('DoctrineGlobal_Article')); $this->assertEquals("DoctrineGlobal_Article", $cm->subClasses[0]); @@ -168,6 +175,7 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase $field['type'] = 'string'; $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); $this->setExpectedException('Doctrine\ORM\Mapping\MappingException'); $cm->setVersionMapping($field); @@ -176,6 +184,7 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase public function testGetSingleIdentifierFieldName_MultipleIdentifierEntity_ThrowsException() { $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); $cm->isIdentifierComposite = true; $this->setExpectedException('Doctrine\ORM\Mapping\MappingException'); @@ -185,6 +194,8 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase public function testDuplicateAssociationMappingException() { $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + $a1 = array('fieldName' => 'foo', 'sourceEntity' => 'stdClass', 'targetEntity' => 'stdClass', 'mappedBy' => 'foo'); $a2 = array('fieldName' => 'foo', 'sourceEntity' => 'stdClass', 'targetEntity' => 'stdClass', 'mappedBy' => 'foo'); @@ -196,6 +207,8 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase public function testDuplicateColumnName_ThrowsMappingException() { $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + $cm->mapField(array('fieldName' => 'name', 'columnName' => 'name')); $this->setExpectedException('Doctrine\ORM\Mapping\MappingException'); @@ -205,6 +218,8 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase public function testDuplicateColumnName_DiscriminatorColumn_ThrowsMappingException() { $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + $cm->mapField(array('fieldName' => 'name', 'columnName' => 'name')); $this->setExpectedException('Doctrine\ORM\Mapping\MappingException'); @@ -214,6 +229,8 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase public function testDuplicateColumnName_DiscriminatorColumn2_ThrowsMappingException() { $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + $cm->setDiscriminatorColumn(array('name' => 'name')); $this->setExpectedException('Doctrine\ORM\Mapping\MappingException'); @@ -223,6 +240,8 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase public function testDuplicateFieldAndAssocationMapping1_ThrowsException() { $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + $cm->mapField(array('fieldName' => 'name', 'columnName' => 'name')); $this->setExpectedException('Doctrine\ORM\Mapping\MappingException'); @@ -232,6 +251,8 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase public function testDuplicateFieldAndAssocationMapping2_ThrowsException() { $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + $cm->mapOneToOne(array('fieldName' => 'name', 'targetEntity' => 'CmsUser')); $this->setExpectedException('Doctrine\ORM\Mapping\MappingException'); @@ -244,6 +265,8 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase public function testGetTemporaryTableNameSchema() { $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + $cm->setTableName('foo.bar'); $this->assertEquals('foo_bar_id_tmp', $cm->getTemporaryIdTableName()); @@ -252,6 +275,7 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase public function testDefaultTableName() { $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); // When table's name is not given $primaryTable = array(); @@ -261,6 +285,7 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase $this->assertEquals('CmsUser', $cm->table['name']); $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); // When joinTable's name is not given $cm->mapManyToMany(array( 'fieldName' => 'user', @@ -274,6 +299,8 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase public function testDefaultJoinColumnName() { $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + // this is really dirty, but it's the simpliest way to test whether // joinColumn's name will be automatically set to user_id $cm->mapOneToOne(array( @@ -283,6 +310,7 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase $this->assertEquals('user_id', $cm->associationMappings['user']['joinColumns'][0]['name']); $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsAddress'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); $cm->mapManyToMany(array( 'fieldName' => 'user', 'targetEntity' => 'CmsUser', @@ -300,6 +328,8 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase public function testSetMultipleIdentifierSetsComposite() { $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + $cm->mapField(array('fieldName' => 'name')); $cm->mapField(array('fieldName' => 'username')); @@ -313,6 +343,7 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase public function testMappingNotFound() { $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); $this->setExpectedException('Doctrine\ORM\Mapping\MappingException', "No mapping found for field 'foo' on class 'Doctrine\Tests\Models\CMS\CmsUser'."); $cm->getFieldMapping('foo'); @@ -324,6 +355,8 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase public function testJoinTableMappingDefaults() { $cm = new ClassMetadata('DoctrineGlobal_Article'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + $cm->mapManyToMany(array('fieldName' => 'author', 'targetEntity' => 'Doctrine\Tests\Models\CMS\CmsUser')); $this->assertEquals('doctrineglobal_article_cmsuser', $cm->associationMappings['author']['joinTable']['name']); @@ -335,6 +368,8 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase public function testMapIdentifierAssociation() { $cm = new ClassMetadata('Doctrine\Tests\Models\DDC117\DDC117ArticleDetails'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + $cm->mapOneToOne(array( 'fieldName' => 'article', 'id' => true, @@ -352,6 +387,7 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase public function testOrphanRemovalIdentifierAssociation() { $cm = new ClassMetadata('Doctrine\Tests\Models\DDC117\DDC117ArticleDetails'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); $this->setExpectedException('Doctrine\ORM\Mapping\MappingException', 'The orphan removal option is not allowed on an association that'); $cm->mapOneToOne(array( @@ -369,6 +405,8 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase public function testInverseIdentifierAssocation() { $cm = new ClassMetadata('Doctrine\Tests\Models\DDC117\DDC117ArticleDetails'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + $this->setExpectedException('Doctrine\ORM\Mapping\MappingException', 'An inverse association is not allowed to be identifier in'); $cm->mapOneToOne(array( @@ -386,6 +424,8 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase public function testIdentifierAssocationManyToMany() { $cm = new ClassMetadata('Doctrine\Tests\Models\DDC117\DDC117ArticleDetails'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + $this->setExpectedException('Doctrine\ORM\Mapping\MappingException', 'Many-to-many or one-to-many associations are not allowed to be identifier in'); $cm->mapManyToMany(array( @@ -404,12 +444,16 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase $this->setExpectedException('Doctrine\ORM\Mapping\MappingException', "The field or association mapping misses the 'fieldName' attribute in entity 'Doctrine\Tests\Models\CMS\CmsUser'."); $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + $cm->mapField(array('fieldName' => '')); } public function testRetrievalOfNamedQueries() { $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + $this->assertEquals(0, count($cm->getNamedQueries())); @@ -424,6 +468,8 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase public function testExistanceOfNamedQuery() { $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + $cm->addNamedQuery(array( 'name' => 'all', @@ -437,6 +483,8 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase public function testRetrieveOfNamedQuery() { $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + $cm->addNamedQuery(array( 'name' => 'userById', @@ -449,6 +497,8 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase public function testNamingCollisionNamedQueryShouldThrowException() { $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + $this->setExpectedException('Doctrine\ORM\Mapping\MappingException'); @@ -470,6 +520,8 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase { $user = new \Doctrine\Tests\Models\CMS\CmsUser(); $cm = new ClassMetadata('DOCTRINE\TESTS\MODELS\CMS\CMSUSER'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + $this->assertEquals('Doctrine\Tests\Models\CMS\CmsUser', $cm->name); } @@ -479,6 +531,8 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase public function testLifecycleCallbackNotFound() { $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + $this->setExpectedException("Doctrine\ORM\Mapping\MappingException", "Entity 'Doctrine\Tests\Models\CMS\CmsUser' has no method 'notfound' to be registered as lifecycle callback."); $cm->addLifecycleCallback('notfound', 'postLoad'); @@ -490,6 +544,8 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase public function testTargetEntityNotFound() { $cm = new ClassMetadata('Doctrine\Tests\Models\CMS\CmsUser'); + $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); + $this->setExpectedException("Doctrine\ORM\Mapping\MappingException", "The target-entity Doctrine\Tests\Models\CMS\UnknownClass cannot be found in 'Doctrine\Tests\Models\CMS\CmsUser#address'."); $cm->mapManyToOne(array('fieldName' => 'address', 'targetEntity' => 'UnknownClass')); diff --git a/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php index e04543db0..6a852bc69 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php @@ -21,6 +21,7 @@ class XmlMappingDriverTest extends AbstractMappingDriverTest $mappingDriver = $this->_loadDriver(); $class = new ClassMetadata($className); + $class->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); $mappingDriver->loadMetadataForClass($className, $class); $expectedMap = array( @@ -92,4 +93,4 @@ class CTI class CTIFoo extends CTI {} class CTIBar extends CTI {} -class CTIBaz extends CTI {} \ No newline at end of file +class CTIBaz extends CTI {} diff --git a/tests/Doctrine/Tests/ORM/Proxy/ProxyClassGeneratorTest.php b/tests/Doctrine/Tests/ORM/Proxy/ProxyClassGeneratorTest.php index 39bdcfe5a..a45ca2c1f 100644 --- a/tests/Doctrine/Tests/ORM/Proxy/ProxyClassGeneratorTest.php +++ b/tests/Doctrine/Tests/ORM/Proxy/ProxyClassGeneratorTest.php @@ -127,6 +127,7 @@ class ProxyClassGeneratorTest extends \Doctrine\Tests\OrmTestCase $className = "\DoctrineOrmTestEntity"; $proxyName = "DoctrineOrmTestEntityProxy"; $classMetadata = new \Doctrine\ORM\Mapping\ClassMetadata($className); + $classMetadata->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); $classMetadata->mapField(array('fieldName' => 'id', 'type' => 'integer')); $classMetadata->setIdentifier(array('id')); @@ -143,6 +144,7 @@ class ProxyClassGeneratorTest extends \Doctrine\Tests\OrmTestCase $className = "\Doctrine\Tests\ORM\Proxy\SleepClass"; $proxyName = "DoctrineTestsORMProxySleepClassProxy"; $classMetadata = new \Doctrine\ORM\Mapping\ClassMetadata($className); + $classMetadata->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService); $classMetadata->mapField(array('fieldName' => 'id', 'type' => 'integer')); $classMetadata->setIdentifier(array('id'));