X-Git-Url: http://git.inspyration.org/?a=blobdiff_plain;f=vendor%2Fdoctrine%2Form%2Ftests%2FDoctrine%2FTests%2FORM%2FFunctional%2FTicket%2FDDC531Test.php;fp=vendor%2Fdoctrine%2Form%2Ftests%2FDoctrine%2FTests%2FORM%2FFunctional%2FTicket%2FDDC531Test.php;h=5e22c2cbe6dd317a3a04747733152c5b2109db34;hb=8b04b2d11798dee4f3e1358e4f43e97a6df851f6;hp=0000000000000000000000000000000000000000;hpb=73568cf05a785a45f94ca3f2351d9e07bf917958;p=zf2.biz%2Fgalerie.git diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC531Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC531Test.php new file mode 100644 index 0000000..5e22c2c --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC531Test.php @@ -0,0 +1,88 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC531Item'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC531SubItem'), + )); + } + + public function testIssue() + { + $item1 = new DDC531Item; + $item2 = new DDC531Item; + $item2->parent = $item1; + $item1->getChildren()->add($item2); + $this->_em->persist($item1); + $this->_em->persist($item2); + $this->_em->flush(); + $this->_em->clear(); + + $item3 = $this->_em->find(__NAMESPACE__ . '\DDC531Item', $item2->id); // Load child item first (id 2) + // parent will already be loaded, cannot be lazy because it has mapped subclasses and we would not + // know which proxy type to put in. + $this->assertInstanceOf(__NAMESPACE__ . '\DDC531Item', $item3->parent); + $this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $item3->parent); + $item4 = $this->_em->find(__NAMESPACE__ . '\DDC531Item', $item1->id); // Load parent item (id 1) + $this->assertNull($item4->parent); + $this->assertNotNull($item4->getChildren()); + $this->assertTrue($item4->getChildren()->contains($item3)); // lazy-loads children + } +} + +/** + * @Entity + * @InheritanceType("SINGLE_TABLE") + * @DiscriminatorColumn(name="type", type="integer") + * @DiscriminatorMap({"0" = "DDC531Item", "1" = "DDC531SubItem"}) + */ +class DDC531Item +{ + /** + * @Id + * @Column(type="integer") + * @GeneratedValue(strategy="AUTO") + */ + public $id; + + /** + * @OneToMany(targetEntity="DDC531Item", mappedBy="parent") + */ + protected $children; + + /** + * @ManyToOne(targetEntity="DDC531Item", inversedBy="children") + * @JoinColumn(name="parentId", referencedColumnName="id") + */ + public $parent; + + public function __construct() + { + $this->children = new \Doctrine\Common\Collections\ArrayCollection; + } + + public function getParent() + { + return $this->parent; + } + + public function getChildren() + { + return $this->children; + } +} + +/** + * @Entity + */ +class DDC531SubItem extends DDC531Item +{ +} \ No newline at end of file