From 7d921a8220cd5ba835a40c08bbc36ac63f8fd6f2 Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Sat, 29 Oct 2011 00:22:45 +0200 Subject: [PATCH] DDC-1452 - Attach working testcase --- .../ORM/Functional/Ticket/DDC1452Test.php | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1452Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1452Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1452Test.php new file mode 100644 index 000000000..33241fad2 --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1452Test.php @@ -0,0 +1,77 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1452EntityA'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC1452EntityB'), + )); + } catch (\Exception $ignored) { + } + } + + public function testIssue() + { + $a = new DDC1452EntityA(); + $a->title = "foo"; + + $b = new DDC1452EntityB(); + $b->entityAFrom = $a; + $b->entityATo = $a; + + $this->_em->persist($a); + $this->_em->persist($b); + $this->_em->flush(); + $this->_em->clear(); + + $dql = "SELECT a, b, ba FROM " . __NAMESPACE__ . "\DDC1452EntityA AS a LEFT JOIN a.entitiesB AS b LEFT JOIN b.entityATo AS ba"; + $results = $this->_em->createQuery($dql)->getResult(); + + $this->assertSame($results[0], $results[0]->entitiesB[0]->entityAFrom); + $this->assertSame($results[0], $results[0]->entitiesB[0]->entityATo); + } +} + +/** + * @Entity + */ +class DDC1452EntityA +{ + /** @Id @Column(type="integer") @GeneratedValue */ + public $id; + /** @Column */ + public $title; + /** @ManyToMany(targetEntity="DDC1452EntityB", mappedBy="entityAFrom") */ + public $entitiesB; +} + +/** + * @Entity + */ +class DDC1452EntityB +{ + /** @Id @Column(type="integer") @GeneratedValue */ + public $id; + + /** + * @ManyToOne(targetEntity="DDC1452EntityA", inversedBy="entitiesB") + */ + public $entityAFrom; + /** + * @ManyToOne(targetEntity="DDC1452EntityA") + */ + public $entityATo; +} \ No newline at end of file