Rajout de doctrine/orm
[zf2.biz/galerie.git] / vendor / doctrine / orm / tests / Doctrine / Tests / ORM / Functional / Ticket / DDC1250Test.php
1 <?php
2
3 namespace Doctrine\Tests\ORM\Functional\Ticket;
4
5 use Doctrine\Common\Collections\ArrayCollection;
6 use Doctrine\Tests\Models\CMS\CmsEmployee;
7
8 require_once __DIR__ . '/../../../TestInit.php';
9
10 /**
11  * @group DDC-1250
12  */
13 class DDC1250Test extends \Doctrine\Tests\OrmFunctionalTestCase
14 {
15     public function setUp()
16     {
17         parent::setUp();
18         try {
19             $this->_schemaTool->createSchema(array(
20                 $this->_em->getClassMetadata(__NAMESPACE__ . '\\DDC1250ClientHistory'),
21             ));
22         } catch(\PDOException $e) {
23
24         }
25     }
26
27     public function testIssue()
28     {
29         $c1 = new DDC1250ClientHistory;
30         $c2 = new DDC1250ClientHistory;
31         $c1->declinedClientsHistory = $c2;
32         $c1->declinedBy = $c2;
33         $c2->declinedBy = $c1;
34         $c2->declinedClientsHistory= $c1;
35
36         $this->_em->persist($c1);
37         $this->_em->persist($c2);
38         $this->_em->flush();
39         $this->_em->clear();
40
41         $history = $this->_em->createQuery('SELECT h FROM ' . __NAMESPACE__ . '\\DDC1250ClientHistory h WHERE h.id = ?1')
42                   ->setParameter(1, $c2->id)->getSingleResult();
43
44         $this->assertInstanceOf(__NAMESPACE__ . '\\DDC1250ClientHistory', $history);
45     }
46 }
47
48 /**
49  * @Entity
50  */
51 class DDC1250ClientHistory
52 {
53     /** @Id @GeneratedValue @Column(type="integer") */
54     public $id;
55
56     /** @OneToOne(targetEntity="DDC1250ClientHistory", inversedBy="declinedBy")
57      * @JoinColumn(name="declined_clients_history_id", referencedColumnName="id")
58      */
59     public $declinedClientsHistory;
60
61     /**
62      * @OneToOne(targetEntity="DDC1250ClientHistory", mappedBy="declinedClientsHistory")
63      * @var
64      */
65     public $declinedBy;
66 }
67
68 /**
69  *
70 Entities\ClientsHistory:
71 type: entity
72 table: clients_history
73 fields:
74 id:
75 id: true
76 type: integer
77 unsigned: false
78 nullable: false
79 generator:
80 strategy: IDENTITY
81 [...skiped...]
82 oneToOne:
83 declinedClientsHistory:
84 targetEntity: Entities\ClientsHistory
85 joinColumn:
86 name: declined_clients_history_id
87 referencedColumnName: id
88 inversedBy: declinedBy
89 declinedBy:
90 targetEntity: Entities\ClientsHistory
91 mappedBy: declinedClientsHistory
92 lifecycleCallbacks: { }
93 repositoryClass: Entities\ClientsHistoryRepository
94
95
96  */