From aac523d15578b05084c13ec7f9dde9d8fe35186e Mon Sep 17 00:00:00 2001 From: Full Date: Sat, 4 Mar 2017 15:09:29 +0100 Subject: [PATCH] tests with custom inheritance tree --- .../Tests/Models/DDC6303/DDC6303Contract.php | 24 ++++++++ .../Tests/Models/DDC6303/DDC6303ContractA.php | 17 ++++++ .../Tests/Models/DDC6303/DDC6303ContractB.php | 17 ++++++ .../ORM/Functional/Ticket/DDC6303Test.php | 56 +++++++++++++++++++ .../Doctrine/Tests/OrmFunctionalTestCase.php | 6 ++ 5 files changed, 120 insertions(+) create mode 100644 tests/Doctrine/Tests/Models/DDC6303/DDC6303Contract.php create mode 100644 tests/Doctrine/Tests/Models/DDC6303/DDC6303ContractA.php create mode 100644 tests/Doctrine/Tests/Models/DDC6303/DDC6303ContractB.php create mode 100644 tests/Doctrine/Tests/ORM/Functional/Ticket/DDC6303Test.php diff --git a/tests/Doctrine/Tests/Models/DDC6303/DDC6303Contract.php b/tests/Doctrine/Tests/Models/DDC6303/DDC6303Contract.php new file mode 100644 index 000000000..ccb2dee34 --- /dev/null +++ b/tests/Doctrine/Tests/Models/DDC6303/DDC6303Contract.php @@ -0,0 +1,24 @@ +useModelSet('ddc6303'); + parent::setUp(); + } + + public function testMixedTypeHydratedCorrectlyInJoinedInheritance() + { + $contractA = new DDC6303ContractA(); + $contractAData = 'authorized'; + $contractA->originalData = $contractAData; + + $contractB = new DDC6303ContractB(); + $contractBData = ['accepted', 'authorized']; + $contractB->originalData = $contractBData; + + $this->_em->persist($contractA); + $this->_em->persist($contractB); + + $this->_em->flush(); + + // clear entity manager so that $repository->find actually fetches them and uses the hydrator + // instead of just returning the existing managed entities + $this->_em->clear(); + + $repository = $this->_em->getRepository(DDC6303Contract::class); + + $contracts = $repository->createQueryBuilder('p') + ->getQuery()->getResult(); + + foreach( $contracts as $contract ){ + switch( $contract->id ){ + case $contractA->id: + static::assertEquals($contract->originalData, $contractAData); + break; + + case $contractB->id: + static::assertEquals($contract->originalData, $contractBData); + break; + } + } + } +} diff --git a/tests/Doctrine/Tests/OrmFunctionalTestCase.php b/tests/Doctrine/Tests/OrmFunctionalTestCase.php index e9299b1c6..5618fa120 100644 --- a/tests/Doctrine/Tests/OrmFunctionalTestCase.php +++ b/tests/Doctrine/Tests/OrmFunctionalTestCase.php @@ -312,6 +312,12 @@ abstract class OrmFunctionalTestCase extends OrmTestCase Models\Issue5989\Issue5989Employee::class, Models\Issue5989\Issue5989Manager::class, ], + 'ddc6303' => [ + Models\DDC6303\DDC6303Contract::class, + Models\DDC6303\DDC6303ContractA::class, + Models\DDC6303\DDC6303ContractB::class, + ] + ]; /**