X-Git-Url: http://git.inspyration.org/?a=blobdiff_plain;f=vendor%2Fdoctrine%2Form%2Ftests%2FDoctrine%2FTests%2FORM%2FFunctional%2FTicket%2FDDC371Test.php;fp=vendor%2Fdoctrine%2Form%2Ftests%2FDoctrine%2FTests%2FORM%2FFunctional%2FTicket%2FDDC371Test.php;h=2a99519cb75a65f41c7f2f531a24cc426fdc3bb5;hb=8b04b2d11798dee4f3e1358e4f43e97a6df851f6;hp=0000000000000000000000000000000000000000;hpb=73568cf05a785a45f94ca3f2351d9e07bf917958;p=zf2.biz%2Fapplication_blanche.git diff --git a/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC371Test.php b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC371Test.php new file mode 100644 index 0000000..2a99519 --- /dev/null +++ b/vendor/doctrine/orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC371Test.php @@ -0,0 +1,72 @@ +_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger); + $this->_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC371Parent'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC371Child') + )); + } + + public function testIssue() + { + $parent = new DDC371Parent; + $parent->data = 'parent'; + $parent->children = new \Doctrine\Common\Collections\ArrayCollection; + + $child = new DDC371Child; + $child->data = 'child'; + + $child->parent = $parent; + $parent->children->add($child); + + $this->_em->persist($parent); + $this->_em->persist($child); + + $this->_em->flush(); + $this->_em->clear(); + + $children = $this->_em->createQuery('select c,p from '.__NAMESPACE__.'\DDC371Child c ' + . 'left join c.parent p where c.id = 1 and p.id = 1') + ->setHint(Query::HINT_REFRESH, true) + ->getResult(); + + $this->assertEquals(1, count($children)); + $this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $children[0]->parent); + $this->assertFalse($children[0]->parent->children->isInitialized()); + $this->assertEquals(0, $children[0]->parent->children->unwrap()->count()); + } +} + +/** @Entity */ +class DDC371Child { + /** @Id @Column(type="integer") @GeneratedValue */ + private $id; + /** @Column(type="string") */ + public $data; + /** @ManyToOne(targetEntity="DDC371Parent", inversedBy="children") @JoinColumn(name="parentId") */ + public $parent; +} + +/** @Entity */ +class DDC371Parent { + /** @Id @Column(type="integer") @GeneratedValue */ + private $id; + /** @Column(type="string") */ + public $data; + /** @OneToMany(targetEntity="DDC371Child", mappedBy="parent") */ + public $children; +} +