2 namespace Doctrine\Tests\ORM\Functional\Ticket;
4 use Doctrine\ORM\Query;
6 require_once __DIR__ . '/../../../TestInit.php';
11 class DDC371Test extends \Doctrine\Tests\OrmFunctionalTestCase
13 protected function setUp()
16 //$this->_em->getConnection()->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger);
17 $this->_schemaTool->createSchema(array(
18 $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC371Parent'),
19 $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC371Child')
23 public function testIssue()
25 $parent = new DDC371Parent;
26 $parent->data = 'parent';
27 $parent->children = new \Doctrine\Common\Collections\ArrayCollection;
29 $child = new DDC371Child;
30 $child->data = 'child';
32 $child->parent = $parent;
33 $parent->children->add($child);
35 $this->_em->persist($parent);
36 $this->_em->persist($child);
41 $children = $this->_em->createQuery('select c,p from '.__NAMESPACE__.'\DDC371Child c '
42 . 'left join c.parent p where c.id = 1 and p.id = 1')
43 ->setHint(Query::HINT_REFRESH, true)
46 $this->assertEquals(1, count($children));
47 $this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $children[0]->parent);
48 $this->assertFalse($children[0]->parent->children->isInitialized());
49 $this->assertEquals(0, $children[0]->parent->children->unwrap()->count());
55 /** @Id @Column(type="integer") @GeneratedValue */
57 /** @Column(type="string") */
59 /** @ManyToOne(targetEntity="DDC371Parent", inversedBy="children") @JoinColumn(name="parentId") */
65 /** @Id @Column(type="integer") @GeneratedValue */
67 /** @Column(type="string") */
69 /** @OneToMany(targetEntity="DDC371Child", mappedBy="parent") */