Rajout de doctrine/orm
[zf2.biz/galerie.git] / vendor / doctrine / orm / tests / Doctrine / Tests / ORM / Functional / Ticket / DDC832Test.php
1 <?php
2
3 namespace Doctrine\Tests\ORM\Functional\Ticket;
4
5 use Doctrine\Common\Collections\ArrayCollection;
6 use Doctrine\Tests\Models\CMS\CmsUser;
7 use Doctrine\Tests\Models\CMS\CmsGroup;
8
9 require_once __DIR__ . '/../../../TestInit.php';
10
11 class DDC832Test extends \Doctrine\Tests\OrmFunctionalTestCase
12 {
13     public function setUp()
14     {
15         parent::setUp();
16         $platform = $this->_em->getConnection()->getDatabasePlatform();
17         if ($platform->getName() == "oracle") {
18             $this->markTestSkipped('Doesnt run on Oracle.');
19         }
20
21         $this->_em->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger());
22         try {
23             $this->_schemaTool->createSchema(array(
24                 $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC832JoinedIndex'),
25                 $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC832JoinedTreeIndex'),
26                 $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC832Like'),
27             ));
28         } catch(\Exception $e) {
29
30         }
31     }
32
33     public function tearDown()
34     {
35         /* @var $sm \Doctrine\DBAL\Schema\AbstractSchemaManager */
36         $platform = $this->_em->getConnection()->getDatabasePlatform();
37         $sm = $this->_em->getConnection()->getSchemaManager();
38         $sm->dropTable($platform->quoteIdentifier('TREE_INDEX'));
39         $sm->dropTable($platform->quoteIdentifier('INDEX'));
40         $sm->dropTable($platform->quoteIdentifier('LIKE'));
41     }
42
43     /**
44      * @group DDC-832
45      */
46     public function testQuotedTableBasicUpdate()
47     {
48         $like = new DDC832Like("test");
49         $this->_em->persist($like);
50         $this->_em->flush();
51
52         $like->word = "test2";
53         $this->_em->flush();
54     }
55
56     /**
57      * @group DDC-832
58      */
59     public function testQuotedTableBasicRemove()
60     {
61         $like = new DDC832Like("test");
62         $this->_em->persist($like);
63         $this->_em->flush();
64
65         $this->_em->remove($like);
66         $this->_em->flush();
67     }
68
69     /**
70      * @group DDC-832
71      */
72     public function testQuotedTableJoinedUpdate()
73     {
74         $index = new DDC832JoinedIndex("test");
75         $this->_em->persist($index);
76         $this->_em->flush();
77
78         $index->name = "asdf";
79         $this->_em->flush();
80     }
81
82     /**
83      * @group DDC-832
84      */
85     public function testQuotedTableJoinedRemove()
86     {
87         $index = new DDC832JoinedIndex("test");
88         $this->_em->persist($index);
89         $this->_em->flush();
90
91         $this->_em->remove($index);
92         $this->_em->flush();
93     }
94
95     /**
96      * @group DDC-832
97      */
98     public function testQuotedTableJoinedChildUpdate()
99     {
100         $index = new DDC832JoinedTreeIndex("test", 1, 2);
101         $this->_em->persist($index);
102         $this->_em->flush();
103
104         $index->name = "asdf";
105         $this->_em->flush();
106     }
107
108     /**
109      * @group DDC-832
110      */
111     public function testQuotedTableJoinedChildRemove()
112     {
113         $index = new DDC832JoinedTreeIndex("test", 1, 2);
114         $this->_em->persist($index);
115         $this->_em->flush();
116
117         $this->_em->remove($index);
118         $this->_em->flush();
119     }
120 }
121
122 /**
123  * @Entity
124  * @Table(name="`LIKE`")
125  */
126 class DDC832Like
127 {
128     /**
129      * @Id @Column(type="integer") @GeneratedValue
130      */
131     public $id;
132
133     /** @Column(type="string") */
134     public $word;
135
136     /**
137      * @version
138      * @Column(type="integer")
139      */
140     public $version;
141
142     public function __construct($word)
143     {
144         $this->word = $word;
145     }
146 }
147
148 /**
149  * @Entity
150  * @Table(name="`INDEX`")
151  * @InheritanceType("JOINED")
152  * @DiscriminatorColumn(name="discr", type="string")
153  * @DiscriminatorMap({"like" = "DDC832JoinedIndex", "fuzzy" = "DDC832JoinedTreeIndex"})
154  */
155 class DDC832JoinedIndex
156 {
157     /**
158      * @Id @Column(type="integer") @GeneratedValue
159      */
160     public $id;
161
162     /** @Column(type="string") */
163     public $name;
164
165     /**
166      * @version
167      * @Column(type="integer")
168      */
169     public $version;
170
171     public function __construct($name)
172     {
173         $this->name = $name;
174     }
175 }
176
177 /**
178  * @Entity
179  * @Table(name="`TREE_INDEX`")
180  */
181 class DDC832JoinedTreeIndex extends DDC832JoinedIndex
182 {
183     /** @Column(type="integer") */
184     public $lft;
185     /** @Column(type="integer") */
186     public $rgt;
187
188     public function __construct($name, $lft, $rgt)
189     {
190         $this->name = $name;
191         $this->lft = $lft;
192         $this->rgt = $rgt;
193     }
194 }