From f14063def574614deebd2bca0b586c1832b29cbd Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Tue, 13 Jan 2015 20:38:01 +0100 Subject: [PATCH] #385 #1181 DDC-3385 - splitting test case to verify interface-first fetching of metadata (via fallback logic) --- .../Tools/ResolveTargetEntityListenerTest.php | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/tests/Doctrine/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php b/tests/Doctrine/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php index cbc6d40a7..fdee6e8c2 100644 --- a/tests/Doctrine/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/ResolveTargetEntityListenerTest.php @@ -51,10 +51,9 @@ class ResolveTargetEntityListenerTest extends \Doctrine\Tests\OrmTestCase ); $evm->addEventSubscriber($this->listener); - $this->assertNotNull($this->factory->getMetadataFor('Doctrine\Tests\ORM\Tools\ResolveTargetInterface')); - - $cm = $this->factory->getMetadataFor('Doctrine\Tests\ORM\Tools\ResolveTargetEntity'); + $cm = $this->factory->getMetadataFor('Doctrine\Tests\ORM\Tools\ResolveTargetEntity'); $meta = $cm->associationMappings; + $this->assertSame('Doctrine\Tests\ORM\Tools\TargetEntity', $meta['manyToMany']['targetEntity']); $this->assertSame('Doctrine\Tests\ORM\Tools\ResolveTargetEntity', $meta['manyToOne']['targetEntity']); $this->assertSame('Doctrine\Tests\ORM\Tools\ResolveTargetEntity', $meta['oneToMany']['targetEntity']); @@ -63,6 +62,26 @@ class ResolveTargetEntityListenerTest extends \Doctrine\Tests\OrmTestCase $this->assertSame($cm, $this->factory->getMetadataFor('Doctrine\Tests\ORM\Tools\ResolveTargetInterface')); } + /** + * @group DDC-3385 + * @group 1181 + * @group 385 + */ + public function testResolveTargetEntityListenerCanRetrieveTargetEntityByInterfaceName() + { + $this->listener->addResolveTargetEntity( + 'Doctrine\Tests\ORM\Tools\ResolveTargetInterface', + 'Doctrine\Tests\ORM\Tools\ResolveTargetEntity', + array() + ); + + $this->em->getEventManager()->addEventSubscriber($this->listener); + + $cm = $this->factory->getMetadataFor('Doctrine\Tests\ORM\Tools\ResolveTargetInterface'); + + $this->assertSame($this->factory->getMetadataFor('Doctrine\Tests\ORM\Tools\ResolveTargetEntity'), $cm); + } + /** * @group DDC-2109 */