From b7c28924b16a18e3b8cd33a69fd0d55f4bda602b Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Thu, 15 Jan 2015 03:48:53 +0100 Subject: [PATCH] #1130 DDC-3300 - fixed inheritance maps where inheritance members were missing --- .../JoinedRootClass.php | 2 +- .../SingleRootClass.php | 2 +- .../ORM/Functional/Ticket/DDC1113Test.php | 2 +- .../ORM/Functional/Ticket/DDC1454Test.php | 2 +- .../ORM/Functional/Ticket/DDC1509Test.php | 2 +- .../ORM/Functional/Ticket/DDC1787Test.php | 2 +- .../ORM/Functional/Ticket/DDC2012Test.php | 3 +- .../ORM/Functional/Ticket/DDC2346Test.php | 2 +- .../ORM/Functional/Ticket/DDC3300Test.php | 38 ++++++++++++------- 9 files changed, 34 insertions(+), 21 deletions(-) diff --git a/tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedRootClass.php b/tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedRootClass.php index f145ba259..3055b32e1 100644 --- a/tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedRootClass.php +++ b/tests/Doctrine/Tests/Models/CompositeKeyInheritance/JoinedRootClass.php @@ -5,7 +5,7 @@ namespace Doctrine\Tests\Models\CompositeKeyInheritance; * @Entity * @InheritanceType("JOINED") * @DiscriminatorColumn(name="discr", type="string") - * @DiscriminatorMap({"child" = "JoinedChildClass",}) + * @DiscriminatorMap({"child" = "JoinedChildClass", "root" = "JoinedRootClass"}) */ class JoinedRootClass { diff --git a/tests/Doctrine/Tests/Models/CompositeKeyInheritance/SingleRootClass.php b/tests/Doctrine/Tests/Models/CompositeKeyInheritance/SingleRootClass.php index 1bbd09702..19b4b4b01 100644 --- a/tests/Doctrine/Tests/Models/CompositeKeyInheritance/SingleRootClass.php +++ b/tests/Doctrine/Tests/Models/CompositeKeyInheritance/SingleRootClass.php @@ -5,7 +5,7 @@ namespace Doctrine\Tests\Models\CompositeKeyInheritance; * @Entity * @InheritanceType("SINGLE_TABLE") * @DiscriminatorColumn(name="discr", type="string") - * @DiscriminatorMap({"child" = "SingleChildClass",}) + * @DiscriminatorMap({"child" = "SingleChildClass", "root" = "SingleRootClass"}) */ class SingleRootClass { diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1113Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1113Test.php index 5bb007fd0..335c89dce 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1113Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1113Test.php @@ -50,7 +50,7 @@ class DDC1113Test extends \Doctrine\Tests\OrmFunctionalTestCase /** * @Entity * @InheritanceType("SINGLE_TABLE") - * @DiscriminatorMap({"car" = "DDC1113Car", "bus" = "DDC1113Bus"}) + * @DiscriminatorMap({"vehicle" = "DDC1113Vehicle", "car" = "DDC1113Car", "bus" = "DDC1113Bus"}) */ class DDC1113Vehicle { diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1454Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1454Test.php index 162072965..f6b26253a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1454Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1454Test.php @@ -43,7 +43,7 @@ class DDC1454Picture extends DDC1454File * @Entity * @InheritanceType("JOINED") * @DiscriminatorColumn(name="discr", type="string") - * @DiscriminatorMap({"picture" = "DDC1454Picture"}) + * @DiscriminatorMap({"file" = "DDC1454File", "picture" = "DDC1454Picture"}) */ class DDC1454File { diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1509Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1509Test.php index 6ba0cd42f..2b7e9b377 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1509Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1509Test.php @@ -115,7 +115,7 @@ class DDC1509Picture * @Entity * @InheritanceType("SINGLE_TABLE") * @DiscriminatorColumn(name="discr", type="string") - * @DiscriminatorMap({"file" = "DDC1509File"}) + * @DiscriminatorMap({"abstractFile" = "DDC1509AbstractFile", "file" = "DDC1509File"}) */ class DDC1509AbstractFile { diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1787Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1787Test.php index 39fe48367..862d9196a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1787Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1787Test.php @@ -33,7 +33,7 @@ class DDC1787Test extends \Doctrine\Tests\OrmFunctionalTestCase * @Entity * @InheritanceType("JOINED") * @DiscriminatorColumn(name="discr", type="string") - * @DiscriminatorMap({"bar" = "DDC1787Bar"}) + * @DiscriminatorMap({"bar" = "DDC1787Bar", "foo" = "DDC1787Foo"}) */ class DDC1787Foo { diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2012Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2012Test.php index 549cf23cb..92510cb02 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2012Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2012Test.php @@ -71,7 +71,8 @@ class DDC2012Test extends \Doctrine\Tests\OrmFunctionalTestCase * @InheritanceType("JOINED") * @DiscriminatorColumn(name="type_id", type="smallint") * @DiscriminatorMap({ - * 1 = "DDC2012ItemPerson" + * 1 = "DDC2012ItemPerson", + * 2 = "DDC2012Item" * }) */ class DDC2012Item diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2346Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2346Test.php index 8bc803f29..8832b0f50 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2346Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2346Test.php @@ -88,7 +88,7 @@ class DDC2346Foo * @Entity * @InheritanceType("JOINED") * @DiscriminatorColumn(name="discr", type="string") - * @DiscriminatorMap({"baz" = "DDC2346Baz"}) + * @DiscriminatorMap({"bar" = "DDC2346Bar", "baz" = "DDC2346Baz"}) */ class DDC2346Bar { diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3300Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3300Test.php index 422b3d78f..8ac6dde7a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3300Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3300Test.php @@ -4,6 +4,7 @@ namespace Doctrine\Tests\ORM\Functional\Ticket; use Doctrine\ORM\Events; use Doctrine\ORM\Tools\ResolveDiscriminatorMapListener; +use Doctrine\ORM\Tools\ResolveTargetEntityListener; /** * @group DDC-3300 @@ -12,21 +13,28 @@ class DDC3300Test extends \Doctrine\Tests\OrmFunctionalTestCase { public function testIssue() { - $this - ->_em - ->getEventManager() - ->addEventListener( - Events::loadClassMetadata, - new ResolveDiscriminatorMapListener(array( - 'Doctrine\Tests\ORM\Functional\Ticket\DDC3300BossInterface' => 'Doctrine\Tests\ORM\Functional\Ticket\DDC3300Boss', - 'Doctrine\Tests\ORM\Functional\Ticket\DDC3300EmployeeInterface' => 'Doctrine\Tests\ORM\Functional\Ticket\DDC3300Employee', - )) - ); + $resolveTargetEntity = new ResolveTargetEntityListener(); + + $resolveTargetEntity->addResolveTargetEntity( + DDC3300BossInterface::INTERFACENAME, + DDC3300Boss::CLASSNAME, + array() + ); + + $resolveTargetEntity->addResolveTargetEntity( + DDC3300EmployeeInterface::INTERFACENAME, + DDC3300Employee::CLASSNAME, + array() + ); + + $this->_em->getEventManager()->addEventSubscriber($resolveTargetEntity); $this->_schemaTool->createSchema(array( - $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC3300Person'), + $this->_em->getClassMetadata(DDC3300Person::CLASSNAME), )); + //die(var_dump($this->_em->getClassMetadata(DDC3300Person::CLASSNAME)->discriminatorMap)); + $boss = new DDC3300Boss(); $this->_em->persist($boss); @@ -48,6 +56,8 @@ class DDC3300Test extends \Doctrine\Tests\OrmFunctionalTestCase */ abstract class DDC3300Person { + const CLASSNAME = __CLASS__; + /** * @Id * @Column(type="integer") @@ -58,7 +68,7 @@ abstract class DDC3300Person interface DDC3300BossInterface { - + const INTERFACENAME = __CLASS__; } /** @@ -66,11 +76,12 @@ interface DDC3300BossInterface */ class DDC3300Boss extends DDC3300Person implements DDC3300BossInterface { + const CLASSNAME = __CLASS__; } interface DDC3300EmployeeInterface { - + const INTERFACENAME = __CLASS__; } /** @@ -78,5 +89,6 @@ interface DDC3300EmployeeInterface */ class DDC3300Employee extends DDC3300Person implements DDC3300EmployeeInterface { + const CLASSNAME = __CLASS__; } \ No newline at end of file