Rajout de doctrine/orm
[zf2.biz/galerie.git] / vendor / doctrine / orm / tests / Doctrine / Tests / ORM / Functional / Ticket / DDC309Test.php
1 <?php
2 namespace Doctrine\Tests\ORM\Functional\Ticket;
3
4 require_once __DIR__ . '/../../../TestInit.php';
5
6 class DDC309Test extends \Doctrine\Tests\OrmFunctionalTestCase
7 {
8     protected function setUp()
9     {
10         parent::setUp();
11         $this->_schemaTool->createSchema(array(
12             $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC309Country'),
13             $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC309User'),
14         ));
15     }
16
17     public function testTwoIterateHydrations()
18     {
19         $c1 = new DDC309Country();
20         $c2 = new DDC309Country();
21         $u1 = new DDC309User();
22         $u2 = new DDC309User();
23
24         $this->_em->persist($c1);
25         $this->_em->persist($c2);
26         $this->_em->persist($u1);
27         $this->_em->persist($u2);
28         $this->_em->flush();
29         $this->_em->clear();
30
31         $q = $this->_em->createQuery('SELECT c FROM Doctrine\Tests\ORM\Functional\Ticket\DDC309Country c')->iterate();
32         $c = $q->next();
33
34         $this->assertEquals(1, $c[0]->id);
35
36         $r = $this->_em->createQuery('SELECT u FROM Doctrine\Tests\ORM\Functional\Ticket\DDC309User u')->iterate();
37         $u = $r->next(); // This line breaks
38
39         $this->assertEquals(1, $u[0]->id);
40
41         $c = $q->next();
42         $u = $r->next();
43
44         $this->assertEquals(2, $c[0]->id);
45         $this->assertEquals(2, $u[0]->id);
46     }
47 }
48
49 /**
50  * @Entity
51  */
52 class DDC309Country
53 {
54     /**
55      * @Id
56      * @Column(name="id", type="integer")
57      * @GeneratedValue
58      */
59     public $id;
60 }
61
62 /**
63  * @Entity
64  */
65 class DDC309User
66 {
67     /**
68      * @Id
69      * @Column(name="id", type="integer")
70      * @GeneratedValue
71      */
72     public $id;
73 }