diff --git a/tests/Doctrine/Tests/Models/Issue5989/Issue5989Employee.php b/tests/Doctrine/Tests/Models/Issue5989/Issue5989Employee.php new file mode 100644 index 000000000..e3eaac7d8 --- /dev/null +++ b/tests/Doctrine/Tests/Models/Issue5989/Issue5989Employee.php @@ -0,0 +1,27 @@ +tags; + } + + public function setTags(array $tags) + { + $this->tags = $tags; + } +} diff --git a/tests/Doctrine/Tests/Models/Issue5989/Issue5989Manager.php b/tests/Doctrine/Tests/Models/Issue5989/Issue5989Manager.php new file mode 100644 index 000000000..32c053984 --- /dev/null +++ b/tests/Doctrine/Tests/Models/Issue5989/Issue5989Manager.php @@ -0,0 +1,27 @@ +tags; + } + + public function setTags(array $tags) + { + $this->tags = $tags; + } +} diff --git a/tests/Doctrine/Tests/Models/Issue5989/Issue5989Person.php b/tests/Doctrine/Tests/Models/Issue5989/Issue5989Person.php new file mode 100644 index 000000000..c9e00c4c1 --- /dev/null +++ b/tests/Doctrine/Tests/Models/Issue5989/Issue5989Person.php @@ -0,0 +1,29 @@ +id; + } +} diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/Issue5989Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/Issue5989Test.php new file mode 100644 index 000000000..29a5a3fa2 --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/Issue5989Test.php @@ -0,0 +1,51 @@ +useModelSet('issue5989'); + parent::setUp(); + } + + public function testSimpleArrayTypeHydratedCorrectlyInJoinedInheritance() + { + $manager = new Issue5989Manager(); + + $managerTags = array('tag1', 'tag2'); + $manager->setTags($managerTags); + $this->_em->persist($manager); + + $employee = new Issue5989Employee(); + + $employeeTags = array('tag2', 'tag3'); + $employee->setTags($employeeTags); + $this->_em->persist($employee); + + $this->_em->flush(); + + $managerId = $manager->getId(); + $employeeId = $employee->getId(); + + // 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(Issue5989Person::class); + + $manager = $repository->find($managerId); + $employee = $repository->find($employeeId); + + static::assertEquals($managerTags, $manager->getTags()); + static::assertEquals($employeeTags, $employee->getTags()); + } +} diff --git a/tests/Doctrine/Tests/OrmFunctionalTestCase.php b/tests/Doctrine/Tests/OrmFunctionalTestCase.php index b36a83487..611f357e8 100644 --- a/tests/Doctrine/Tests/OrmFunctionalTestCase.php +++ b/tests/Doctrine/Tests/OrmFunctionalTestCase.php @@ -284,6 +284,11 @@ abstract class OrmFunctionalTestCase extends OrmTestCase 'Doctrine\Tests\Models\VersionedManyToOne\Category', 'Doctrine\Tests\Models\VersionedManyToOne\Article', ), + 'issue5989' => array( + 'Doctrine\Tests\Models\Issue5989\Issue5989Person', + 'Doctrine\Tests\Models\Issue5989\Issue5989Employee', + 'Doctrine\Tests\Models\Issue5989\Issue5989Manager', + ), ); /** @@ -544,6 +549,12 @@ abstract class OrmFunctionalTestCase extends OrmTestCase $conn->executeUpdate('DELETE FROM versioned_many_to_one_category'); } + if (isset($this->_usedModelSets['issue5989'])) { + $conn->executeUpdate('DELETE FROM issue5989_persons'); + $conn->executeUpdate('DELETE FROM issue5989_employees'); + $conn->executeUpdate('DELETE FROM issue5989_managers'); + } + $this->_em->clear(); }