From faf92883b6341321d74ac750ea815448b2d5b2e5 Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Sat, 21 Jan 2012 13:58:25 +0100 Subject: [PATCH] [DDC-1610] Add test and fix wakeup reflection in combination with event listener --- lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php | 2 +- .../Tests/ORM/Mapping/ClassMetadataLoadEventTest.php | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php index 9e0f2b38d..815808014 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php @@ -291,7 +291,6 @@ class ClassMetadataFactory implements ClassMetadataFactoryInterface // Invoke driver try { $this->driver->loadMetadataForClass($className, $class); - $this->wakeupReflection($class, $this->getReflectionService()); } catch (ReflectionException $e) { throw MappingException::reflectionFailure($className, $e); } @@ -333,6 +332,7 @@ class ClassMetadataFactory implements ClassMetadataFactoryInterface $eventArgs = new \Doctrine\ORM\Event\LoadClassMetadataEventArgs($class, $this->em); $this->evm->dispatchEvent(Events::loadClassMetadata, $eventArgs); } + $this->wakeupReflection($class, $this->getReflectionService()); $this->validateRuntimeMetadata($class, $parent); diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataLoadEventTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataLoadEventTest.php index 5ef67c3eb..70aae70d4 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataLoadEventTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataLoadEventTest.php @@ -9,6 +9,9 @@ require_once __DIR__ . '/../../TestInit.php'; class ClassMetadataLoadEventTest extends \Doctrine\Tests\OrmTestCase { + /** + * @group DDC-1610 + */ public function testEvent() { $em = $this->_getTestEntityManager(); @@ -17,6 +20,8 @@ class ClassMetadataLoadEventTest extends \Doctrine\Tests\OrmTestCase $evm->addEventListener(Events::loadClassMetadata, $this); $classMetadata = $metadataFactory->getMetadataFor('Doctrine\Tests\ORM\Mapping\LoadEventTestEntity'); $this->assertTrue($classMetadata->hasField('about')); + $this->assertArrayHasKey('about', $classMetadata->reflFields); + $this->assertInstanceOf('ReflectionProperty', $classMetadata->reflFields['about']); } public function loadClassMetadata(\Doctrine\ORM\Event\LoadClassMetadataEventArgs $eventArgs) @@ -48,4 +53,4 @@ class LoadEventTestEntity private $name; private $about; -} \ No newline at end of file +}