|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Doctrine\Tests; |
|
4
|
|
|
|
|
5
|
|
|
use Doctrine\DBAL\Types\Type; |
|
6
|
|
|
use Doctrine\Tests\EventListener\CacheMetadataListener; |
|
7
|
|
|
use Doctrine\ORM\Cache\Logging\StatisticsCacheLogger; |
|
8
|
|
|
use Doctrine\ORM\Cache\DefaultCacheFactory; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* Base testcase class for all functional ORM testcases. |
|
12
|
|
|
* |
|
13
|
|
|
* @since 2.0 |
|
14
|
|
|
*/ |
|
15
|
|
|
abstract class OrmFunctionalTestCase extends OrmTestCase |
|
16
|
|
|
{ |
|
17
|
|
|
/** |
|
18
|
|
|
* The metadata cache shared between all functional tests. |
|
19
|
|
|
* |
|
20
|
|
|
* @var \Doctrine\Common\Cache\Cache|null |
|
21
|
|
|
*/ |
|
22
|
|
|
private static $_metadataCacheImpl = null; |
|
|
|
|
|
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* The query cache shared between all functional tests. |
|
26
|
|
|
* |
|
27
|
|
|
* @var \Doctrine\Common\Cache\Cache|null |
|
28
|
|
|
*/ |
|
29
|
|
|
private static $_queryCacheImpl = null; |
|
|
|
|
|
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* Shared connection when a TestCase is run alone (outside of its functional suite). |
|
33
|
|
|
* |
|
34
|
|
|
* @var \Doctrine\DBAL\Connection|null |
|
35
|
|
|
*/ |
|
36
|
|
|
protected static $_sharedConn; |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @var \Doctrine\ORM\EntityManager |
|
40
|
|
|
*/ |
|
41
|
|
|
protected $_em; |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @var \Doctrine\ORM\Tools\SchemaTool |
|
45
|
|
|
*/ |
|
46
|
|
|
protected $_schemaTool; |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* @var \Doctrine\DBAL\Logging\DebugStack |
|
50
|
|
|
*/ |
|
51
|
|
|
protected $_sqlLoggerStack; |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* The names of the model sets used in this testcase. |
|
55
|
|
|
* |
|
56
|
|
|
* @var array |
|
57
|
|
|
*/ |
|
58
|
|
|
protected $_usedModelSets = array(); |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* Whether the database schema has already been created. |
|
62
|
|
|
* |
|
63
|
|
|
* @var array |
|
64
|
|
|
*/ |
|
65
|
|
|
protected static $_tablesCreated = array(); |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* Array of entity class name to their tables that were created. |
|
69
|
|
|
* |
|
70
|
|
|
* @var array |
|
71
|
|
|
*/ |
|
72
|
|
|
protected static $_entityTablesCreated = array(); |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* List of model sets and their classes. |
|
76
|
|
|
* |
|
77
|
|
|
* @var array |
|
78
|
|
|
*/ |
|
79
|
|
|
protected static $_modelSets = array( |
|
80
|
|
|
'cms' => array( |
|
81
|
|
|
'Doctrine\Tests\Models\CMS\CmsUser', |
|
82
|
|
|
'Doctrine\Tests\Models\CMS\CmsPhonenumber', |
|
83
|
|
|
'Doctrine\Tests\Models\CMS\CmsAddress', |
|
84
|
|
|
'Doctrine\Tests\Models\CMS\CmsEmail', |
|
85
|
|
|
'Doctrine\Tests\Models\CMS\CmsGroup', |
|
86
|
|
|
'Doctrine\Tests\Models\CMS\CmsArticle', |
|
87
|
|
|
'Doctrine\Tests\Models\CMS\CmsComment', |
|
88
|
|
|
), |
|
89
|
|
|
'forum' => array(), |
|
90
|
|
|
'company' => array( |
|
91
|
|
|
'Doctrine\Tests\Models\Company\CompanyPerson', |
|
92
|
|
|
'Doctrine\Tests\Models\Company\CompanyEmployee', |
|
93
|
|
|
'Doctrine\Tests\Models\Company\CompanyManager', |
|
94
|
|
|
'Doctrine\Tests\Models\Company\CompanyOrganization', |
|
95
|
|
|
'Doctrine\Tests\Models\Company\CompanyEvent', |
|
96
|
|
|
'Doctrine\Tests\Models\Company\CompanyAuction', |
|
97
|
|
|
'Doctrine\Tests\Models\Company\CompanyRaffle', |
|
98
|
|
|
'Doctrine\Tests\Models\Company\CompanyCar', |
|
99
|
|
|
'Doctrine\Tests\Models\Company\CompanyContract', |
|
100
|
|
|
), |
|
101
|
|
|
'ecommerce' => array( |
|
102
|
|
|
'Doctrine\Tests\Models\ECommerce\ECommerceCart', |
|
103
|
|
|
'Doctrine\Tests\Models\ECommerce\ECommerceCustomer', |
|
104
|
|
|
'Doctrine\Tests\Models\ECommerce\ECommerceProduct', |
|
105
|
|
|
'Doctrine\Tests\Models\ECommerce\ECommerceShipping', |
|
106
|
|
|
'Doctrine\Tests\Models\ECommerce\ECommerceFeature', |
|
107
|
|
|
'Doctrine\Tests\Models\ECommerce\ECommerceCategory' |
|
108
|
|
|
), |
|
109
|
|
|
'generic' => array( |
|
110
|
|
|
'Doctrine\Tests\Models\Generic\BooleanModel', |
|
111
|
|
|
'Doctrine\Tests\Models\Generic\DateTimeModel', |
|
112
|
|
|
'Doctrine\Tests\Models\Generic\DecimalModel', |
|
113
|
|
|
'Doctrine\Tests\Models\Generic\SerializationModel', |
|
114
|
|
|
), |
|
115
|
|
|
'routing' => array( |
|
116
|
|
|
'Doctrine\Tests\Models\Routing\RoutingLeg', |
|
117
|
|
|
'Doctrine\Tests\Models\Routing\RoutingLocation', |
|
118
|
|
|
'Doctrine\Tests\Models\Routing\RoutingRoute', |
|
119
|
|
|
'Doctrine\Tests\Models\Routing\RoutingRouteBooking', |
|
120
|
|
|
), |
|
121
|
|
|
'navigation' => array( |
|
122
|
|
|
'Doctrine\Tests\Models\Navigation\NavUser', |
|
123
|
|
|
'Doctrine\Tests\Models\Navigation\NavCountry', |
|
124
|
|
|
'Doctrine\Tests\Models\Navigation\NavPhotos', |
|
125
|
|
|
'Doctrine\Tests\Models\Navigation\NavTour', |
|
126
|
|
|
'Doctrine\Tests\Models\Navigation\NavPointOfInterest', |
|
127
|
|
|
), |
|
128
|
|
|
'directorytree' => array( |
|
129
|
|
|
'Doctrine\Tests\Models\DirectoryTree\AbstractContentItem', |
|
130
|
|
|
'Doctrine\Tests\Models\DirectoryTree\File', |
|
131
|
|
|
'Doctrine\Tests\Models\DirectoryTree\Directory', |
|
132
|
|
|
), |
|
133
|
|
|
'ddc117' => array( |
|
134
|
|
|
'Doctrine\Tests\Models\DDC117\DDC117Article', |
|
135
|
|
|
'Doctrine\Tests\Models\DDC117\DDC117Reference', |
|
136
|
|
|
'Doctrine\Tests\Models\DDC117\DDC117Translation', |
|
137
|
|
|
'Doctrine\Tests\Models\DDC117\DDC117ArticleDetails', |
|
138
|
|
|
'Doctrine\Tests\Models\DDC117\DDC117ApproveChanges', |
|
139
|
|
|
'Doctrine\Tests\Models\DDC117\DDC117Editor', |
|
140
|
|
|
'Doctrine\Tests\Models\DDC117\DDC117Link', |
|
141
|
|
|
), |
|
142
|
|
|
'ddc3699' => array( |
|
143
|
|
|
'Doctrine\Tests\Models\DDC3699\DDC3699Parent', |
|
144
|
|
|
'Doctrine\Tests\Models\DDC3699\DDC3699RelationOne', |
|
145
|
|
|
'Doctrine\Tests\Models\DDC3699\DDC3699RelationMany', |
|
146
|
|
|
'Doctrine\Tests\Models\DDC3699\DDC3699Child', |
|
147
|
|
|
), |
|
148
|
|
|
'stockexchange' => array( |
|
149
|
|
|
'Doctrine\Tests\Models\StockExchange\Bond', |
|
150
|
|
|
'Doctrine\Tests\Models\StockExchange\Stock', |
|
151
|
|
|
'Doctrine\Tests\Models\StockExchange\Market', |
|
152
|
|
|
), |
|
153
|
|
|
'legacy' => array( |
|
154
|
|
|
'Doctrine\Tests\Models\Legacy\LegacyUser', |
|
155
|
|
|
'Doctrine\Tests\Models\Legacy\LegacyUserReference', |
|
156
|
|
|
'Doctrine\Tests\Models\Legacy\LegacyArticle', |
|
157
|
|
|
'Doctrine\Tests\Models\Legacy\LegacyCar', |
|
158
|
|
|
), |
|
159
|
|
|
'customtype' => array( |
|
160
|
|
|
'Doctrine\Tests\Models\CustomType\CustomTypeChild', |
|
161
|
|
|
'Doctrine\Tests\Models\CustomType\CustomTypeParent', |
|
162
|
|
|
'Doctrine\Tests\Models\CustomType\CustomTypeUpperCase', |
|
163
|
|
|
), |
|
164
|
|
|
'compositekeyinheritance' => array( |
|
165
|
|
|
'Doctrine\Tests\Models\CompositeKeyInheritance\JoinedRootClass', |
|
166
|
|
|
'Doctrine\Tests\Models\CompositeKeyInheritance\JoinedChildClass', |
|
167
|
|
|
'Doctrine\Tests\Models\CompositeKeyInheritance\SingleRootClass', |
|
168
|
|
|
'Doctrine\Tests\Models\CompositeKeyInheritance\SingleChildClass', |
|
169
|
|
|
), |
|
170
|
|
|
'taxi' => array( |
|
171
|
|
|
'Doctrine\Tests\Models\Taxi\PaidRide', |
|
172
|
|
|
'Doctrine\Tests\Models\Taxi\Ride', |
|
173
|
|
|
'Doctrine\Tests\Models\Taxi\Car', |
|
174
|
|
|
'Doctrine\Tests\Models\Taxi\Driver', |
|
175
|
|
|
), |
|
176
|
|
|
'cache' => array( |
|
177
|
|
|
'Doctrine\Tests\Models\Cache\Country', |
|
178
|
|
|
'Doctrine\Tests\Models\Cache\State', |
|
179
|
|
|
'Doctrine\Tests\Models\Cache\City', |
|
180
|
|
|
'Doctrine\Tests\Models\Cache\Traveler', |
|
181
|
|
|
'Doctrine\Tests\Models\Cache\TravelerProfileInfo', |
|
182
|
|
|
'Doctrine\Tests\Models\Cache\TravelerProfile', |
|
183
|
|
|
'Doctrine\Tests\Models\Cache\Travel', |
|
184
|
|
|
'Doctrine\Tests\Models\Cache\Attraction', |
|
185
|
|
|
'Doctrine\Tests\Models\Cache\Restaurant', |
|
186
|
|
|
'Doctrine\Tests\Models\Cache\Beach', |
|
187
|
|
|
'Doctrine\Tests\Models\Cache\Bar', |
|
188
|
|
|
'Doctrine\Tests\Models\Cache\Flight', |
|
189
|
|
|
'Doctrine\Tests\Models\Cache\Token', |
|
190
|
|
|
'Doctrine\Tests\Models\Cache\Login', |
|
191
|
|
|
'Doctrine\Tests\Models\Cache\Client', |
|
192
|
|
|
'Doctrine\Tests\Models\Cache\Person', |
|
193
|
|
|
'Doctrine\Tests\Models\Cache\Address', |
|
194
|
|
|
'Doctrine\Tests\Models\Cache\Action', |
|
195
|
|
|
'Doctrine\Tests\Models\Cache\ComplexAction', |
|
196
|
|
|
'Doctrine\Tests\Models\Cache\AttractionInfo', |
|
197
|
|
|
'Doctrine\Tests\Models\Cache\AttractionContactInfo', |
|
198
|
|
|
'Doctrine\Tests\Models\Cache\AttractionLocationInfo' |
|
199
|
|
|
), |
|
200
|
|
|
'tweet' => array( |
|
201
|
|
|
'Doctrine\Tests\Models\Tweet\User', |
|
202
|
|
|
'Doctrine\Tests\Models\Tweet\Tweet', |
|
203
|
|
|
'Doctrine\Tests\Models\Tweet\UserList', |
|
204
|
|
|
), |
|
205
|
|
|
'ddc2504' => array( |
|
206
|
|
|
'Doctrine\Tests\Models\DDC2504\DDC2504RootClass', |
|
207
|
|
|
'Doctrine\Tests\Models\DDC2504\DDC2504ChildClass', |
|
208
|
|
|
'Doctrine\Tests\Models\DDC2504\DDC2504OtherClass', |
|
209
|
|
|
), |
|
210
|
|
|
'ddc3346' => array( |
|
211
|
|
|
'Doctrine\Tests\Models\DDC3346\DDC3346Author', |
|
212
|
|
|
'Doctrine\Tests\Models\DDC3346\DDC3346Article', |
|
213
|
|
|
), |
|
214
|
|
|
'quote' => array( |
|
215
|
|
|
'Doctrine\Tests\Models\Quote\Address', |
|
216
|
|
|
'Doctrine\Tests\Models\Quote\Group', |
|
217
|
|
|
'Doctrine\Tests\Models\Quote\NumericEntity', |
|
218
|
|
|
'Doctrine\Tests\Models\Quote\Phone', |
|
219
|
|
|
'Doctrine\Tests\Models\Quote\User' |
|
220
|
|
|
), |
|
221
|
|
|
'vct_onetoone' => array( |
|
222
|
|
|
'Doctrine\Tests\Models\ValueConversionType\InversedOneToOneEntity', |
|
223
|
|
|
'Doctrine\Tests\Models\ValueConversionType\OwningOneToOneEntity' |
|
224
|
|
|
), |
|
225
|
|
|
'vct_onetoone_compositeid' => array( |
|
226
|
|
|
'Doctrine\Tests\Models\ValueConversionType\InversedOneToOneCompositeIdEntity', |
|
227
|
|
|
'Doctrine\Tests\Models\ValueConversionType\OwningOneToOneCompositeIdEntity' |
|
228
|
|
|
), |
|
229
|
|
|
'vct_onetoone_compositeid_foreignkey' => array( |
|
230
|
|
|
'Doctrine\Tests\Models\ValueConversionType\AuxiliaryEntity', |
|
231
|
|
|
'Doctrine\Tests\Models\ValueConversionType\InversedOneToOneCompositeIdForeignKeyEntity', |
|
232
|
|
|
'Doctrine\Tests\Models\ValueConversionType\OwningOneToOneCompositeIdForeignKeyEntity' |
|
233
|
|
|
), |
|
234
|
|
|
'vct_onetomany' => array( |
|
235
|
|
|
'Doctrine\Tests\Models\ValueConversionType\InversedOneToManyEntity', |
|
236
|
|
|
'Doctrine\Tests\Models\ValueConversionType\OwningManyToOneEntity' |
|
237
|
|
|
), |
|
238
|
|
|
'vct_onetomany_compositeid' => array( |
|
239
|
|
|
'Doctrine\Tests\Models\ValueConversionType\InversedOneToManyCompositeIdEntity', |
|
240
|
|
|
'Doctrine\Tests\Models\ValueConversionType\OwningManyToOneCompositeIdEntity' |
|
241
|
|
|
), |
|
242
|
|
|
'vct_onetomany_compositeid_foreignkey' => array( |
|
243
|
|
|
'Doctrine\Tests\Models\ValueConversionType\AuxiliaryEntity', |
|
244
|
|
|
'Doctrine\Tests\Models\ValueConversionType\InversedOneToManyCompositeIdForeignKeyEntity', |
|
245
|
|
|
'Doctrine\Tests\Models\ValueConversionType\OwningManyToOneCompositeIdForeignKeyEntity' |
|
246
|
|
|
), |
|
247
|
|
|
'vct_onetomany_extralazy' => array( |
|
248
|
|
|
'Doctrine\Tests\Models\ValueConversionType\InversedOneToManyExtraLazyEntity', |
|
249
|
|
|
'Doctrine\Tests\Models\ValueConversionType\OwningManyToOneExtraLazyEntity' |
|
250
|
|
|
), |
|
251
|
|
|
'vct_manytomany' => array( |
|
252
|
|
|
'Doctrine\Tests\Models\ValueConversionType\InversedManyToManyEntity', |
|
253
|
|
|
'Doctrine\Tests\Models\ValueConversionType\OwningManyToManyEntity' |
|
254
|
|
|
), |
|
255
|
|
|
'vct_manytomany_compositeid' => array( |
|
256
|
|
|
'Doctrine\Tests\Models\ValueConversionType\InversedManyToManyCompositeIdEntity', |
|
257
|
|
|
'Doctrine\Tests\Models\ValueConversionType\OwningManyToManyCompositeIdEntity' |
|
258
|
|
|
), |
|
259
|
|
|
'vct_manytomany_compositeid_foreignkey' => array( |
|
260
|
|
|
'Doctrine\Tests\Models\ValueConversionType\AuxiliaryEntity', |
|
261
|
|
|
'Doctrine\Tests\Models\ValueConversionType\InversedManyToManyCompositeIdForeignKeyEntity', |
|
262
|
|
|
'Doctrine\Tests\Models\ValueConversionType\OwningManyToManyCompositeIdForeignKeyEntity' |
|
263
|
|
|
), |
|
264
|
|
|
'vct_manytomany_extralazy' => array( |
|
265
|
|
|
'Doctrine\Tests\Models\ValueConversionType\InversedManyToManyExtraLazyEntity', |
|
266
|
|
|
'Doctrine\Tests\Models\ValueConversionType\OwningManyToManyExtraLazyEntity' |
|
267
|
|
|
), |
|
268
|
|
|
'geonames' => array( |
|
269
|
|
|
'Doctrine\Tests\Models\GeoNames\Country', |
|
270
|
|
|
'Doctrine\Tests\Models\GeoNames\Admin1', |
|
271
|
|
|
'Doctrine\Tests\Models\GeoNames\Admin1AlternateName', |
|
272
|
|
|
'Doctrine\Tests\Models\GeoNames\City' |
|
273
|
|
|
), |
|
274
|
|
|
'custom_id_object_type' => array( |
|
275
|
|
|
'Doctrine\Tests\Models\CustomType\CustomIdObjectTypeParent', |
|
276
|
|
|
'Doctrine\Tests\Models\CustomType\CustomIdObjectTypeChild', |
|
277
|
|
|
), |
|
278
|
|
|
'pagination' => array( |
|
279
|
|
|
'Doctrine\Tests\Models\Pagination\Company', |
|
280
|
|
|
'Doctrine\Tests\Models\Pagination\Logo', |
|
281
|
|
|
'Doctrine\Tests\Models\Pagination\Department', |
|
282
|
|
|
'Doctrine\Tests\Models\Pagination\User', |
|
283
|
|
|
'Doctrine\Tests\Models\Pagination\User1', |
|
284
|
|
|
), |
|
285
|
|
|
'versioned_many_to_one' => array( |
|
286
|
|
|
'Doctrine\Tests\Models\VersionedManyToOne\Category', |
|
287
|
|
|
'Doctrine\Tests\Models\VersionedManyToOne\Article', |
|
288
|
|
|
), |
|
289
|
|
|
); |
|
290
|
|
|
|
|
291
|
|
|
/** |
|
292
|
|
|
* @param string $setName |
|
293
|
|
|
* |
|
294
|
|
|
* @return void |
|
295
|
|
|
*/ |
|
296
|
|
|
protected function useModelSet($setName) |
|
297
|
|
|
{ |
|
298
|
|
|
$this->_usedModelSets[$setName] = true; |
|
299
|
|
|
} |
|
300
|
|
|
|
|
301
|
|
|
/** |
|
302
|
|
|
* Sweeps the database tables and clears the EntityManager. |
|
303
|
|
|
* |
|
304
|
|
|
* @return void |
|
305
|
|
|
*/ |
|
306
|
|
|
protected function tearDown() |
|
307
|
|
|
{ |
|
308
|
|
|
$conn = static::$_sharedConn; |
|
309
|
|
|
|
|
310
|
|
|
// In case test is skipped, tearDown is called, but no setup may have run |
|
311
|
|
|
if ( ! $conn) { |
|
312
|
|
|
return; |
|
313
|
|
|
} |
|
314
|
|
|
|
|
315
|
|
|
$platform = $conn->getDatabasePlatform(); |
|
316
|
|
|
|
|
317
|
|
|
$this->_sqlLoggerStack->enabled = false; |
|
318
|
|
|
|
|
319
|
|
|
if (isset($this->_usedModelSets['cms'])) { |
|
320
|
|
|
$conn->executeUpdate('DELETE FROM cms_users_groups'); |
|
321
|
|
|
$conn->executeUpdate('DELETE FROM cms_groups'); |
|
322
|
|
|
$conn->executeUpdate('DELETE FROM cms_addresses'); |
|
323
|
|
|
$conn->executeUpdate('DELETE FROM cms_phonenumbers'); |
|
324
|
|
|
$conn->executeUpdate('DELETE FROM cms_comments'); |
|
325
|
|
|
$conn->executeUpdate('DELETE FROM cms_articles'); |
|
326
|
|
|
$conn->executeUpdate('DELETE FROM cms_users'); |
|
327
|
|
|
$conn->executeUpdate('DELETE FROM cms_emails'); |
|
328
|
|
|
} |
|
329
|
|
|
|
|
330
|
|
|
if (isset($this->_usedModelSets['ecommerce'])) { |
|
331
|
|
|
$conn->executeUpdate('DELETE FROM ecommerce_carts_products'); |
|
332
|
|
|
$conn->executeUpdate('DELETE FROM ecommerce_products_categories'); |
|
333
|
|
|
$conn->executeUpdate('DELETE FROM ecommerce_products_related'); |
|
334
|
|
|
$conn->executeUpdate('DELETE FROM ecommerce_carts'); |
|
335
|
|
|
$conn->executeUpdate('DELETE FROM ecommerce_customers'); |
|
336
|
|
|
$conn->executeUpdate('DELETE FROM ecommerce_features'); |
|
337
|
|
|
$conn->executeUpdate('DELETE FROM ecommerce_products'); |
|
338
|
|
|
$conn->executeUpdate('DELETE FROM ecommerce_shippings'); |
|
339
|
|
|
$conn->executeUpdate('UPDATE ecommerce_categories SET parent_id = NULL'); |
|
340
|
|
|
$conn->executeUpdate('DELETE FROM ecommerce_categories'); |
|
341
|
|
|
} |
|
342
|
|
|
|
|
343
|
|
|
if (isset($this->_usedModelSets['company'])) { |
|
344
|
|
|
$conn->executeUpdate('DELETE FROM company_contract_employees'); |
|
345
|
|
|
$conn->executeUpdate('DELETE FROM company_contract_managers'); |
|
346
|
|
|
$conn->executeUpdate('DELETE FROM company_contracts'); |
|
347
|
|
|
$conn->executeUpdate('DELETE FROM company_persons_friends'); |
|
348
|
|
|
$conn->executeUpdate('DELETE FROM company_managers'); |
|
349
|
|
|
$conn->executeUpdate('DELETE FROM company_employees'); |
|
350
|
|
|
$conn->executeUpdate('UPDATE company_persons SET spouse_id = NULL'); |
|
351
|
|
|
$conn->executeUpdate('DELETE FROM company_persons'); |
|
352
|
|
|
$conn->executeUpdate('DELETE FROM company_raffles'); |
|
353
|
|
|
$conn->executeUpdate('DELETE FROM company_auctions'); |
|
354
|
|
|
$conn->executeUpdate('UPDATE company_organizations SET main_event_id = NULL'); |
|
355
|
|
|
$conn->executeUpdate('DELETE FROM company_events'); |
|
356
|
|
|
$conn->executeUpdate('DELETE FROM company_organizations'); |
|
357
|
|
|
} |
|
358
|
|
|
|
|
359
|
|
|
if (isset($this->_usedModelSets['generic'])) { |
|
360
|
|
|
$conn->executeUpdate('DELETE FROM boolean_model'); |
|
361
|
|
|
$conn->executeUpdate('DELETE FROM date_time_model'); |
|
362
|
|
|
$conn->executeUpdate('DELETE FROM decimal_model'); |
|
363
|
|
|
$conn->executeUpdate('DELETE FROM serialize_model'); |
|
364
|
|
|
} |
|
365
|
|
|
|
|
366
|
|
|
if (isset($this->_usedModelSets['routing'])) { |
|
367
|
|
|
$conn->executeUpdate('DELETE FROM RoutingRouteLegs'); |
|
368
|
|
|
$conn->executeUpdate('DELETE FROM RoutingRouteBooking'); |
|
369
|
|
|
$conn->executeUpdate('DELETE FROM RoutingRoute'); |
|
370
|
|
|
$conn->executeUpdate('DELETE FROM RoutingLeg'); |
|
371
|
|
|
$conn->executeUpdate('DELETE FROM RoutingLocation'); |
|
372
|
|
|
} |
|
373
|
|
|
|
|
374
|
|
|
if(isset($this->_usedModelSets['navigation'])) { |
|
375
|
|
|
$conn->executeUpdate('DELETE FROM navigation_tour_pois'); |
|
376
|
|
|
$conn->executeUpdate('DELETE FROM navigation_photos'); |
|
377
|
|
|
$conn->executeUpdate('DELETE FROM navigation_pois'); |
|
378
|
|
|
$conn->executeUpdate('DELETE FROM navigation_tours'); |
|
379
|
|
|
$conn->executeUpdate('DELETE FROM navigation_countries'); |
|
380
|
|
|
} |
|
381
|
|
|
if (isset($this->_usedModelSets['directorytree'])) { |
|
382
|
|
|
$conn->executeUpdate('DELETE FROM ' . $platform->quoteIdentifier("file")); |
|
383
|
|
|
// MySQL doesn't know deferred deletions therefore only executing the second query gives errors. |
|
384
|
|
|
$conn->executeUpdate('DELETE FROM Directory WHERE parentDirectory_id IS NOT NULL'); |
|
385
|
|
|
$conn->executeUpdate('DELETE FROM Directory'); |
|
386
|
|
|
} |
|
387
|
|
|
if (isset($this->_usedModelSets['ddc117'])) { |
|
388
|
|
|
$conn->executeUpdate('DELETE FROM ddc117editor_ddc117translation'); |
|
389
|
|
|
$conn->executeUpdate('DELETE FROM DDC117Editor'); |
|
390
|
|
|
$conn->executeUpdate('DELETE FROM DDC117ApproveChanges'); |
|
391
|
|
|
$conn->executeUpdate('DELETE FROM DDC117Link'); |
|
392
|
|
|
$conn->executeUpdate('DELETE FROM DDC117Reference'); |
|
393
|
|
|
$conn->executeUpdate('DELETE FROM DDC117ArticleDetails'); |
|
394
|
|
|
$conn->executeUpdate('DELETE FROM DDC117Translation'); |
|
395
|
|
|
$conn->executeUpdate('DELETE FROM DDC117Article'); |
|
396
|
|
|
} |
|
397
|
|
|
if (isset($this->_usedModelSets['stockexchange'])) { |
|
398
|
|
|
$conn->executeUpdate('DELETE FROM exchange_bonds_stocks'); |
|
399
|
|
|
$conn->executeUpdate('DELETE FROM exchange_bonds'); |
|
400
|
|
|
$conn->executeUpdate('DELETE FROM exchange_stocks'); |
|
401
|
|
|
$conn->executeUpdate('DELETE FROM exchange_markets'); |
|
402
|
|
|
} |
|
403
|
|
|
if (isset($this->_usedModelSets['legacy'])) { |
|
404
|
|
|
$conn->executeUpdate('DELETE FROM legacy_users_cars'); |
|
405
|
|
|
$conn->executeUpdate('DELETE FROM legacy_users_reference'); |
|
406
|
|
|
$conn->executeUpdate('DELETE FROM legacy_articles'); |
|
407
|
|
|
$conn->executeUpdate('DELETE FROM legacy_cars'); |
|
408
|
|
|
$conn->executeUpdate('DELETE FROM legacy_users'); |
|
409
|
|
|
} |
|
410
|
|
|
|
|
411
|
|
|
if (isset($this->_usedModelSets['customtype'])) { |
|
412
|
|
|
$conn->executeUpdate('DELETE FROM customtype_parent_friends'); |
|
413
|
|
|
$conn->executeUpdate('DELETE FROM customtype_parents'); |
|
414
|
|
|
$conn->executeUpdate('DELETE FROM customtype_children'); |
|
415
|
|
|
$conn->executeUpdate('DELETE FROM customtype_uppercases'); |
|
416
|
|
|
} |
|
417
|
|
|
|
|
418
|
|
|
if (isset($this->_usedModelSets['compositekeyinheritance'])) { |
|
419
|
|
|
$conn->executeUpdate('DELETE FROM JoinedChildClass'); |
|
420
|
|
|
$conn->executeUpdate('DELETE FROM JoinedRootClass'); |
|
421
|
|
|
$conn->executeUpdate('DELETE FROM SingleRootClass'); |
|
422
|
|
|
} |
|
423
|
|
|
|
|
424
|
|
|
if (isset($this->_usedModelSets['taxi'])) { |
|
425
|
|
|
$conn->executeUpdate('DELETE FROM taxi_paid_ride'); |
|
426
|
|
|
$conn->executeUpdate('DELETE FROM taxi_ride'); |
|
427
|
|
|
$conn->executeUpdate('DELETE FROM taxi_car'); |
|
428
|
|
|
$conn->executeUpdate('DELETE FROM taxi_driver'); |
|
429
|
|
|
} |
|
430
|
|
|
|
|
431
|
|
|
if (isset($this->_usedModelSets['tweet'])) { |
|
432
|
|
|
$conn->executeUpdate('DELETE FROM tweet_tweet'); |
|
433
|
|
|
$conn->executeUpdate('DELETE FROM tweet_user_list'); |
|
434
|
|
|
$conn->executeUpdate('DELETE FROM tweet_user'); |
|
435
|
|
|
} |
|
436
|
|
|
|
|
437
|
|
|
if (isset($this->_usedModelSets['cache'])) { |
|
438
|
|
|
$conn->executeUpdate('DELETE FROM cache_attraction_location_info'); |
|
439
|
|
|
$conn->executeUpdate('DELETE FROM cache_attraction_contact_info'); |
|
440
|
|
|
$conn->executeUpdate('DELETE FROM cache_attraction_info'); |
|
441
|
|
|
$conn->executeUpdate('DELETE FROM cache_visited_cities'); |
|
442
|
|
|
$conn->executeUpdate('DELETE FROM cache_flight'); |
|
443
|
|
|
$conn->executeUpdate('DELETE FROM cache_attraction'); |
|
444
|
|
|
$conn->executeUpdate('DELETE FROM cache_travel'); |
|
445
|
|
|
$conn->executeUpdate('DELETE FROM cache_traveler'); |
|
446
|
|
|
$conn->executeUpdate('DELETE FROM cache_traveler_profile_info'); |
|
447
|
|
|
$conn->executeUpdate('DELETE FROM cache_traveler_profile'); |
|
448
|
|
|
$conn->executeUpdate('DELETE FROM cache_city'); |
|
449
|
|
|
$conn->executeUpdate('DELETE FROM cache_state'); |
|
450
|
|
|
$conn->executeUpdate('DELETE FROM cache_country'); |
|
451
|
|
|
$conn->executeUpdate('DELETE FROM cache_login'); |
|
452
|
|
|
$conn->executeUpdate('DELETE FROM cache_complex_action'); |
|
453
|
|
|
$conn->executeUpdate('DELETE FROM cache_token'); |
|
454
|
|
|
$conn->executeUpdate('DELETE FROM cache_action'); |
|
455
|
|
|
$conn->executeUpdate('DELETE FROM cache_client'); |
|
456
|
|
|
} |
|
457
|
|
|
|
|
458
|
|
|
if (isset($this->_usedModelSets['ddc3346'])) { |
|
459
|
|
|
$conn->executeUpdate('DELETE FROM ddc3346_articles'); |
|
460
|
|
|
$conn->executeUpdate('DELETE FROM ddc3346_users'); |
|
461
|
|
|
} |
|
462
|
|
|
|
|
463
|
|
|
if (isset($this->_usedModelSets['quote'])) { |
|
464
|
|
|
$conn->executeUpdate('DELETE FROM ' . $platform->quoteIdentifier("quote-address")); |
|
465
|
|
|
$conn->executeUpdate('DELETE FROM ' . $platform->quoteIdentifier("quote-group")); |
|
466
|
|
|
$conn->executeUpdate('DELETE FROM ' . $platform->quoteIdentifier("quote-phone")); |
|
467
|
|
|
$conn->executeUpdate('DELETE FROM ' . $platform->quoteIdentifier("quote-user")); |
|
468
|
|
|
} |
|
469
|
|
|
|
|
470
|
|
|
if (isset($this->_usedModelSets['vct_onetoone'])) { |
|
471
|
|
|
$conn->executeUpdate('DELETE FROM vct_owning_onetoone'); |
|
472
|
|
|
$conn->executeUpdate('DELETE FROM vct_inversed_onetoone'); |
|
473
|
|
|
} |
|
474
|
|
|
|
|
475
|
|
|
if (isset($this->_usedModelSets['vct_onetoone_compositeid'])) { |
|
476
|
|
|
$conn->executeUpdate('DELETE FROM vct_owning_onetoone_compositeid'); |
|
477
|
|
|
$conn->executeUpdate('DELETE FROM vct_inversed_onetoone_compositeid'); |
|
478
|
|
|
} |
|
479
|
|
|
|
|
480
|
|
|
if (isset($this->_usedModelSets['vct_onetoone_compositeid_foreignkey'])) { |
|
481
|
|
|
$conn->executeUpdate('DELETE FROM vct_owning_onetoone_compositeid_foreignkey'); |
|
482
|
|
|
$conn->executeUpdate('DELETE FROM vct_inversed_onetoone_compositeid_foreignkey'); |
|
483
|
|
|
$conn->executeUpdate('DELETE FROM vct_auxiliary'); |
|
484
|
|
|
} |
|
485
|
|
|
|
|
486
|
|
|
if (isset($this->_usedModelSets['vct_onetomany'])) { |
|
487
|
|
|
$conn->executeUpdate('DELETE FROM vct_owning_manytoone'); |
|
488
|
|
|
$conn->executeUpdate('DELETE FROM vct_inversed_onetomany'); |
|
489
|
|
|
} |
|
490
|
|
|
|
|
491
|
|
|
if (isset($this->_usedModelSets['vct_onetomany_compositeid'])) { |
|
492
|
|
|
$conn->executeUpdate('DELETE FROM vct_owning_manytoone_compositeid'); |
|
493
|
|
|
$conn->executeUpdate('DELETE FROM vct_inversed_onetomany_compositeid'); |
|
494
|
|
|
} |
|
495
|
|
|
|
|
496
|
|
|
if (isset($this->_usedModelSets['vct_onetomany_compositeid_foreignkey'])) { |
|
497
|
|
|
$conn->executeUpdate('DELETE FROM vct_owning_manytoone_compositeid_foreignkey'); |
|
498
|
|
|
$conn->executeUpdate('DELETE FROM vct_inversed_onetomany_compositeid_foreignkey'); |
|
499
|
|
|
$conn->executeUpdate('DELETE FROM vct_auxiliary'); |
|
500
|
|
|
} |
|
501
|
|
|
|
|
502
|
|
|
if (isset($this->_usedModelSets['vct_onetomany_extralazy'])) { |
|
503
|
|
|
$conn->executeUpdate('DELETE FROM vct_owning_manytoone_extralazy'); |
|
504
|
|
|
$conn->executeUpdate('DELETE FROM vct_inversed_onetomany_extralazy'); |
|
505
|
|
|
} |
|
506
|
|
|
|
|
507
|
|
|
if (isset($this->_usedModelSets['vct_manytomany'])) { |
|
508
|
|
|
$conn->executeUpdate('DELETE FROM vct_xref_manytomany'); |
|
509
|
|
|
$conn->executeUpdate('DELETE FROM vct_owning_manytomany'); |
|
510
|
|
|
$conn->executeUpdate('DELETE FROM vct_inversed_manytomany'); |
|
511
|
|
|
} |
|
512
|
|
|
|
|
513
|
|
|
if (isset($this->_usedModelSets['vct_manytomany_compositeid'])) { |
|
514
|
|
|
$conn->executeUpdate('DELETE FROM vct_xref_manytomany_compositeid'); |
|
515
|
|
|
$conn->executeUpdate('DELETE FROM vct_owning_manytomany_compositeid'); |
|
516
|
|
|
$conn->executeUpdate('DELETE FROM vct_inversed_manytomany_compositeid'); |
|
517
|
|
|
} |
|
518
|
|
|
|
|
519
|
|
|
if (isset($this->_usedModelSets['vct_manytomany_compositeid_foreignkey'])) { |
|
520
|
|
|
$conn->executeUpdate('DELETE FROM vct_xref_manytomany_compositeid_foreignkey'); |
|
521
|
|
|
$conn->executeUpdate('DELETE FROM vct_owning_manytomany_compositeid_foreignkey'); |
|
522
|
|
|
$conn->executeUpdate('DELETE FROM vct_inversed_manytomany_compositeid_foreignkey'); |
|
523
|
|
|
$conn->executeUpdate('DELETE FROM vct_auxiliary'); |
|
524
|
|
|
} |
|
525
|
|
|
|
|
526
|
|
|
if (isset($this->_usedModelSets['vct_manytomany_extralazy'])) { |
|
527
|
|
|
$conn->executeUpdate('DELETE FROM vct_xref_manytomany_extralazy'); |
|
528
|
|
|
$conn->executeUpdate('DELETE FROM vct_owning_manytomany_extralazy'); |
|
529
|
|
|
$conn->executeUpdate('DELETE FROM vct_inversed_manytomany_extralazy'); |
|
530
|
|
|
} |
|
531
|
|
|
if (isset($this->_usedModelSets['geonames'])) { |
|
532
|
|
|
$conn->executeUpdate('DELETE FROM geonames_admin1_alternate_name'); |
|
533
|
|
|
$conn->executeUpdate('DELETE FROM geonames_admin1'); |
|
534
|
|
|
$conn->executeUpdate('DELETE FROM geonames_city'); |
|
535
|
|
|
$conn->executeUpdate('DELETE FROM geonames_country'); |
|
536
|
|
|
} |
|
537
|
|
|
|
|
538
|
|
|
if (isset($this->_usedModelSets['custom_id_object_type'])) { |
|
539
|
|
|
$conn->executeUpdate('DELETE FROM custom_id_type_child'); |
|
540
|
|
|
$conn->executeUpdate('DELETE FROM custom_id_type_parent'); |
|
541
|
|
|
} |
|
542
|
|
|
|
|
543
|
|
|
if (isset($this->_usedModelSets['pagination'])) { |
|
544
|
|
|
$conn->executeUpdate('DELETE FROM pagination_logo'); |
|
545
|
|
|
$conn->executeUpdate('DELETE FROM pagination_department'); |
|
546
|
|
|
$conn->executeUpdate('DELETE FROM pagination_company'); |
|
547
|
|
|
$conn->executeUpdate('DELETE FROM pagination_user'); |
|
548
|
|
|
} |
|
549
|
|
|
|
|
550
|
|
|
if (isset($this->_usedModelSets['versioned_many_to_one'])) { |
|
551
|
|
|
$conn->executeUpdate('DELETE FROM versioned_many_to_one_article'); |
|
552
|
|
|
$conn->executeUpdate('DELETE FROM versioned_many_to_one_category'); |
|
553
|
|
|
} |
|
554
|
|
|
|
|
555
|
|
|
$this->_em->clear(); |
|
556
|
|
|
} |
|
557
|
|
|
|
|
558
|
|
|
/** |
|
559
|
|
|
* @param array $classNames |
|
560
|
|
|
* |
|
561
|
|
|
* @return void |
|
562
|
|
|
* |
|
563
|
|
|
* @throws \RuntimeException |
|
564
|
|
|
*/ |
|
565
|
|
|
protected function setUpEntitySchema(array $classNames) |
|
566
|
|
|
{ |
|
567
|
|
|
if ($this->_em === null) { |
|
568
|
|
|
throw new \RuntimeException("EntityManager not set, you have to call parent::setUp() before invoking this method."); |
|
569
|
|
|
} |
|
570
|
|
|
|
|
571
|
|
|
$classes = array(); |
|
572
|
|
|
foreach ($classNames as $className) { |
|
573
|
|
|
if ( ! isset(static::$_entityTablesCreated[$className])) { |
|
574
|
|
|
static::$_entityTablesCreated[$className] = true; |
|
575
|
|
|
$classes[] = $this->_em->getClassMetadata($className); |
|
576
|
|
|
} |
|
577
|
|
|
} |
|
578
|
|
|
|
|
579
|
|
|
if ($classes) { |
|
|
|
|
|
|
580
|
|
|
$this->_schemaTool->createSchema($classes); |
|
581
|
|
|
} |
|
582
|
|
|
} |
|
583
|
|
|
|
|
584
|
|
|
/** |
|
585
|
|
|
* Creates a connection to the test database, if there is none yet, and |
|
586
|
|
|
* creates the necessary tables. |
|
587
|
|
|
* |
|
588
|
|
|
* @return void |
|
589
|
|
|
*/ |
|
590
|
|
|
protected function setUp() |
|
591
|
|
|
{ |
|
592
|
|
|
$this->setUpDBALTypes(); |
|
593
|
|
|
|
|
594
|
|
|
$forceCreateTables = false; |
|
|
|
|
|
|
595
|
|
|
|
|
596
|
|
|
if ( ! isset(static::$_sharedConn)) { |
|
597
|
|
|
static::$_sharedConn = TestUtil::getConnection(); |
|
598
|
|
|
|
|
599
|
|
|
if (static::$_sharedConn->getDriver() instanceof \Doctrine\DBAL\Driver\PDOSqlite\Driver) { |
|
600
|
|
|
$forceCreateTables = true; |
|
|
|
|
|
|
601
|
|
|
} |
|
602
|
|
|
} |
|
603
|
|
|
|
|
604
|
|
|
if (isset($GLOBALS['DOCTRINE_MARK_SQL_LOGS'])) { |
|
605
|
|
|
if (in_array(static::$_sharedConn->getDatabasePlatform()->getName(), array("mysql", "postgresql"))) { |
|
606
|
|
|
static::$_sharedConn->executeQuery('SELECT 1 /*' . get_class($this) . '*/'); |
|
607
|
|
|
} else if (static::$_sharedConn->getDatabasePlatform()->getName() == "oracle") { |
|
608
|
|
|
static::$_sharedConn->executeQuery('SELECT 1 /*' . get_class($this) . '*/ FROM dual'); |
|
609
|
|
|
} |
|
610
|
|
|
} |
|
611
|
|
|
|
|
612
|
|
|
if ( ! $this->_em) { |
|
613
|
|
|
$this->_em = $this->_getEntityManager(); |
|
614
|
|
|
$this->_schemaTool = new \Doctrine\ORM\Tools\SchemaTool($this->_em); |
|
615
|
|
|
} |
|
616
|
|
|
|
|
617
|
|
|
$classes = array(); |
|
618
|
|
|
|
|
619
|
|
|
foreach ($this->_usedModelSets as $setName => $bool) { |
|
620
|
|
|
if ( ! isset(static::$_tablesCreated[$setName])/* || $forceCreateTables*/) { |
|
621
|
|
|
foreach (static::$_modelSets[$setName] as $className) { |
|
622
|
|
|
$classes[] = $this->_em->getClassMetadata($className); |
|
623
|
|
|
} |
|
624
|
|
|
|
|
625
|
|
|
static::$_tablesCreated[$setName] = true; |
|
626
|
|
|
} |
|
627
|
|
|
} |
|
628
|
|
|
|
|
629
|
|
|
if ($classes) { |
|
|
|
|
|
|
630
|
|
|
$this->_schemaTool->createSchema($classes); |
|
631
|
|
|
} |
|
632
|
|
|
|
|
633
|
|
|
$this->_sqlLoggerStack->enabled = true; |
|
634
|
|
|
} |
|
635
|
|
|
|
|
636
|
|
|
/** |
|
637
|
|
|
* Gets an EntityManager for testing purposes. |
|
638
|
|
|
* |
|
639
|
|
|
* @param \Doctrine\ORM\Configuration $config The Configuration to pass to the EntityManager. |
|
640
|
|
|
* @param \Doctrine\Common\EventManager $eventManager The EventManager to pass to the EntityManager. |
|
641
|
|
|
* |
|
642
|
|
|
* @return \Doctrine\ORM\EntityManager |
|
643
|
|
|
*/ |
|
644
|
|
|
protected function _getEntityManager($config = null, $eventManager = null) { |
|
|
|
|
|
|
645
|
|
|
// NOTE: Functional tests use their own shared metadata cache, because |
|
646
|
|
|
// the actual database platform used during execution has effect on some |
|
647
|
|
|
// metadata mapping behaviors (like the choice of the ID generation). |
|
648
|
|
|
if (is_null(self::$_metadataCacheImpl)) { |
|
649
|
|
|
if (isset($GLOBALS['DOCTRINE_CACHE_IMPL'])) { |
|
650
|
|
|
self::$_metadataCacheImpl = new $GLOBALS['DOCTRINE_CACHE_IMPL']; |
|
651
|
|
|
} else { |
|
652
|
|
|
self::$_metadataCacheImpl = new \Doctrine\Common\Cache\ArrayCache; |
|
653
|
|
|
} |
|
654
|
|
|
} |
|
655
|
|
|
|
|
656
|
|
|
if (is_null(self::$_queryCacheImpl)) { |
|
657
|
|
|
self::$_queryCacheImpl = new \Doctrine\Common\Cache\ArrayCache; |
|
658
|
|
|
} |
|
659
|
|
|
|
|
660
|
|
|
$this->_sqlLoggerStack = new \Doctrine\DBAL\Logging\DebugStack(); |
|
661
|
|
|
$this->_sqlLoggerStack->enabled = false; |
|
662
|
|
|
|
|
663
|
|
|
//FIXME: two different configs! $conn and the created entity manager have |
|
664
|
|
|
// different configs. |
|
665
|
|
|
$config = new \Doctrine\ORM\Configuration(); |
|
666
|
|
|
$config->setMetadataCacheImpl(self::$_metadataCacheImpl); |
|
667
|
|
|
$config->setQueryCacheImpl(self::$_queryCacheImpl); |
|
668
|
|
|
$config->setProxyDir(__DIR__ . '/Proxies'); |
|
669
|
|
|
$config->setProxyNamespace('Doctrine\Tests\Proxies'); |
|
670
|
|
|
|
|
671
|
|
|
$enableSecondLevelCache = getenv('ENABLE_SECOND_LEVEL_CACHE'); |
|
672
|
|
|
|
|
673
|
|
|
if ($this->isSecondLevelCacheEnabled || $enableSecondLevelCache) { |
|
674
|
|
|
|
|
675
|
|
|
$cacheConfig = new \Doctrine\ORM\Cache\CacheConfiguration(); |
|
676
|
|
|
$cache = $this->getSharedSecondLevelCacheDriverImpl(); |
|
677
|
|
|
$factory = new DefaultCacheFactory($cacheConfig->getRegionsConfiguration(), $cache); |
|
678
|
|
|
|
|
679
|
|
|
$this->secondLevelCacheFactory = $factory; |
|
680
|
|
|
|
|
681
|
|
|
if ($this->isSecondLevelCacheLogEnabled) { |
|
682
|
|
|
$this->secondLevelCacheLogger = new StatisticsCacheLogger(); |
|
683
|
|
|
$cacheConfig->setCacheLogger($this->secondLevelCacheLogger); |
|
684
|
|
|
} |
|
685
|
|
|
|
|
686
|
|
|
$cacheConfig->setCacheFactory($factory); |
|
687
|
|
|
$config->setSecondLevelCacheEnabled(true); |
|
688
|
|
|
$config->setSecondLevelCacheConfiguration($cacheConfig); |
|
689
|
|
|
|
|
690
|
|
|
$this->isSecondLevelCacheEnabled = true; |
|
691
|
|
|
} |
|
692
|
|
|
|
|
693
|
|
|
$config->setMetadataDriverImpl($config->newDefaultAnnotationDriver(array( |
|
694
|
|
|
realpath(__DIR__ . '/Models/Cache'), |
|
695
|
|
|
realpath(__DIR__ . '/Models/GeoNames') |
|
696
|
|
|
), true)); |
|
697
|
|
|
|
|
698
|
|
|
$conn = static::$_sharedConn; |
|
699
|
|
|
$conn->getConfiguration()->setSQLLogger($this->_sqlLoggerStack); |
|
700
|
|
|
|
|
701
|
|
|
// get rid of more global state |
|
702
|
|
|
$evm = $conn->getEventManager(); |
|
703
|
|
|
foreach ($evm->getListeners() AS $event => $listeners) { |
|
704
|
|
|
foreach ($listeners AS $listener) { |
|
705
|
|
|
$evm->removeEventListener(array($event), $listener); |
|
706
|
|
|
} |
|
707
|
|
|
} |
|
708
|
|
|
|
|
709
|
|
|
if ($enableSecondLevelCache) { |
|
710
|
|
|
$evm->addEventListener('loadClassMetadata', new CacheMetadataListener()); |
|
711
|
|
|
} |
|
712
|
|
|
|
|
713
|
|
|
if (isset($GLOBALS['db_event_subscribers'])) { |
|
714
|
|
|
foreach (explode(",", $GLOBALS['db_event_subscribers']) AS $subscriberClass) { |
|
715
|
|
|
$subscriberInstance = new $subscriberClass(); |
|
716
|
|
|
$evm->addEventSubscriber($subscriberInstance); |
|
717
|
|
|
} |
|
718
|
|
|
} |
|
719
|
|
|
|
|
720
|
|
|
if (isset($GLOBALS['debug_uow_listener'])) { |
|
721
|
|
|
$evm->addEventListener(array('onFlush'), new \Doctrine\ORM\Tools\DebugUnitOfWorkListener()); |
|
722
|
|
|
} |
|
723
|
|
|
|
|
724
|
|
|
return \Doctrine\ORM\EntityManager::create($conn, $config); |
|
725
|
|
|
} |
|
726
|
|
|
|
|
727
|
|
|
/** |
|
728
|
|
|
* @param \Exception $e |
|
729
|
|
|
* |
|
730
|
|
|
* @return void |
|
731
|
|
|
* |
|
732
|
|
|
* @throws \Exception |
|
733
|
|
|
*/ |
|
734
|
|
|
protected function onNotSuccessfulTest(\Exception $e) |
|
735
|
|
|
{ |
|
736
|
|
|
if ($e instanceof \PHPUnit_Framework_AssertionFailedError) { |
|
737
|
|
|
throw $e; |
|
738
|
|
|
} |
|
739
|
|
|
|
|
740
|
|
|
if(isset($this->_sqlLoggerStack->queries) && count($this->_sqlLoggerStack->queries)) { |
|
741
|
|
|
$queries = ""; |
|
742
|
|
|
for($i = count($this->_sqlLoggerStack->queries)-1; $i > max(count($this->_sqlLoggerStack->queries)-25, 0) && isset($this->_sqlLoggerStack->queries[$i]); $i--) { |
|
743
|
|
|
$query = $this->_sqlLoggerStack->queries[$i]; |
|
744
|
|
|
$params = array_map(function($p) { if (is_object($p)) return get_class($p); else return "'".$p."'"; }, $query['params'] ?: array()); |
|
745
|
|
|
$queries .= ($i+1).". SQL: '".$query['sql']."' Params: ".implode(", ", $params).PHP_EOL; |
|
746
|
|
|
} |
|
747
|
|
|
|
|
748
|
|
|
$trace = $e->getTrace(); |
|
749
|
|
|
$traceMsg = ""; |
|
750
|
|
|
foreach($trace AS $part) { |
|
751
|
|
|
if(isset($part['file'])) { |
|
752
|
|
|
if(strpos($part['file'], "PHPUnit/") !== false) { |
|
753
|
|
|
// Beginning with PHPUnit files we don't print the trace anymore. |
|
754
|
|
|
break; |
|
755
|
|
|
} |
|
756
|
|
|
|
|
757
|
|
|
$traceMsg .= $part['file'].":".$part['line'].PHP_EOL; |
|
758
|
|
|
} |
|
759
|
|
|
} |
|
760
|
|
|
|
|
761
|
|
|
$message = "[".get_class($e)."] ".$e->getMessage().PHP_EOL.PHP_EOL."With queries:".PHP_EOL.$queries.PHP_EOL."Trace:".PHP_EOL.$traceMsg; |
|
762
|
|
|
|
|
763
|
|
|
throw new \Exception($message, (int)$e->getCode(), $e); |
|
764
|
|
|
} |
|
765
|
|
|
throw $e; |
|
766
|
|
|
} |
|
767
|
|
|
|
|
768
|
|
|
public function assertSQLEquals($expectedSql, $actualSql) |
|
769
|
|
|
{ |
|
770
|
|
|
return $this->assertEquals(strtolower($expectedSql), strtolower($actualSql), "Lowercase comparison of SQL statements failed."); |
|
771
|
|
|
} |
|
772
|
|
|
|
|
773
|
|
|
/** |
|
774
|
|
|
* Using the SQL Logger Stack this method retrieves the current query count executed in this test. |
|
775
|
|
|
* |
|
776
|
|
|
* @return int |
|
777
|
|
|
*/ |
|
778
|
|
|
protected function getCurrentQueryCount() |
|
779
|
|
|
{ |
|
780
|
|
|
return count($this->_sqlLoggerStack->queries); |
|
781
|
|
|
} |
|
782
|
|
|
|
|
783
|
|
|
/** |
|
784
|
|
|
* Configures DBAL types required in tests |
|
785
|
|
|
*/ |
|
786
|
|
|
protected function setUpDBALTypes() |
|
787
|
|
|
{ |
|
788
|
|
|
if (Type::hasType('rot13')) { |
|
789
|
|
|
Type::overrideType('rot13', 'Doctrine\Tests\DbalTypes\Rot13Type'); |
|
790
|
|
|
} else { |
|
791
|
|
|
Type::addType('rot13', 'Doctrine\Tests\DbalTypes\Rot13Type'); |
|
792
|
|
|
} |
|
793
|
|
|
} |
|
794
|
|
|
} |
|
795
|
|
|
|