Rajout de doctrine/orm
[zf2.biz/galerie.git] / vendor / doctrine / orm / tests / Doctrine / Tests / ORM / Functional / Ticket / DDC1548Test.php
1 <?php
2
3 namespace Doctrine\Tests\ORM\Functional\Ticket;
4
5 /**
6  * @group DDC-1548
7  */
8 class DDC1548Test extends \Doctrine\Tests\OrmFunctionalTestCase
9 {
10     public function setUp()
11     {
12         parent::setUp();
13         $this->_schemaTool->createSchema(array(
14             $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1548E1'),
15             $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1548E2'),
16             $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1548Rel'),
17         ));
18     }
19
20     public function testIssue()
21     {
22         $rel = new DDC1548Rel();
23         $this->_em->persist($rel);
24         $this->_em->flush();
25
26         $e1 = new DDC1548E1();
27         $e1->rel = $rel;
28         $this->_em->persist($e1);
29         $this->_em->flush();
30         $this->_em->clear();
31
32         $obt = $this->_em->find(__NAMESPACE__ . '\DDC1548Rel', $rel->id);
33
34         $this->assertNull($obt->e2);
35     }
36 }
37
38 /**
39  * @Entity
40  */
41 class DDC1548E1
42 {
43     /**
44      * @Id
45      * @OneToOne(targetEntity="DDC1548Rel", inversedBy="e1")
46      */
47     public $rel;
48 }
49
50 /**
51  * @Entity
52  */
53 class DDC1548E2
54 {
55     /**
56      * @Id
57      * @OneToOne(targetEntity="DDC1548Rel", inversedBy="e2")
58      */
59     public $rel;
60 }
61
62 /**
63  * @Entity
64  */
65 class DDC1548Rel
66 {
67     /**
68      * @Id @GeneratedValue
69      * @Column(type="integer")
70      */
71     public $id;
72
73     /**
74      * @OneToOne(targetEntity="DDC1548E1", mappedBy="rel")
75      */
76     public $e1;
77     /**
78      * @OneToOne(targetEntity="DDC1548E2", mappedBy="rel")
79      */
80     public $e2;
81 }