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