1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* File contains: eZ\Publish\Core\Persistence\Legacy\Tests\Content\Type\Gateway\DoctrineDatabaseTest class. |
5
|
|
|
* |
6
|
|
|
* @copyright Copyright (C) eZ Systems AS. All rights reserved. |
7
|
|
|
* @license For full copyright and license information view LICENSE file distributed with this source code. |
8
|
|
|
* |
9
|
|
|
* @version //autogentag// |
10
|
|
|
*/ |
11
|
|
|
namespace eZ\Publish\Core\Persistence\Legacy\Tests\Content\Gateway; |
12
|
|
|
|
13
|
|
|
use eZ\Publish\Core\Persistence\Legacy\Tests\Content\LanguageAwareTestCase; |
14
|
|
|
use eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase; |
15
|
|
|
use eZ\Publish\Core\Persistence\Legacy\Content\StorageFieldValue; |
16
|
|
|
use eZ\Publish\SPI\Persistence\Content; |
17
|
|
|
use eZ\Publish\SPI\Persistence\Content\ContentInfo; |
18
|
|
|
use eZ\Publish\SPI\Persistence\Content\CreateStruct; |
19
|
|
|
use eZ\Publish\SPI\Persistence\Content\UpdateStruct; |
20
|
|
|
use eZ\Publish\SPI\Persistence\Content\MetadataUpdateStruct; |
21
|
|
|
use eZ\Publish\SPI\Persistence\Content\Field; |
22
|
|
|
use eZ\Publish\SPI\Persistence\Content\VersionInfo; |
23
|
|
|
use eZ\Publish\API\Repository\Values\Content\Relation as RelationValue; |
24
|
|
|
use eZ\Publish\SPI\Persistence\Content\Relation\CreateStruct as RelationCreateStruct; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Test case for eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase. |
28
|
|
|
*/ |
29
|
|
|
class DoctrineDatabaseTest extends LanguageAwareTestCase |
30
|
|
|
{ |
31
|
|
|
/** |
32
|
|
|
* Database gateway to test. |
33
|
|
|
* |
34
|
|
|
* @var \eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase |
35
|
|
|
*/ |
36
|
|
|
protected $databaseGateway; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @covers eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase::__construct |
40
|
|
|
*/ |
41
|
|
|
public function testCtor() |
42
|
|
|
{ |
43
|
|
|
$handlerMock = $this->getDatabaseHandler(); |
44
|
|
|
$gateway = $this->getDatabaseGateway(); |
45
|
|
|
|
46
|
|
|
$this->assertAttributeSame( |
47
|
|
|
$handlerMock, |
48
|
|
|
'dbHandler', |
49
|
|
|
$gateway |
50
|
|
|
); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @covers eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase::insertContentObject |
55
|
|
|
* @covers eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase::generateLanguageMask |
56
|
|
|
* |
57
|
|
|
* @todo Fix not available fields |
58
|
|
|
*/ |
59
|
|
|
public function testInsertContentObject() |
60
|
|
|
{ |
61
|
|
|
$struct = $this->getCreateStructFixture(); |
62
|
|
|
|
63
|
|
|
$gateway = $this->getDatabaseGateway(); |
64
|
|
|
$gateway->insertContentObject($struct); |
65
|
|
|
|
66
|
|
|
$this->assertQueryResult( |
67
|
|
|
array( |
68
|
|
|
array( |
69
|
|
|
'name' => 'Content name', |
70
|
|
|
'contentclass_id' => '23', |
71
|
|
|
'section_id' => '42', |
72
|
|
|
'owner_id' => '13', |
73
|
|
|
'current_version' => '1', |
74
|
|
|
'initial_language_id' => '2', |
75
|
|
|
'remote_id' => 'some_remote_id', |
76
|
|
|
'language_mask' => '3', |
77
|
|
|
'modified' => '0', |
78
|
|
|
'published' => '0', |
79
|
|
|
'status' => ContentInfo::STATUS_DRAFT, |
80
|
|
|
), |
81
|
|
|
), |
82
|
|
|
$this->getDatabaseHandler() |
83
|
|
|
->createSelectQuery() |
84
|
|
|
->select( |
85
|
|
|
array( |
86
|
|
|
'name', |
87
|
|
|
'contentclass_id', |
88
|
|
|
'section_id', |
89
|
|
|
'owner_id', |
90
|
|
|
'current_version', |
91
|
|
|
'initial_language_id', |
92
|
|
|
'remote_id', |
93
|
|
|
'language_mask', |
94
|
|
|
'modified', |
95
|
|
|
'published', |
96
|
|
|
'status', |
97
|
|
|
) |
98
|
|
|
)->from('ezcontentobject') |
99
|
|
|
); |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* Returns a Content fixture. |
104
|
|
|
* |
105
|
|
|
* @return \eZ\Publish\SPI\Persistence\Content\CreateStruct |
106
|
|
|
*/ |
107
|
|
|
protected function getCreateStructFixture() |
108
|
|
|
{ |
109
|
|
|
$struct = new CreateStruct(); |
110
|
|
|
|
111
|
|
|
$struct->typeId = 23; |
112
|
|
|
$struct->sectionId = 42; |
113
|
|
|
$struct->ownerId = 13; |
114
|
|
|
$struct->initialLanguageId = 2; |
115
|
|
|
$struct->remoteId = 'some_remote_id'; |
116
|
|
|
$struct->alwaysAvailable = true; |
117
|
|
|
$struct->modified = 456; |
118
|
|
|
$struct->name = array( |
|
|
|
|
119
|
|
|
'eng-US' => 'Content name', |
120
|
|
|
); |
121
|
|
|
$struct->fields = array( |
122
|
|
|
new Field(array('languageCode' => 'eng-US')), |
123
|
|
|
); |
124
|
|
|
$struct->locations = array(); |
125
|
|
|
|
126
|
|
|
return $struct; |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* Returns a Content fixture. |
131
|
|
|
* |
132
|
|
|
* @return \eZ\Publish\SPI\Persistence\Content |
133
|
|
|
*/ |
134
|
|
|
protected function getContentFixture() |
135
|
|
|
{ |
136
|
|
|
$content = new Content(); |
137
|
|
|
|
138
|
|
|
$content->versionInfo = new VersionInfo(); |
139
|
|
|
$content->versionInfo->names = array( |
140
|
|
|
'eng-US' => 'Content name', |
141
|
|
|
); |
142
|
|
|
$content->versionInfo->status = VersionInfo::STATUS_PENDING; |
143
|
|
|
|
144
|
|
|
$content->versionInfo->contentInfo = new ContentInfo(); |
145
|
|
|
$content->versionInfo->contentInfo->contentTypeId = 23; |
146
|
|
|
$content->versionInfo->contentInfo->sectionId = 42; |
147
|
|
|
$content->versionInfo->contentInfo->ownerId = 13; |
148
|
|
|
$content->versionInfo->contentInfo->currentVersionNo = 2; |
149
|
|
|
$content->versionInfo->contentInfo->mainLanguageCode = 'eng-US'; |
150
|
|
|
$content->versionInfo->contentInfo->remoteId = 'some_remote_id'; |
151
|
|
|
$content->versionInfo->contentInfo->alwaysAvailable = true; |
152
|
|
|
$content->versionInfo->contentInfo->publicationDate = 123; |
153
|
|
|
$content->versionInfo->contentInfo->modificationDate = 456; |
154
|
|
|
$content->versionInfo->contentInfo->isPublished = false; |
155
|
|
|
$content->versionInfo->contentInfo->name = 'Content name'; |
156
|
|
|
|
157
|
|
|
return $content; |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
/** |
161
|
|
|
* Returns a Version fixture. |
162
|
|
|
* |
163
|
|
|
* @return \eZ\Publish\SPI\Persistence\Content\VersionInfo |
164
|
|
|
*/ |
165
|
|
|
protected function getVersionFixture() |
166
|
|
|
{ |
167
|
|
|
$version = new VersionInfo(); |
168
|
|
|
|
169
|
|
|
$version->id = null; |
170
|
|
|
$version->versionNo = 1; |
171
|
|
|
$version->creatorId = 13; |
172
|
|
|
$version->status = 0; |
173
|
|
|
$version->creationDate = 1312278322; |
174
|
|
|
$version->modificationDate = 1312278323; |
175
|
|
|
$version->initialLanguageCode = 'eng-GB'; |
|
|
|
|
176
|
|
|
$version->contentInfo = new ContentInfo( |
177
|
|
|
array( |
178
|
|
|
'id' => 2342, |
179
|
|
|
'alwaysAvailable' => true, |
180
|
|
|
) |
181
|
|
|
); |
182
|
|
|
|
183
|
|
|
return $version; |
184
|
|
|
} |
185
|
|
|
|
186
|
|
|
/** |
187
|
|
|
* @covers eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase::insertVersion |
188
|
|
|
* @covers eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase::generateLanguageMask |
189
|
|
|
*/ |
190
|
|
|
public function testInsertVersion() |
191
|
|
|
{ |
192
|
|
|
$version = $this->getVersionFixture(); |
193
|
|
|
|
194
|
|
|
$gateway = $this->getDatabaseGateway(); |
195
|
|
|
$gateway->insertVersion($version, array()); |
196
|
|
|
|
197
|
|
|
$this->assertQueryResult( |
198
|
|
|
array( |
199
|
|
|
array( |
200
|
|
|
'contentobject_id' => '2342', |
201
|
|
|
'created' => '1312278322', |
202
|
|
|
'creator_id' => '13', |
203
|
|
|
'modified' => '1312278323', |
204
|
|
|
'status' => '0', |
205
|
|
|
'workflow_event_pos' => '0', |
206
|
|
|
'version' => '1', |
207
|
|
|
'language_mask' => '5', |
208
|
|
|
'initial_language_id' => '4', |
209
|
|
|
// Not needed, according to field mapping document |
210
|
|
|
// 'user_id', |
211
|
|
|
), |
212
|
|
|
), |
213
|
|
|
$this->getDatabaseHandler() |
214
|
|
|
->createSelectQuery() |
215
|
|
|
->select( |
216
|
|
|
array( |
217
|
|
|
'contentobject_id', |
218
|
|
|
'created', |
219
|
|
|
'creator_id', |
220
|
|
|
'modified', |
221
|
|
|
'status', |
222
|
|
|
'workflow_event_pos', |
223
|
|
|
'version', |
224
|
|
|
'language_mask', |
225
|
|
|
'initial_language_id', |
226
|
|
|
) |
227
|
|
|
)->from('ezcontentobject_version') |
228
|
|
|
); |
229
|
|
|
} |
230
|
|
|
|
231
|
|
|
/** |
232
|
|
|
* @covers eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase::setStatus |
233
|
|
|
*/ |
234
|
|
View Code Duplication |
public function testSetStatus() |
235
|
|
|
{ |
236
|
|
|
$gateway = $this->getDatabaseGateway(); |
237
|
|
|
|
238
|
|
|
// insert content |
239
|
|
|
$struct = $this->getCreateStructFixture(); |
240
|
|
|
$contentId = $gateway->insertContentObject($struct); |
241
|
|
|
|
242
|
|
|
// insert version |
243
|
|
|
$version = $this->getVersionFixture(); |
244
|
|
|
$version->contentInfo->id = $contentId; |
245
|
|
|
$gateway->insertVersion($version, array()); |
246
|
|
|
|
247
|
|
|
$this->assertTrue( |
248
|
|
|
$gateway->setStatus($version->contentInfo->id, $version->versionNo, VersionInfo::STATUS_PENDING) |
249
|
|
|
); |
250
|
|
|
|
251
|
|
|
$this->assertQueryResult( |
252
|
|
|
array(array(VersionInfo::STATUS_PENDING)), |
253
|
|
|
$this->getDatabaseHandler() |
254
|
|
|
->createSelectQuery() |
255
|
|
|
->select('status') |
256
|
|
|
->from('ezcontentobject_version') |
257
|
|
|
); |
258
|
|
|
|
259
|
|
|
// check that content status has not been set to published |
260
|
|
|
$this->assertQueryResult( |
261
|
|
|
array(array(VersionInfo::STATUS_DRAFT)), |
262
|
|
|
$this->getDatabaseHandler() |
263
|
|
|
->createSelectQuery() |
264
|
|
|
->select('status') |
265
|
|
|
->from('ezcontentobject') |
266
|
|
|
); |
267
|
|
|
} |
268
|
|
|
|
269
|
|
|
/** |
270
|
|
|
* @covers eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase::setStatus |
271
|
|
|
*/ |
272
|
|
View Code Duplication |
public function testSetStatusPublished() |
273
|
|
|
{ |
274
|
|
|
$gateway = $this->getDatabaseGateway(); |
275
|
|
|
|
276
|
|
|
// insert content |
277
|
|
|
$struct = $this->getCreateStructFixture(); |
278
|
|
|
$contentId = $gateway->insertContentObject($struct); |
279
|
|
|
|
280
|
|
|
// insert version |
281
|
|
|
$version = $this->getVersionFixture(); |
282
|
|
|
$version->contentInfo->id = $contentId; |
283
|
|
|
$gateway->insertVersion($version, array()); |
284
|
|
|
|
285
|
|
|
$this->assertTrue( |
286
|
|
|
$gateway->setStatus($version->contentInfo->id, $version->versionNo, VersionInfo::STATUS_PUBLISHED) |
287
|
|
|
); |
288
|
|
|
|
289
|
|
|
$this->assertQueryResult( |
290
|
|
|
array(array(VersionInfo::STATUS_PUBLISHED)), |
291
|
|
|
$this->getDatabaseHandler() |
292
|
|
|
->createSelectQuery() |
293
|
|
|
->select('status') |
294
|
|
|
->from('ezcontentobject_version') |
295
|
|
|
); |
296
|
|
|
|
297
|
|
|
// check that content status has been set to published |
298
|
|
|
$this->assertQueryResult( |
299
|
|
|
array(array(ContentInfo::STATUS_PUBLISHED)), |
300
|
|
|
$this->getDatabaseHandler() |
301
|
|
|
->createSelectQuery() |
302
|
|
|
->select('status') |
303
|
|
|
->from('ezcontentobject') |
304
|
|
|
); |
305
|
|
|
} |
306
|
|
|
|
307
|
|
|
/** |
308
|
|
|
* @covers eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase::setStatus |
309
|
|
|
*/ |
310
|
|
|
public function testSetStatusUnknownVersion() |
311
|
|
|
{ |
312
|
|
|
$gateway = $this->getDatabaseGateway(); |
313
|
|
|
|
314
|
|
|
$this->assertFalse( |
315
|
|
|
$gateway->setStatus(23, 42, 2) |
316
|
|
|
); |
317
|
|
|
} |
318
|
|
|
|
319
|
|
|
/** |
320
|
|
|
* @covers eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase::updateContent |
321
|
|
|
*/ |
322
|
|
|
public function testUpdateContent() |
323
|
|
|
{ |
324
|
|
|
$gateway = $this->getDatabaseGateway(); |
325
|
|
|
|
326
|
|
|
$this->insertDatabaseFixture( |
327
|
|
|
__DIR__ . '/../_fixtures/contentobjects.php' |
328
|
|
|
); |
329
|
|
|
|
330
|
|
|
$metadataStruct = $this->getMetadataUpdateStructFixture(); |
331
|
|
|
|
332
|
|
|
$gateway->updateContent(10, $metadataStruct); |
333
|
|
|
|
334
|
|
|
$this->assertQueryResult( |
335
|
|
|
array( |
336
|
|
|
array( |
337
|
|
|
'initial_language_id' => '3', |
338
|
|
|
'modified' => '234567', |
339
|
|
|
'owner_id' => '42', |
340
|
|
|
'published' => '123456', |
341
|
|
|
'remote_id' => 'ghjk1234567890ghjk1234567890', |
342
|
|
|
'name' => 'Thoth', |
343
|
|
|
), |
344
|
|
|
), |
345
|
|
|
$this->getDatabaseHandler()->createSelectQuery() |
346
|
|
|
->select( |
347
|
|
|
'initial_language_id', |
348
|
|
|
'modified', |
349
|
|
|
'owner_id', |
350
|
|
|
'published', |
351
|
|
|
'remote_id', |
352
|
|
|
'name' |
353
|
|
|
)->from('ezcontentobject') |
354
|
|
|
->where('id = 10') |
355
|
|
|
); |
356
|
|
|
} |
357
|
|
|
|
358
|
|
|
/** |
359
|
|
|
* Returns an UpdateStruct fixture. |
360
|
|
|
* |
361
|
|
|
* @return \eZ\Publish\SPI\Persistence\Content\UpdateStruct |
362
|
|
|
*/ |
363
|
|
|
protected function getUpdateStructFixture() |
364
|
|
|
{ |
365
|
|
|
$struct = new UpdateStruct(); |
366
|
|
|
$struct->creatorId = 23; |
367
|
|
|
$struct->fields = array(); |
368
|
|
|
$struct->modificationDate = 234567; |
369
|
|
|
$struct->initialLanguageId = 2; |
370
|
|
|
|
371
|
|
|
return $struct; |
372
|
|
|
} |
373
|
|
|
|
374
|
|
|
/** |
375
|
|
|
* Returns a MetadataUpdateStruct fixture. |
376
|
|
|
* |
377
|
|
|
* @return \eZ\Publish\SPI\Persistence\Content\MetadataUpdateStruct |
378
|
|
|
*/ |
379
|
|
|
protected function getMetadataUpdateStructFixture() |
380
|
|
|
{ |
381
|
|
|
$struct = new MetadataUpdateStruct(); |
382
|
|
|
$struct->ownerId = 42; |
383
|
|
|
$struct->publicationDate = 123456; |
384
|
|
|
$struct->mainLanguageId = 3; |
385
|
|
|
$struct->modificationDate = 234567; |
386
|
|
|
$struct->remoteId = 'ghjk1234567890ghjk1234567890'; |
387
|
|
|
$struct->name = 'Thoth'; |
388
|
|
|
|
389
|
|
|
return $struct; |
390
|
|
|
} |
391
|
|
|
|
392
|
|
|
/** |
393
|
|
|
* @covers eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase::updateVersion |
394
|
|
|
*/ |
395
|
|
|
public function testUpdateVersion() |
396
|
|
|
{ |
397
|
|
|
$gateway = $this->getDatabaseGateway(); |
398
|
|
|
|
399
|
|
|
$this->insertDatabaseFixture( |
400
|
|
|
__DIR__ . '/../_fixtures/contentobjects.php' |
401
|
|
|
); |
402
|
|
|
|
403
|
|
|
$gateway->updateVersion(10, 2, $this->getUpdateStructFixture()); |
404
|
|
|
|
405
|
|
|
$query = $this->getDatabaseHandler()->createSelectQuery(); |
406
|
|
|
$this->assertQueryResult( |
407
|
|
|
array( |
408
|
|
|
array( |
409
|
|
|
'creator_id' => '23', |
410
|
|
|
'initial_language_id' => '2', |
411
|
|
|
'modified' => '234567', |
412
|
|
|
), |
413
|
|
|
), |
414
|
|
|
$query |
415
|
|
|
->select( |
416
|
|
|
array( |
417
|
|
|
'creator_id', |
418
|
|
|
'initial_language_id', |
419
|
|
|
'modified', |
420
|
|
|
) |
421
|
|
|
)->from('ezcontentobject_version') |
422
|
|
|
->where( |
423
|
|
|
$query->expr->lAnd( |
424
|
|
|
$query->expr->eq('contentobject_id', 10), |
425
|
|
|
$query->expr->eq('version', 2) |
426
|
|
|
) |
427
|
|
|
) |
428
|
|
|
); |
429
|
|
|
} |
430
|
|
|
|
431
|
|
|
/** |
432
|
|
|
* @covers eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase::insertNewField |
433
|
|
|
*/ |
434
|
|
|
public function testInsertNewField() |
435
|
|
|
{ |
436
|
|
|
$content = $this->getContentFixture(); |
437
|
|
|
$content->versionInfo->contentInfo->id = 2342; |
438
|
|
|
|
439
|
|
|
$field = $this->getFieldFixture(); |
440
|
|
|
$value = $this->getStorageValueFixture(); |
441
|
|
|
|
442
|
|
|
$gateway = $this->getDatabaseGateway(); |
443
|
|
|
$gateway->insertNewField($content, $field, $value); |
444
|
|
|
|
445
|
|
|
$this->assertQueryResult( |
446
|
|
|
array( |
447
|
|
|
array( |
448
|
|
|
'contentclassattribute_id' => '231', |
449
|
|
|
'contentobject_id' => '2342', |
450
|
|
|
'data_float' => '24.42', |
451
|
|
|
'data_int' => '42', |
452
|
|
|
'data_text' => 'Test text', |
453
|
|
|
'data_type_string' => 'ezstring', |
454
|
|
|
'language_code' => 'eng-GB', |
455
|
|
|
'language_id' => '4', |
456
|
|
|
'sort_key_int' => '23', |
457
|
|
|
'sort_key_string' => 'Test', |
458
|
|
|
'version' => '1', |
459
|
|
|
), |
460
|
|
|
), |
461
|
|
|
$this->getDatabaseHandler() |
462
|
|
|
->createSelectQuery() |
463
|
|
|
->select( |
464
|
|
|
array( |
465
|
|
|
'contentclassattribute_id', |
466
|
|
|
'contentobject_id', |
467
|
|
|
'data_float', |
468
|
|
|
'data_int', |
469
|
|
|
'data_text', |
470
|
|
|
'data_type_string', |
471
|
|
|
'language_code', |
472
|
|
|
'language_id', |
473
|
|
|
'sort_key_int', |
474
|
|
|
'sort_key_string', |
475
|
|
|
'version', |
476
|
|
|
) |
477
|
|
|
)->from('ezcontentobject_attribute') |
478
|
|
|
); |
479
|
|
|
} |
480
|
|
|
|
481
|
|
|
/** |
482
|
|
|
* @covers eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase::insertNewField |
483
|
|
|
*/ |
484
|
|
|
public function testInsertNewAlwaysAvailableField() |
485
|
|
|
{ |
486
|
|
|
$content = $this->getContentFixture(); |
487
|
|
|
$content->versionInfo->contentInfo->id = 2342; |
488
|
|
|
// Set main language to the one used in the field fixture |
489
|
|
|
$content->versionInfo->contentInfo->mainLanguageCode = 'eng-GB'; |
490
|
|
|
|
491
|
|
|
$field = $this->getFieldFixture(); |
492
|
|
|
$value = $this->getStorageValueFixture(); |
493
|
|
|
|
494
|
|
|
$gateway = $this->getDatabaseGateway(); |
495
|
|
|
$gateway->insertNewField($content, $field, $value); |
496
|
|
|
|
497
|
|
|
$this->assertQueryResult( |
498
|
|
|
array( |
499
|
|
|
array( |
500
|
|
|
'contentclassattribute_id' => '231', |
501
|
|
|
'contentobject_id' => '2342', |
502
|
|
|
'data_float' => '24.42', |
503
|
|
|
'data_int' => '42', |
504
|
|
|
'data_text' => 'Test text', |
505
|
|
|
'data_type_string' => 'ezstring', |
506
|
|
|
'language_code' => 'eng-GB', |
507
|
|
|
'language_id' => '5', |
508
|
|
|
'sort_key_int' => '23', |
509
|
|
|
'sort_key_string' => 'Test', |
510
|
|
|
'version' => '1', |
511
|
|
|
), |
512
|
|
|
), |
513
|
|
|
$this->getDatabaseHandler() |
514
|
|
|
->createSelectQuery() |
515
|
|
|
->select( |
516
|
|
|
array( |
517
|
|
|
'contentclassattribute_id', |
518
|
|
|
'contentobject_id', |
519
|
|
|
'data_float', |
520
|
|
|
'data_int', |
521
|
|
|
'data_text', |
522
|
|
|
'data_type_string', |
523
|
|
|
'language_code', |
524
|
|
|
'language_id', |
525
|
|
|
'sort_key_int', |
526
|
|
|
'sort_key_string', |
527
|
|
|
'version', |
528
|
|
|
) |
529
|
|
|
)->from('ezcontentobject_attribute') |
530
|
|
|
); |
531
|
|
|
} |
532
|
|
|
|
533
|
|
|
/** |
534
|
|
|
* @covers eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase::updateField |
535
|
|
|
* @covers eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase::setFieldUpdateValues |
536
|
|
|
*/ |
537
|
|
|
public function testUpdateField() |
538
|
|
|
{ |
539
|
|
|
$content = $this->getContentFixture(); |
540
|
|
|
$content->versionInfo->contentInfo->id = 2342; |
541
|
|
|
|
542
|
|
|
$field = $this->getFieldFixture(); |
543
|
|
|
$value = $this->getStorageValueFixture(); |
544
|
|
|
|
545
|
|
|
$gateway = $this->getDatabaseGateway(); |
546
|
|
|
$field->id = $gateway->insertNewField($content, $field, $value); |
547
|
|
|
|
548
|
|
|
$newValue = new StorageFieldValue( |
549
|
|
|
array( |
550
|
|
|
'dataFloat' => 124.42, |
551
|
|
|
'dataInt' => 142, |
552
|
|
|
'dataText' => 'New text', |
553
|
|
|
'sortKeyInt' => 123, |
554
|
|
|
'sortKeyString' => 'new_text', |
555
|
|
|
) |
556
|
|
|
); |
557
|
|
|
|
558
|
|
|
$gateway->updateField($field, $newValue); |
559
|
|
|
|
560
|
|
|
$this->assertQueryResult( |
561
|
|
|
array( |
562
|
|
|
array( |
563
|
|
|
'data_float' => '124.42', |
564
|
|
|
'data_int' => '142', |
565
|
|
|
'data_text' => 'New text', |
566
|
|
|
'sort_key_int' => '123', |
567
|
|
|
'sort_key_string' => 'new_text', |
568
|
|
|
), |
569
|
|
|
), |
570
|
|
|
$this->getDatabaseHandler() |
571
|
|
|
->createSelectQuery() |
572
|
|
|
->select( |
573
|
|
|
array( |
574
|
|
|
'data_float', |
575
|
|
|
'data_int', |
576
|
|
|
'data_text', |
577
|
|
|
'sort_key_int', |
578
|
|
|
'sort_key_string', |
579
|
|
|
) |
580
|
|
|
)->from('ezcontentobject_attribute') |
581
|
|
|
); |
582
|
|
|
} |
583
|
|
|
|
584
|
|
|
/** |
585
|
|
|
* @covers eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase::updateNonTranslatableField |
586
|
|
|
* @covers eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase::setFieldUpdateValues |
587
|
|
|
*/ |
588
|
|
|
public function testUpdateNonTranslatableField() |
589
|
|
|
{ |
590
|
|
|
$content = $this->getContentFixture(); |
591
|
|
|
$content->versionInfo->contentInfo->id = 2342; |
592
|
|
|
|
593
|
|
|
$fieldGb = $this->getFieldFixture(); |
594
|
|
|
$fieldUs = $this->getOtherLanguageFieldFixture(); |
595
|
|
|
$value = $this->getStorageValueFixture(); |
596
|
|
|
|
597
|
|
|
$gateway = $this->getDatabaseGateway(); |
598
|
|
|
$fieldGb->id = $gateway->insertNewField($content, $fieldGb, $value); |
599
|
|
|
$fieldUs->id = $gateway->insertNewField($content, $fieldUs, $value); |
600
|
|
|
|
601
|
|
|
$updateStruct = new Content\UpdateStruct(); |
|
|
|
|
602
|
|
|
|
603
|
|
|
$newValue = new StorageFieldValue( |
604
|
|
|
array( |
605
|
|
|
'dataFloat' => 124.42, |
606
|
|
|
'dataInt' => 142, |
607
|
|
|
'dataText' => 'New text', |
608
|
|
|
'sortKeyInt' => 123, |
609
|
|
|
'sortKeyString' => 'new_text', |
610
|
|
|
) |
611
|
|
|
); |
612
|
|
|
|
613
|
|
|
$gateway->updateNonTranslatableField($fieldGb, $newValue, $content->versionInfo->contentInfo->id); |
614
|
|
|
|
615
|
|
|
$this->assertQueryResult( |
616
|
|
|
array( |
617
|
|
|
// Both fields updated |
618
|
|
|
array( |
619
|
|
|
'data_float' => '124.42', |
620
|
|
|
'data_int' => '142', |
621
|
|
|
'data_text' => 'New text', |
622
|
|
|
'sort_key_int' => '123', |
623
|
|
|
'sort_key_string' => 'new_text', |
624
|
|
|
), |
625
|
|
|
array( |
626
|
|
|
'data_float' => '124.42', |
627
|
|
|
'data_int' => '142', |
628
|
|
|
'data_text' => 'New text', |
629
|
|
|
'sort_key_int' => '123', |
630
|
|
|
'sort_key_string' => 'new_text', |
631
|
|
|
), |
632
|
|
|
), |
633
|
|
|
$this->getDatabaseHandler() |
634
|
|
|
->createSelectQuery() |
635
|
|
|
->select( |
636
|
|
|
array( |
637
|
|
|
'data_float', |
638
|
|
|
'data_int', |
639
|
|
|
'data_text', |
640
|
|
|
'sort_key_int', |
641
|
|
|
'sort_key_string', |
642
|
|
|
) |
643
|
|
|
)->from('ezcontentobject_attribute') |
644
|
|
|
); |
645
|
|
|
} |
646
|
|
|
|
647
|
|
|
/** |
648
|
|
|
* @covers eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase::listVersions |
649
|
|
|
*/ |
650
|
|
|
public function testListVersions() |
651
|
|
|
{ |
652
|
|
|
$this->insertDatabaseFixture( |
653
|
|
|
__DIR__ . '/../_fixtures/contentobjects.php' |
654
|
|
|
); |
655
|
|
|
|
656
|
|
|
$gateway = $this->getDatabaseGateway(); |
657
|
|
|
$res = $gateway->listVersions(226); |
658
|
|
|
|
659
|
|
|
$this->assertEquals( |
660
|
|
|
2, |
661
|
|
|
count($res) |
662
|
|
|
); |
663
|
|
|
|
664
|
|
|
foreach ($res as $row) { |
665
|
|
|
$this->assertEquals( |
666
|
|
|
22, |
667
|
|
|
count($row) |
668
|
|
|
); |
669
|
|
|
} |
670
|
|
|
|
671
|
|
|
$this->assertEquals( |
672
|
|
|
675, |
673
|
|
|
$res[0]['ezcontentobject_version_id'] |
674
|
|
|
); |
675
|
|
|
$this->assertEquals( |
676
|
|
|
676, |
677
|
|
|
$res[1]['ezcontentobject_version_id'] |
678
|
|
|
); |
679
|
|
|
|
680
|
|
|
//$orig = include __DIR__ . '/../_fixtures/restricted_version_rows.php'; |
681
|
|
|
|
682
|
|
|
/*$this->storeFixture( |
683
|
|
|
__DIR__ . '/../_fixtures/restricted_version_rows.php', |
684
|
|
|
$res |
685
|
|
|
);*/ |
686
|
|
|
|
687
|
|
|
//$this->assertEquals( $orig, $res, "Fixtures differ between what was previously stored(expected) and what it now generates(actual), this hints either some mistake in impl or that the fixture (../_fixtures/restricted_version_rows.php) and tests needs to be adapted." ); |
688
|
|
|
} |
689
|
|
|
|
690
|
|
|
/** |
691
|
|
|
* @covers eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase::listVersionNumbers |
692
|
|
|
*/ |
693
|
|
|
public function testListVersionNumbers() |
694
|
|
|
{ |
695
|
|
|
$this->insertDatabaseFixture( |
696
|
|
|
__DIR__ . '/../_fixtures/contentobjects.php' |
697
|
|
|
); |
698
|
|
|
|
699
|
|
|
$gateway = $this->getDatabaseGateway(); |
700
|
|
|
$res = $gateway->listVersionNumbers(226); |
701
|
|
|
|
702
|
|
|
$this->assertEquals(array(1, 2), $res); |
703
|
|
|
} |
704
|
|
|
|
705
|
|
|
/** |
706
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase::listVersionsForUser |
707
|
|
|
*/ |
708
|
|
|
public function testListVersionsForUser() |
709
|
|
|
{ |
710
|
|
|
$this->insertDatabaseFixture( |
711
|
|
|
__DIR__ . '/../_fixtures/contentobjects.php' |
712
|
|
|
); |
713
|
|
|
|
714
|
|
|
$gateway = $this->getDatabaseGateway(); |
715
|
|
|
$res = $gateway->listVersionsForUser(14); |
716
|
|
|
|
717
|
|
|
$this->assertEquals( |
718
|
|
|
2, |
719
|
|
|
count($res) |
720
|
|
|
); |
721
|
|
|
|
722
|
|
|
foreach ($res as $row) { |
723
|
|
|
$this->assertEquals( |
724
|
|
|
22, |
725
|
|
|
count($row) |
726
|
|
|
); |
727
|
|
|
} |
728
|
|
|
|
729
|
|
|
$this->assertEquals( |
730
|
|
|
677, |
731
|
|
|
$res[0]['ezcontentobject_version_id'] |
732
|
|
|
); |
733
|
|
|
$this->assertEquals( |
734
|
|
|
0, |
735
|
|
|
$res[0]['ezcontentobject_version_status'] |
736
|
|
|
); |
737
|
|
|
$this->assertEquals( |
738
|
|
|
678, |
739
|
|
|
$res[1]['ezcontentobject_version_id'] |
740
|
|
|
); |
741
|
|
|
$this->assertEquals( |
742
|
|
|
0, |
743
|
|
|
$res[1]['ezcontentobject_version_status'] |
744
|
|
|
); |
745
|
|
|
} |
746
|
|
|
|
747
|
|
|
/** |
748
|
|
|
* @covers eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase::load |
749
|
|
|
* @covers eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase\QueryBuilder |
750
|
|
|
*/ |
751
|
|
|
public function testLoadWithAllTranslations() |
752
|
|
|
{ |
753
|
|
|
$this->insertDatabaseFixture( |
754
|
|
|
__DIR__ . '/../_fixtures/contentobjects.php' |
755
|
|
|
); |
756
|
|
|
|
757
|
|
|
$gateway = $this->getDatabaseGateway(); |
758
|
|
|
$res = $gateway->load(226, 2); |
759
|
|
|
|
760
|
|
|
$this->assertValuesInRows( |
761
|
|
|
'ezcontentobject_attribute_language_code', |
762
|
|
|
array('eng-US', 'eng-GB'), |
763
|
|
|
$res |
764
|
|
|
); |
765
|
|
|
|
766
|
|
|
$this->assertValuesInRows( |
767
|
|
|
'ezcontentobject_attribute_language_id', |
768
|
|
|
array('2', '4'), |
769
|
|
|
$res |
770
|
|
|
); |
771
|
|
|
} |
772
|
|
|
|
773
|
|
|
/** |
774
|
|
|
* @covers eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase::load |
775
|
|
|
* @covers eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase\QueryBuilder |
776
|
|
|
*/ |
777
|
|
View Code Duplication |
public function testCreateFixtureForMapperExtractContentFromRowsMultipleVersions() |
778
|
|
|
{ |
779
|
|
|
$this->insertDatabaseFixture( |
780
|
|
|
__DIR__ . '/../_fixtures/contentobjects.php' |
781
|
|
|
); |
782
|
|
|
|
783
|
|
|
$gateway = $this->getDatabaseGateway(); |
784
|
|
|
|
785
|
|
|
$resFirst = $gateway->load(11, 1); |
786
|
|
|
$resSecond = $gateway->load(11, 2); |
787
|
|
|
|
788
|
|
|
$res = array_merge($resFirst, $resSecond); |
789
|
|
|
|
790
|
|
|
$orig = include __DIR__ . '/../_fixtures/extract_content_from_rows_multiple_versions.php'; |
791
|
|
|
|
792
|
|
|
/*$this->storeFixture( |
793
|
|
|
__DIR__ . '/../_fixtures/extract_content_from_rows_multiple_versions.php', |
794
|
|
|
$res |
795
|
|
|
);*/ |
796
|
|
|
|
797
|
|
|
$this->assertEquals($orig, $res, 'Fixtures differ between what was previously stored(expected) and what it now generates(actual), this hints either some mistake in impl or that the fixture (../_fixtures/extract_content_from_rows_multiple_versions.php) and tests needs to be adapted.'); |
798
|
|
|
} |
799
|
|
|
|
800
|
|
|
/** |
801
|
|
|
* @covers eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase::load |
802
|
|
|
* @covers eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase\QueryBuilder |
803
|
|
|
*/ |
804
|
|
|
public function testCreateFixtureForMapperExtractContentFromRows() |
805
|
|
|
{ |
806
|
|
|
$this->insertDatabaseFixture( |
807
|
|
|
__DIR__ . '/../_fixtures/contentobjects.php' |
808
|
|
|
); |
809
|
|
|
|
810
|
|
|
$gateway = $this->getDatabaseGateway(); |
811
|
|
|
|
812
|
|
|
$res = $gateway->load(226, 2); |
813
|
|
|
|
814
|
|
|
$res = array_merge($res); |
815
|
|
|
|
816
|
|
|
$orig = include __DIR__ . '/../_fixtures/extract_content_from_rows.php'; |
817
|
|
|
|
818
|
|
|
/*$this->storeFixture( |
819
|
|
|
__DIR__ . '/../_fixtures/extract_content_from_rows.php', |
820
|
|
|
$res |
821
|
|
|
);*/ |
822
|
|
|
|
823
|
|
|
$this->assertEquals($orig, $res, 'Fixtures differ between what was previously stored(expected) and what it now generates(actual), this hints either some mistake in impl or that the fixture (../_fixtures/extract_content_from_rows.php) and tests needs to be adapted.'); |
824
|
|
|
} |
825
|
|
|
|
826
|
|
|
/** |
827
|
|
|
* @covers eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase::load |
828
|
|
|
* @covers eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase\QueryBuilder |
829
|
|
|
*/ |
830
|
|
View Code Duplication |
public function testLoadWithSingleTranslation() |
831
|
|
|
{ |
832
|
|
|
$this->insertDatabaseFixture( |
833
|
|
|
__DIR__ . '/../_fixtures/contentobjects.php' |
834
|
|
|
); |
835
|
|
|
|
836
|
|
|
$gateway = $this->getDatabaseGateway(); |
837
|
|
|
$res = $gateway->load(226, 2, array('eng-GB')); |
838
|
|
|
|
839
|
|
|
$this->assertValuesInRows( |
840
|
|
|
'ezcontentobject_attribute_language_code', |
841
|
|
|
array('eng-GB'), |
842
|
|
|
$res |
843
|
|
|
); |
844
|
|
|
$this->assertValuesInRows( |
845
|
|
|
'ezcontentobject_attribute_language_id', |
846
|
|
|
array('4'), |
847
|
|
|
$res |
848
|
|
|
); |
849
|
|
|
$this->assertEquals( |
850
|
|
|
1, |
851
|
|
|
count($res) |
852
|
|
|
); |
853
|
|
|
} |
854
|
|
|
|
855
|
|
|
/** |
856
|
|
|
* @covers eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase::load |
857
|
|
|
* @covers eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase\QueryBuilder |
858
|
|
|
*/ |
859
|
|
View Code Duplication |
public function testLoadNonExistentTranslation() |
860
|
|
|
{ |
861
|
|
|
$this->insertDatabaseFixture( |
862
|
|
|
__DIR__ . '/../_fixtures/contentobjects.php' |
863
|
|
|
); |
864
|
|
|
|
865
|
|
|
$gateway = $this->getDatabaseGateway(); |
866
|
|
|
$res = $gateway->load(226, 2, array('de-DE')); |
867
|
|
|
|
868
|
|
|
$this->assertEquals( |
869
|
|
|
0, |
870
|
|
|
count($res) |
871
|
|
|
); |
872
|
|
|
} |
873
|
|
|
|
874
|
|
|
/** |
875
|
|
|
* Asserts that $columnKey in $actualRows exactly contains $expectedValues. |
876
|
|
|
* |
877
|
|
|
* @param string $columnKey |
878
|
|
|
* @param string[] $expectedValues |
879
|
|
|
* @param string[][] $actualRows |
880
|
|
|
*/ |
881
|
|
|
protected function assertValuesInRows($columnKey, array $expectedValues, array $actualRows) |
882
|
|
|
{ |
883
|
|
|
$expectedValues = array_fill_keys( |
884
|
|
|
array_values($expectedValues), |
885
|
|
|
true |
886
|
|
|
); |
887
|
|
|
|
888
|
|
|
$containedValues = array(); |
889
|
|
|
|
890
|
|
|
foreach ($actualRows as $row) { |
891
|
|
|
if (isset($row[$columnKey])) { |
892
|
|
|
$containedValues[$row[$columnKey]] = true; |
893
|
|
|
} |
894
|
|
|
} |
895
|
|
|
|
896
|
|
|
$this->assertEquals( |
897
|
|
|
$expectedValues, |
898
|
|
|
$containedValues |
899
|
|
|
); |
900
|
|
|
} |
901
|
|
|
|
902
|
|
|
/** |
903
|
|
|
* @covers eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase::getAllLocationIds |
904
|
|
|
*/ |
905
|
|
|
public function testGetAllLocationIds() |
906
|
|
|
{ |
907
|
|
|
$this->insertDatabaseFixture( |
908
|
|
|
__DIR__ . '/../_fixtures/contentobjects.php' |
909
|
|
|
); |
910
|
|
|
|
911
|
|
|
$gateway = $this->getDatabaseGateway(); |
912
|
|
|
|
913
|
|
|
$this->assertEquals( |
914
|
|
|
array(228), |
915
|
|
|
$gateway->getAllLocationIds(226) |
916
|
|
|
); |
917
|
|
|
} |
918
|
|
|
|
919
|
|
|
/** |
920
|
|
|
* @covers eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase::getFieldIdsByType |
921
|
|
|
*/ |
922
|
|
|
public function testGetFieldIdsByType() |
923
|
|
|
{ |
924
|
|
|
$this->insertDatabaseFixture( |
925
|
|
|
__DIR__ . '/../_fixtures/contentobjects.php' |
926
|
|
|
); |
927
|
|
|
|
928
|
|
|
$gateway = $this->getDatabaseGateway(); |
929
|
|
|
|
930
|
|
|
$this->assertEquals( |
931
|
|
|
array( |
932
|
|
|
'ezstring' => array(841), |
933
|
|
|
'ezrichtext' => array(842), |
934
|
|
|
'ezimage' => array(843), |
935
|
|
|
'ezkeyword' => array(844), |
936
|
|
|
), |
937
|
|
|
$gateway->getFieldIdsByType(149) |
938
|
|
|
); |
939
|
|
|
} |
940
|
|
|
|
941
|
|
|
/** |
942
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase::getFieldIdsByType |
943
|
|
|
*/ |
944
|
|
|
public function testGetFieldIdsByTypeWithSecondArgument() |
945
|
|
|
{ |
946
|
|
|
$this->insertDatabaseFixture( |
947
|
|
|
__DIR__ . '/../_fixtures/contentobjects.php' |
948
|
|
|
); |
949
|
|
|
|
950
|
|
|
$gateway = $this->getDatabaseGateway(); |
951
|
|
|
|
952
|
|
|
$this->assertEquals( |
953
|
|
|
array( |
954
|
|
|
'ezstring' => array(4001, 4002), |
955
|
|
|
), |
956
|
|
|
$gateway->getFieldIdsByType(225, 2) |
957
|
|
|
); |
958
|
|
|
} |
959
|
|
|
|
960
|
|
|
/** |
961
|
|
|
* @covers eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase::deleteRelations |
962
|
|
|
*/ |
963
|
|
View Code Duplication |
public function testDeleteRelationsTo() |
964
|
|
|
{ |
965
|
|
|
$this->insertDatabaseFixture( |
966
|
|
|
__DIR__ . '/../_fixtures/contentobjects.php' |
967
|
|
|
); |
968
|
|
|
|
969
|
|
|
$beforeCount = array( |
970
|
|
|
'all' => $this->countContentRelations(), |
971
|
|
|
'from' => $this->countContentRelations(149), |
972
|
|
|
'to' => $this->countContentRelations(null, 149), |
973
|
|
|
); |
974
|
|
|
|
975
|
|
|
$gateway = $this->getDatabaseGateway(); |
976
|
|
|
$gateway->deleteRelations(149); |
977
|
|
|
|
978
|
|
|
$this->assertEquals( |
979
|
|
|
// yes, relates to itself! |
980
|
|
|
array( |
981
|
|
|
'all' => $beforeCount['all'] - 2, |
982
|
|
|
'from' => $beforeCount['from'] - 1, |
983
|
|
|
'to' => $beforeCount['to'] - 2, |
984
|
|
|
), |
985
|
|
|
array( |
986
|
|
|
'all' => $this->countContentRelations(), |
987
|
|
|
'from' => $this->countContentRelations(149), |
988
|
|
|
'to' => $this->countContentRelations(null, 149), |
989
|
|
|
) |
990
|
|
|
); |
991
|
|
|
} |
992
|
|
|
|
993
|
|
|
/** |
994
|
|
|
* @covers eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase::deleteRelations |
995
|
|
|
*/ |
996
|
|
View Code Duplication |
public function testDeleteRelationsFrom() |
997
|
|
|
{ |
998
|
|
|
$this->insertDatabaseFixture( |
999
|
|
|
__DIR__ . '/../_fixtures/contentobjects.php' |
1000
|
|
|
); |
1001
|
|
|
|
1002
|
|
|
$beforeCount = array( |
1003
|
|
|
'all' => $this->countContentRelations(), |
1004
|
|
|
'from' => $this->countContentRelations(75), |
1005
|
|
|
'to' => $this->countContentRelations(null, 75), |
1006
|
|
|
); |
1007
|
|
|
|
1008
|
|
|
$gateway = $this->getDatabaseGateway(); |
1009
|
|
|
$gateway->deleteRelations(75); |
1010
|
|
|
|
1011
|
|
|
$this->assertEquals( |
1012
|
|
|
array( |
1013
|
|
|
'all' => $beforeCount['all'] - 6, |
1014
|
|
|
'from' => $beforeCount['from'] - 6, |
1015
|
|
|
'to' => $beforeCount['to'], |
1016
|
|
|
), |
1017
|
|
|
array( |
1018
|
|
|
'all' => $this->countContentRelations(), |
1019
|
|
|
'from' => $this->countContentRelations(75), |
1020
|
|
|
'to' => $this->countContentRelations(null, 75), |
1021
|
|
|
) |
1022
|
|
|
); |
1023
|
|
|
} |
1024
|
|
|
|
1025
|
|
|
/** |
1026
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase::deleteRelations |
1027
|
|
|
*/ |
1028
|
|
View Code Duplication |
public function testDeleteRelationsWithSecondArgument() |
1029
|
|
|
{ |
1030
|
|
|
$this->insertDatabaseFixture( |
1031
|
|
|
__DIR__ . '/../_fixtures/contentobjects.php' |
1032
|
|
|
); |
1033
|
|
|
|
1034
|
|
|
$beforeCount = array( |
1035
|
|
|
'all' => $this->countContentRelations(), |
1036
|
|
|
'from' => $this->countContentRelations(225), |
1037
|
|
|
'to' => $this->countContentRelations(null, 225), |
1038
|
|
|
); |
1039
|
|
|
|
1040
|
|
|
$gateway = $this->getDatabaseGateway(); |
1041
|
|
|
$gateway->deleteRelations(225, 2); |
1042
|
|
|
|
1043
|
|
|
$this->assertEquals( |
1044
|
|
|
array( |
1045
|
|
|
'all' => $beforeCount['all'] - 1, |
1046
|
|
|
'from' => $beforeCount['from'] - 1, |
1047
|
|
|
'to' => $beforeCount['to'], |
1048
|
|
|
), |
1049
|
|
|
array( |
1050
|
|
|
'all' => $this->countContentRelations(), |
1051
|
|
|
'from' => $this->countContentRelations(225), |
1052
|
|
|
'to' => $this->countContentRelations(null, 225), |
1053
|
|
|
) |
1054
|
|
|
); |
1055
|
|
|
} |
1056
|
|
|
|
1057
|
|
|
/** |
1058
|
|
|
* @covers eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase::deleteField |
1059
|
|
|
*/ |
1060
|
|
|
public function testDeleteField() |
1061
|
|
|
{ |
1062
|
|
|
$this->insertDatabaseFixture( |
1063
|
|
|
__DIR__ . '/../_fixtures/contentobjects.php' |
1064
|
|
|
); |
1065
|
|
|
|
1066
|
|
|
$beforeCount = $this->countContentFields(); |
1067
|
|
|
|
1068
|
|
|
$gateway = $this->getDatabaseGateway(); |
1069
|
|
|
$gateway->deleteField(22); |
1070
|
|
|
|
1071
|
|
|
$this->assertEquals( |
1072
|
|
|
$beforeCount - 2, |
1073
|
|
|
$this->countContentFields() |
1074
|
|
|
); |
1075
|
|
|
|
1076
|
|
|
$this->assertQueryResult( |
1077
|
|
|
array(), |
1078
|
|
|
$this->getDatabaseHandler()->createSelectQuery() |
1079
|
|
|
->select('*') |
1080
|
|
|
->from('ezcontentobject_attribute') |
1081
|
|
|
->where('id=22') |
1082
|
|
|
); |
1083
|
|
|
} |
1084
|
|
|
|
1085
|
|
|
/** |
1086
|
|
|
* @covers eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase::deleteFields |
1087
|
|
|
*/ |
1088
|
|
View Code Duplication |
public function testDeleteFields() |
1089
|
|
|
{ |
1090
|
|
|
$this->insertDatabaseFixture( |
1091
|
|
|
__DIR__ . '/../_fixtures/contentobjects.php' |
1092
|
|
|
); |
1093
|
|
|
|
1094
|
|
|
$beforeCount = array( |
1095
|
|
|
'all' => $this->countContentFields(), |
1096
|
|
|
'this' => $this->countContentFields(4), |
1097
|
|
|
); |
1098
|
|
|
|
1099
|
|
|
$gateway = $this->getDatabaseGateway(); |
1100
|
|
|
$gateway->deleteFields(4); |
1101
|
|
|
|
1102
|
|
|
$this->assertEquals( |
1103
|
|
|
array( |
1104
|
|
|
'all' => $beforeCount['all'] - 2, |
1105
|
|
|
'this' => 0, |
1106
|
|
|
), |
1107
|
|
|
array( |
1108
|
|
|
'all' => $this->countContentFields(), |
1109
|
|
|
'this' => $this->countContentFields(4), |
1110
|
|
|
) |
1111
|
|
|
); |
1112
|
|
|
} |
1113
|
|
|
|
1114
|
|
|
/** |
1115
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase::deleteFields |
1116
|
|
|
*/ |
1117
|
|
View Code Duplication |
public function testDeleteFieldsWithSecondArgument() |
1118
|
|
|
{ |
1119
|
|
|
$this->insertDatabaseFixture( |
1120
|
|
|
__DIR__ . '/../_fixtures/contentobjects.php' |
1121
|
|
|
); |
1122
|
|
|
|
1123
|
|
|
$beforeCount = array( |
1124
|
|
|
'all' => $this->countContentFields(), |
1125
|
|
|
'this' => $this->countContentFields(225), |
1126
|
|
|
); |
1127
|
|
|
|
1128
|
|
|
$gateway = $this->getDatabaseGateway(); |
1129
|
|
|
$gateway->deleteFields(225, 2); |
1130
|
|
|
|
1131
|
|
|
$this->assertEquals( |
1132
|
|
|
array( |
1133
|
|
|
'all' => $beforeCount['all'] - 2, |
1134
|
|
|
'this' => $beforeCount['this'] - 2, |
1135
|
|
|
), |
1136
|
|
|
array( |
1137
|
|
|
'all' => $this->countContentFields(), |
1138
|
|
|
'this' => $this->countContentFields(225), |
1139
|
|
|
) |
1140
|
|
|
); |
1141
|
|
|
} |
1142
|
|
|
|
1143
|
|
|
/** |
1144
|
|
|
* @covers eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase::deleteVersions |
1145
|
|
|
*/ |
1146
|
|
View Code Duplication |
public function testDeleteVersions() |
1147
|
|
|
{ |
1148
|
|
|
$this->insertDatabaseFixture( |
1149
|
|
|
__DIR__ . '/../_fixtures/contentobjects.php' |
1150
|
|
|
); |
1151
|
|
|
|
1152
|
|
|
$beforeCount = array( |
1153
|
|
|
'all' => $this->countContentVersions(), |
1154
|
|
|
'this' => $this->countContentVersions(14), |
1155
|
|
|
); |
1156
|
|
|
|
1157
|
|
|
$gateway = $this->getDatabaseGateway(); |
1158
|
|
|
$gateway->deleteVersions(14); |
1159
|
|
|
|
1160
|
|
|
$this->assertEquals( |
1161
|
|
|
array( |
1162
|
|
|
'all' => $beforeCount['all'] - 2, |
1163
|
|
|
'this' => 0, |
1164
|
|
|
), |
1165
|
|
|
array( |
1166
|
|
|
'all' => $this->countContentVersions(), |
1167
|
|
|
'this' => $this->countContentVersions(14), |
1168
|
|
|
) |
1169
|
|
|
); |
1170
|
|
|
} |
1171
|
|
|
|
1172
|
|
|
/** |
1173
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase::deleteVersions |
1174
|
|
|
*/ |
1175
|
|
View Code Duplication |
public function testDeleteVersionsWithSecondArgument() |
1176
|
|
|
{ |
1177
|
|
|
$this->insertDatabaseFixture( |
1178
|
|
|
__DIR__ . '/../_fixtures/contentobjects.php' |
1179
|
|
|
); |
1180
|
|
|
|
1181
|
|
|
$beforeCount = array( |
1182
|
|
|
'all' => $this->countContentVersions(), |
1183
|
|
|
'this' => $this->countContentVersions(225), |
1184
|
|
|
); |
1185
|
|
|
|
1186
|
|
|
$gateway = $this->getDatabaseGateway(); |
1187
|
|
|
$gateway->deleteVersions(225, 2); |
1188
|
|
|
|
1189
|
|
|
$this->assertEquals( |
1190
|
|
|
array( |
1191
|
|
|
'all' => $beforeCount['all'] - 1, |
1192
|
|
|
'this' => $beforeCount['this'] - 1, |
1193
|
|
|
), |
1194
|
|
|
array( |
1195
|
|
|
'all' => $this->countContentVersions(), |
1196
|
|
|
'this' => $this->countContentVersions(225), |
1197
|
|
|
) |
1198
|
|
|
); |
1199
|
|
|
} |
1200
|
|
|
|
1201
|
|
|
/** |
1202
|
|
|
* @covers eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase::setName |
1203
|
|
|
*/ |
1204
|
|
|
public function testSetName() |
1205
|
|
|
{ |
1206
|
|
|
$beforeCount = array( |
|
|
|
|
1207
|
|
|
'all' => $this->countContentNames(), |
1208
|
|
|
'this' => $this->countContentNames(14), |
1209
|
|
|
); |
1210
|
|
|
|
1211
|
|
|
$gateway = $this->getDatabaseGateway(); |
1212
|
|
|
|
1213
|
|
|
$gateway->setName(14, 2, 'Hello world!', 'eng-GB'); |
1214
|
|
|
|
1215
|
|
|
$this->assertQueryResult( |
1216
|
|
|
array(array('eng-GB', 2, 14, 4, 'Hello world!', 'eng-GB')), |
1217
|
|
|
$this->getDatabaseHandler() |
1218
|
|
|
->createSelectQuery() |
1219
|
|
|
->select('*') |
1220
|
|
|
->from('ezcontentobject_name') |
1221
|
|
|
); |
1222
|
|
|
} |
1223
|
|
|
|
1224
|
|
|
/** |
1225
|
|
|
* @covers eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase::deleteNames |
1226
|
|
|
*/ |
1227
|
|
View Code Duplication |
public function testDeleteNames() |
1228
|
|
|
{ |
1229
|
|
|
$this->insertDatabaseFixture( |
1230
|
|
|
__DIR__ . '/../_fixtures/contentobjects.php' |
1231
|
|
|
); |
1232
|
|
|
|
1233
|
|
|
$beforeCount = array( |
1234
|
|
|
'all' => $this->countContentNames(), |
1235
|
|
|
'this' => $this->countContentNames(14), |
1236
|
|
|
); |
1237
|
|
|
|
1238
|
|
|
$gateway = $this->getDatabaseGateway(); |
1239
|
|
|
$gateway->deleteNames(14); |
1240
|
|
|
|
1241
|
|
|
$this->assertEquals( |
1242
|
|
|
array( |
1243
|
|
|
'all' => $beforeCount['all'] - 2, |
1244
|
|
|
'this' => 0, |
1245
|
|
|
), |
1246
|
|
|
array( |
1247
|
|
|
'all' => $this->countContentNames(), |
1248
|
|
|
'this' => $this->countContentNames(14), |
1249
|
|
|
) |
1250
|
|
|
); |
1251
|
|
|
} |
1252
|
|
|
|
1253
|
|
|
/** |
1254
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase::deleteNames |
1255
|
|
|
*/ |
1256
|
|
View Code Duplication |
public function testDeleteNamesWithSecondArgument() |
1257
|
|
|
{ |
1258
|
|
|
$this->insertDatabaseFixture( |
1259
|
|
|
__DIR__ . '/../_fixtures/contentobjects.php' |
1260
|
|
|
); |
1261
|
|
|
|
1262
|
|
|
$beforeCount = array( |
1263
|
|
|
'all' => $this->countContentNames(), |
1264
|
|
|
'this' => $this->countContentNames(225), |
1265
|
|
|
); |
1266
|
|
|
|
1267
|
|
|
$gateway = $this->getDatabaseGateway(); |
1268
|
|
|
$gateway->deleteNames(225, 2); |
1269
|
|
|
|
1270
|
|
|
$this->assertEquals( |
1271
|
|
|
array( |
1272
|
|
|
'all' => $beforeCount['all'] - 1, |
1273
|
|
|
'this' => $beforeCount['this'] - 1, |
1274
|
|
|
), |
1275
|
|
|
array( |
1276
|
|
|
'all' => $this->countContentNames(), |
1277
|
|
|
'this' => $this->countContentNames(225), |
1278
|
|
|
) |
1279
|
|
|
); |
1280
|
|
|
} |
1281
|
|
|
|
1282
|
|
|
/** |
1283
|
|
|
* @covers eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase::deleteContent |
1284
|
|
|
*/ |
1285
|
|
|
public function testDeleteContent() |
1286
|
|
|
{ |
1287
|
|
|
$this->insertDatabaseFixture( |
1288
|
|
|
__DIR__ . '/../_fixtures/contentobjects.php' |
1289
|
|
|
); |
1290
|
|
|
|
1291
|
|
|
$beforeCount = $this->countContent(); |
1292
|
|
|
|
1293
|
|
|
$gateway = $this->getDatabaseGateway(); |
1294
|
|
|
$gateway->deleteContent(14); |
1295
|
|
|
|
1296
|
|
|
$this->assertEquals( |
1297
|
|
|
array( |
1298
|
|
|
'all' => $beforeCount - 1, |
1299
|
|
|
'this' => 0, |
1300
|
|
|
), |
1301
|
|
|
array( |
1302
|
|
|
'all' => $this->countContent(), |
1303
|
|
|
'this' => $this->countContent(14), |
1304
|
|
|
) |
1305
|
|
|
); |
1306
|
|
|
} |
1307
|
|
|
|
1308
|
|
|
/** |
1309
|
|
|
* @covers eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase::loadRelations |
1310
|
|
|
*/ |
1311
|
|
View Code Duplication |
public function testLoadRelations() |
1312
|
|
|
{ |
1313
|
|
|
$this->insertRelationFixture(); |
1314
|
|
|
|
1315
|
|
|
$gateway = $this->getDatabaseGateway(); |
1316
|
|
|
|
1317
|
|
|
$relations = $gateway->loadRelations(57); |
1318
|
|
|
|
1319
|
|
|
$this->assertEquals(3, count($relations)); |
1320
|
|
|
|
1321
|
|
|
$this->assertValuesInRows( |
1322
|
|
|
'ezcontentobject_link_to_contentobject_id', |
1323
|
|
|
array(58, 59, 60), |
1324
|
|
|
$relations |
1325
|
|
|
); |
1326
|
|
|
|
1327
|
|
|
$this->assertValuesInRows( |
1328
|
|
|
'ezcontentobject_link_from_contentobject_id', |
1329
|
|
|
array(57), |
1330
|
|
|
$relations |
1331
|
|
|
); |
1332
|
|
|
$this->assertValuesInRows( |
1333
|
|
|
'ezcontentobject_link_from_contentobject_version', |
1334
|
|
|
array(2), |
1335
|
|
|
$relations |
1336
|
|
|
); |
1337
|
|
|
} |
1338
|
|
|
|
1339
|
|
|
/** |
1340
|
|
|
* @covers eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase::loadRelations |
1341
|
|
|
*/ |
1342
|
|
View Code Duplication |
public function testLoadRelationsByType() |
1343
|
|
|
{ |
1344
|
|
|
$this->insertRelationFixture(); |
1345
|
|
|
|
1346
|
|
|
$gateway = $this->getDatabaseGateway(); |
1347
|
|
|
|
1348
|
|
|
$relations = $gateway->loadRelations(57, null, \eZ\Publish\API\Repository\Values\Content\Relation::COMMON); |
1349
|
|
|
|
1350
|
|
|
$this->assertEquals(1, count($relations), 'Expecting one relation to be loaded'); |
1351
|
|
|
|
1352
|
|
|
$this->assertValuesInRows( |
1353
|
|
|
'ezcontentobject_link_relation_type', |
1354
|
|
|
array(\eZ\Publish\API\Repository\Values\Content\Relation::COMMON), |
1355
|
|
|
$relations |
1356
|
|
|
); |
1357
|
|
|
|
1358
|
|
|
$this->assertValuesInRows( |
1359
|
|
|
'ezcontentobject_link_to_contentobject_id', |
1360
|
|
|
array(58), |
1361
|
|
|
$relations |
1362
|
|
|
); |
1363
|
|
|
} |
1364
|
|
|
|
1365
|
|
|
/** |
1366
|
|
|
* @covers eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase::loadRelations |
1367
|
|
|
*/ |
1368
|
|
|
public function testLoadRelationsByVersion() |
1369
|
|
|
{ |
1370
|
|
|
$this->insertRelationFixture(); |
1371
|
|
|
|
1372
|
|
|
$gateway = $this->getDatabaseGateway(); |
1373
|
|
|
|
1374
|
|
|
$relations = $gateway->loadRelations(57, 1); |
1375
|
|
|
|
1376
|
|
|
$this->assertEquals(1, count($relations), 'Expecting one relation to be loaded'); |
1377
|
|
|
|
1378
|
|
|
$this->assertValuesInRows( |
1379
|
|
|
'ezcontentobject_link_to_contentobject_id', |
1380
|
|
|
array(58), |
1381
|
|
|
$relations |
1382
|
|
|
); |
1383
|
|
|
} |
1384
|
|
|
|
1385
|
|
|
/** |
1386
|
|
|
* @covers eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase::loadRelations |
1387
|
|
|
*/ |
1388
|
|
View Code Duplication |
public function testLoadRelationsNoResult() |
1389
|
|
|
{ |
1390
|
|
|
$this->insertRelationFixture(); |
1391
|
|
|
|
1392
|
|
|
$gateway = $this->getDatabaseGateway(); |
1393
|
|
|
|
1394
|
|
|
$relations = $gateway->loadRelations(57, 1, \eZ\Publish\API\Repository\Values\Content\Relation::EMBED); |
1395
|
|
|
|
1396
|
|
|
$this->assertEquals(0, count($relations), 'Expecting no relation to be loaded'); |
1397
|
|
|
} |
1398
|
|
|
|
1399
|
|
|
/** |
1400
|
|
|
* @covers eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase::loadReverseRelations |
1401
|
|
|
*/ |
1402
|
|
View Code Duplication |
public function testLoadReverseRelations() |
1403
|
|
|
{ |
1404
|
|
|
$this->insertRelationFixture(); |
1405
|
|
|
|
1406
|
|
|
$gateway = $this->getDatabaseGateway(); |
1407
|
|
|
|
1408
|
|
|
$relations = $gateway->loadReverseRelations(58); |
1409
|
|
|
|
1410
|
|
|
self::assertEquals(2, count($relations)); |
1411
|
|
|
|
1412
|
|
|
$this->assertValuesInRows( |
1413
|
|
|
'ezcontentobject_link_from_contentobject_id', |
1414
|
|
|
array(57, 61), |
1415
|
|
|
$relations |
1416
|
|
|
); |
1417
|
|
|
} |
1418
|
|
|
|
1419
|
|
|
/** |
1420
|
|
|
* @covers eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase::loadReverseRelations |
1421
|
|
|
*/ |
1422
|
|
View Code Duplication |
public function testLoadReverseRelationsWithType() |
1423
|
|
|
{ |
1424
|
|
|
$this->insertRelationFixture(); |
1425
|
|
|
|
1426
|
|
|
$gateway = $this->getDatabaseGateway(); |
1427
|
|
|
|
1428
|
|
|
$relations = $gateway->loadReverseRelations(58, \eZ\Publish\API\Repository\Values\Content\Relation::COMMON); |
1429
|
|
|
|
1430
|
|
|
self::assertEquals(1, count($relations)); |
1431
|
|
|
|
1432
|
|
|
$this->assertValuesInRows( |
1433
|
|
|
'ezcontentobject_link_from_contentobject_id', |
1434
|
|
|
array(57), |
1435
|
|
|
$relations |
1436
|
|
|
); |
1437
|
|
|
|
1438
|
|
|
$this->assertValuesInRows( |
1439
|
|
|
'ezcontentobject_link_relation_type', |
1440
|
|
|
array(\eZ\Publish\API\Repository\Values\Content\Relation::COMMON), |
1441
|
|
|
$relations |
1442
|
|
|
); |
1443
|
|
|
} |
1444
|
|
|
|
1445
|
|
|
/** |
1446
|
|
|
* Inserts the relation database fixture from relation_data.php. |
1447
|
|
|
*/ |
1448
|
|
|
protected function insertRelationFixture() |
1449
|
|
|
{ |
1450
|
|
|
$this->insertDatabaseFixture( |
1451
|
|
|
__DIR__ . '/../_fixtures/relations_data.php' |
1452
|
|
|
); |
1453
|
|
|
} |
1454
|
|
|
|
1455
|
|
|
/* |
1456
|
|
|
* @covers eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase::getLastVersionNumber |
1457
|
|
|
* |
1458
|
|
|
* @return void |
1459
|
|
|
*/ |
1460
|
|
|
public function testGetLastVersionNumber() |
1461
|
|
|
{ |
1462
|
|
|
$this->insertDatabaseFixture( |
1463
|
|
|
__DIR__ . '/../_fixtures/contentobjects.php' |
1464
|
|
|
); |
1465
|
|
|
|
1466
|
|
|
$gateway = $this->getDatabaseGateway(); |
1467
|
|
|
|
1468
|
|
|
$this->assertEquals( |
1469
|
|
|
1, |
1470
|
|
|
$gateway->getLastVersionNumber(4) |
1471
|
|
|
); |
1472
|
|
|
} |
1473
|
|
|
|
1474
|
|
|
/** |
1475
|
|
|
* @covers eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase::insertRelation |
1476
|
|
|
*/ |
1477
|
|
|
public function testInsertRelation() |
1478
|
|
|
{ |
1479
|
|
|
$struct = $this->getRelationCreateStructFixture(); |
1480
|
|
|
$gateway = $this->getDatabaseGateway(); |
1481
|
|
|
$gateway->insertRelation($struct); |
1482
|
|
|
|
1483
|
|
|
$this->assertQueryResult( |
1484
|
|
|
array( |
1485
|
|
|
array( |
1486
|
|
|
'id' => 1, |
1487
|
|
|
'from_contentobject_id' => $struct->sourceContentId, |
1488
|
|
|
'from_contentobject_version' => $struct->sourceContentVersionNo, |
1489
|
|
|
'contentclassattribute_id' => $struct->sourceFieldDefinitionId, |
1490
|
|
|
'to_contentobject_id' => $struct->destinationContentId, |
1491
|
|
|
'relation_type' => $struct->type, |
1492
|
|
|
), |
1493
|
|
|
), |
1494
|
|
|
$this->getDatabaseHandler() |
1495
|
|
|
->createSelectQuery() |
1496
|
|
|
->select( |
1497
|
|
|
array( |
1498
|
|
|
'id', |
1499
|
|
|
'from_contentobject_id', |
1500
|
|
|
'from_contentobject_version', |
1501
|
|
|
'contentclassattribute_id', |
1502
|
|
|
'to_contentobject_id', |
1503
|
|
|
'relation_type', |
1504
|
|
|
) |
1505
|
|
|
)->from('ezcontentobject_link') |
1506
|
|
|
->where('id = 1') |
1507
|
|
|
); |
1508
|
|
|
} |
1509
|
|
|
|
1510
|
|
|
/** |
1511
|
|
|
* @covers eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase::deleteRelation |
1512
|
|
|
*/ |
1513
|
|
|
public function testDeleteRelation() |
1514
|
|
|
{ |
1515
|
|
|
$this->insertRelationFixture(); |
1516
|
|
|
|
1517
|
|
|
self::assertEquals(4, $this->countContentRelations(57)); |
1518
|
|
|
|
1519
|
|
|
$gateway = $this->getDatabaseGateway(); |
1520
|
|
|
$gateway->deleteRelation(2, RelationValue::COMMON); |
1521
|
|
|
|
1522
|
|
|
self::assertEquals(3, $this->countContentRelations(57)); |
1523
|
|
|
} |
1524
|
|
|
|
1525
|
|
|
/** |
1526
|
|
|
* @covers eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase::deleteRelation |
1527
|
|
|
*/ |
1528
|
|
|
public function testDeleteRelationWithCompositeBitmask() |
1529
|
|
|
{ |
1530
|
|
|
$this->insertRelationFixture(); |
1531
|
|
|
|
1532
|
|
|
$gateway = $this->getDatabaseGateway(); |
1533
|
|
|
$gateway->deleteRelation(11, RelationValue::COMMON); |
1534
|
|
|
|
1535
|
|
|
/** @var $query \eZ\Publish\Core\Persistence\Database\SelectQuery */ |
1536
|
|
|
$query = $this->getDatabaseHandler()->createSelectQuery(); |
1537
|
|
|
$this->assertQueryResult( |
1538
|
|
|
array(array('relation_type' => RelationValue::LINK)), |
1539
|
|
|
$query->select( |
1540
|
|
|
array('relation_type') |
1541
|
|
|
)->from( |
1542
|
|
|
'ezcontentobject_link' |
1543
|
|
|
)->where( |
1544
|
|
|
$query->expr->eq('id', 11) |
1545
|
|
|
) |
1546
|
|
|
); |
1547
|
|
|
} |
1548
|
|
|
|
1549
|
|
|
/** |
1550
|
|
|
* Test for the updateAlwaysAvailableFlag() method. |
1551
|
|
|
* |
1552
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase::updateAlwaysAvailableFlag |
1553
|
|
|
*/ |
1554
|
|
View Code Duplication |
public function testUpdateAlwaysAvailableFlagRemove() |
1555
|
|
|
{ |
1556
|
|
|
$this->insertDatabaseFixture( |
1557
|
|
|
__DIR__ . '/../_fixtures/contentobjects.php' |
1558
|
|
|
); |
1559
|
|
|
|
1560
|
|
|
$gateway = $this->getDatabaseGateway(); |
1561
|
|
|
$gateway->updateAlwaysAvailableFlag(103, false); |
1562
|
|
|
|
1563
|
|
|
$this->assertQueryResult( |
1564
|
|
|
array(array('id' => 2)), |
1565
|
|
|
$this->getDatabaseHandler()->createSelectQuery()->select( |
1566
|
|
|
array('language_mask') |
1567
|
|
|
)->from( |
1568
|
|
|
'ezcontentobject' |
1569
|
|
|
)->where( |
1570
|
|
|
'id = 103' |
1571
|
|
|
) |
1572
|
|
|
); |
1573
|
|
|
|
1574
|
|
|
$query = $this->getDatabaseHandler()->createSelectQuery(); |
1575
|
|
|
$this->assertQueryResult( |
1576
|
|
|
array(array('language_id' => 2)), |
1577
|
|
|
$query->select( |
1578
|
|
|
array('language_id') |
1579
|
|
|
)->from( |
1580
|
|
|
'ezcontentobject_name' |
1581
|
|
|
)->where( |
1582
|
|
|
$query->expr->lAnd( |
1583
|
|
|
$query->expr->eq('contentobject_id', 103), |
1584
|
|
|
$query->expr->eq('content_version', 1) |
1585
|
|
|
) |
1586
|
|
|
) |
1587
|
|
|
); |
1588
|
|
|
|
1589
|
|
|
$query = $this->getDatabaseHandler()->createSelectQuery(); |
1590
|
|
|
$this->assertQueryResult( |
1591
|
|
|
array( |
1592
|
|
|
array('language_id' => 2), |
1593
|
|
|
), |
1594
|
|
|
$query->selectDistinct( |
1595
|
|
|
array('language_id') |
1596
|
|
|
)->from( |
1597
|
|
|
'ezcontentobject_attribute' |
1598
|
|
|
)->where( |
1599
|
|
|
$query->expr->lAnd( |
1600
|
|
|
$query->expr->eq('contentobject_id', 103), |
1601
|
|
|
$query->expr->eq('version', 1) |
1602
|
|
|
) |
1603
|
|
|
) |
1604
|
|
|
); |
1605
|
|
|
} |
1606
|
|
|
|
1607
|
|
|
/** |
1608
|
|
|
* Test for the updateAlwaysAvailableFlag() method. |
1609
|
|
|
* |
1610
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase::updateAlwaysAvailableFlag |
1611
|
|
|
*/ |
1612
|
|
View Code Duplication |
public function testUpdateAlwaysAvailableFlagAdd() |
1613
|
|
|
{ |
1614
|
|
|
$this->insertDatabaseFixture( |
1615
|
|
|
__DIR__ . '/../_fixtures/contentobjects.php' |
1616
|
|
|
); |
1617
|
|
|
|
1618
|
|
|
$gateway = $this->getDatabaseGateway(); |
1619
|
|
|
$gateway->updateAlwaysAvailableFlag(102, true); |
1620
|
|
|
|
1621
|
|
|
$this->assertQueryResult( |
1622
|
|
|
array(array('id' => 3)), |
1623
|
|
|
$this->getDatabaseHandler()->createSelectQuery()->select( |
1624
|
|
|
array('language_mask') |
1625
|
|
|
)->from( |
1626
|
|
|
'ezcontentobject' |
1627
|
|
|
)->where( |
1628
|
|
|
'id = 102' |
1629
|
|
|
) |
1630
|
|
|
); |
1631
|
|
|
|
1632
|
|
|
$query = $this->getDatabaseHandler()->createSelectQuery(); |
1633
|
|
|
$this->assertQueryResult( |
1634
|
|
|
array(array('language_id' => 3)), |
1635
|
|
|
$query->select( |
1636
|
|
|
array('language_id') |
1637
|
|
|
)->from( |
1638
|
|
|
'ezcontentobject_name' |
1639
|
|
|
)->where( |
1640
|
|
|
$query->expr->lAnd( |
1641
|
|
|
$query->expr->eq('contentobject_id', 102), |
1642
|
|
|
$query->expr->eq('content_version', 1) |
1643
|
|
|
) |
1644
|
|
|
) |
1645
|
|
|
); |
1646
|
|
|
|
1647
|
|
|
$query = $this->getDatabaseHandler()->createSelectQuery(); |
1648
|
|
|
$this->assertQueryResult( |
1649
|
|
|
array( |
1650
|
|
|
array('language_id' => 3), |
1651
|
|
|
), |
1652
|
|
|
$query->selectDistinct( |
1653
|
|
|
array('language_id') |
1654
|
|
|
)->from( |
1655
|
|
|
'ezcontentobject_attribute' |
1656
|
|
|
)->where( |
1657
|
|
|
$query->expr->lAnd( |
1658
|
|
|
$query->expr->eq('contentobject_id', 102), |
1659
|
|
|
$query->expr->eq('version', 1) |
1660
|
|
|
) |
1661
|
|
|
) |
1662
|
|
|
); |
1663
|
|
|
} |
1664
|
|
|
|
1665
|
|
|
/** |
1666
|
|
|
* Test for the updateAlwaysAvailableFlag() method. |
1667
|
|
|
* |
1668
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase::updateAlwaysAvailableFlag |
1669
|
|
|
*/ |
1670
|
|
View Code Duplication |
public function testUpdateContentAddAlwaysAvailableFlagMultilingual() |
1671
|
|
|
{ |
1672
|
|
|
$this->insertDatabaseFixture( |
1673
|
|
|
__DIR__ . '/../_fixtures/contentobjects_multilingual.php' |
1674
|
|
|
); |
1675
|
|
|
|
1676
|
|
|
$gateway = $this->getDatabaseGateway(); |
1677
|
|
|
$contentMetadataUpdateStruct = new MetadataUpdateStruct( |
1678
|
|
|
array( |
1679
|
|
|
'mainLanguageId' => 4, |
1680
|
|
|
'alwaysAvailable' => true, |
1681
|
|
|
) |
1682
|
|
|
); |
1683
|
|
|
$gateway->updateContent(4, $contentMetadataUpdateStruct); |
1684
|
|
|
|
1685
|
|
|
$this->assertQueryResult( |
1686
|
|
|
array(array('id' => 7)), |
1687
|
|
|
$this->getDatabaseHandler()->createSelectQuery()->select( |
1688
|
|
|
array('language_mask') |
1689
|
|
|
)->from( |
1690
|
|
|
'ezcontentobject' |
1691
|
|
|
)->where( |
1692
|
|
|
'id = 4' |
1693
|
|
|
) |
1694
|
|
|
); |
1695
|
|
|
|
1696
|
|
|
$query = $this->getDatabaseHandler()->createSelectQuery(); |
1697
|
|
|
$this->assertQueryResult( |
1698
|
|
|
array( |
1699
|
|
|
array('id' => '7', 'language_id' => 2), |
1700
|
|
|
array('id' => '8', 'language_id' => 5), |
1701
|
|
|
), |
1702
|
|
|
$query->selectDistinct( |
1703
|
|
|
array('id', 'language_id') |
1704
|
|
|
)->from( |
1705
|
|
|
'ezcontentobject_attribute' |
1706
|
|
|
)->where( |
1707
|
|
|
$query->expr->lAnd( |
1708
|
|
|
$query->expr->eq('contentobject_id', 4), |
1709
|
|
|
$query->expr->eq('version', 2) |
1710
|
|
|
) |
1711
|
|
|
)->orderBy('id') |
1712
|
|
|
); |
1713
|
|
|
|
1714
|
|
|
$query = $this->getDatabaseHandler()->createSelectQuery(); |
1715
|
|
|
$this->assertQueryResult( |
1716
|
|
|
array( |
1717
|
|
|
array('id' => '7', 'language_id' => 2), |
1718
|
|
|
array('id' => '8', 'language_id' => 5), |
1719
|
|
|
), |
1720
|
|
|
$query->selectDistinct( |
1721
|
|
|
array('id', 'language_id') |
1722
|
|
|
)->from( |
1723
|
|
|
'ezcontentobject_attribute' |
1724
|
|
|
)->where( |
1725
|
|
|
$query->expr->lAnd( |
1726
|
|
|
$query->expr->eq('contentobject_id', 4), |
1727
|
|
|
$query->expr->eq('version', 1) |
1728
|
|
|
) |
1729
|
|
|
)->orderBy('id') |
1730
|
|
|
); |
1731
|
|
|
} |
1732
|
|
|
|
1733
|
|
|
/** |
1734
|
|
|
* Test for the updateAlwaysAvailableFlag() method. |
1735
|
|
|
* |
1736
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase::updateAlwaysAvailableFlag |
1737
|
|
|
*/ |
1738
|
|
View Code Duplication |
public function testUpdateContentRemoveAlwaysAvailableFlagMultilingual() |
1739
|
|
|
{ |
1740
|
|
|
$this->insertDatabaseFixture( |
1741
|
|
|
__DIR__ . '/../_fixtures/contentobjects_multilingual.php' |
1742
|
|
|
); |
1743
|
|
|
|
1744
|
|
|
$gateway = $this->getDatabaseGateway(); |
1745
|
|
|
$contentMetadataUpdateStruct = new MetadataUpdateStruct( |
1746
|
|
|
array( |
1747
|
|
|
'mainLanguageId' => 4, |
1748
|
|
|
'alwaysAvailable' => false, |
1749
|
|
|
) |
1750
|
|
|
); |
1751
|
|
|
$gateway->updateContent(4, $contentMetadataUpdateStruct); |
1752
|
|
|
|
1753
|
|
|
$this->assertQueryResult( |
1754
|
|
|
array(array('id' => 6)), |
1755
|
|
|
$this->getDatabaseHandler()->createSelectQuery()->select( |
1756
|
|
|
array('language_mask') |
1757
|
|
|
)->from( |
1758
|
|
|
'ezcontentobject' |
1759
|
|
|
)->where( |
1760
|
|
|
'id = 4' |
1761
|
|
|
) |
1762
|
|
|
); |
1763
|
|
|
|
1764
|
|
|
$query = $this->getDatabaseHandler()->createSelectQuery(); |
1765
|
|
|
$this->assertQueryResult( |
1766
|
|
|
array( |
1767
|
|
|
array('id' => '7', 'language_id' => 2), |
1768
|
|
|
array('id' => '8', 'language_id' => 4), |
1769
|
|
|
), |
1770
|
|
|
$query->selectDistinct( |
1771
|
|
|
array('id', 'language_id') |
1772
|
|
|
)->from( |
1773
|
|
|
'ezcontentobject_attribute' |
1774
|
|
|
)->where( |
1775
|
|
|
$query->expr->lAnd( |
1776
|
|
|
$query->expr->eq('contentobject_id', 4), |
1777
|
|
|
$query->expr->eq('version', 2) |
1778
|
|
|
) |
1779
|
|
|
)->orderBy('id') |
1780
|
|
|
); |
1781
|
|
|
|
1782
|
|
|
$query = $this->getDatabaseHandler()->createSelectQuery(); |
1783
|
|
|
$this->assertQueryResult( |
1784
|
|
|
array( |
1785
|
|
|
array('id' => '7', 'language_id' => 2), |
1786
|
|
|
array('id' => '8', 'language_id' => 5), |
1787
|
|
|
), |
1788
|
|
|
$query->selectDistinct( |
1789
|
|
|
array('id', 'language_id') |
1790
|
|
|
)->from( |
1791
|
|
|
'ezcontentobject_attribute' |
1792
|
|
|
)->where( |
1793
|
|
|
$query->expr->lAnd( |
1794
|
|
|
$query->expr->eq('contentobject_id', 4), |
1795
|
|
|
$query->expr->eq('version', 1) |
1796
|
|
|
) |
1797
|
|
|
)->orderBy('id') |
1798
|
|
|
); |
1799
|
|
|
} |
1800
|
|
|
|
1801
|
|
View Code Duplication |
public function testLoadVersionInfo() |
1802
|
|
|
{ |
1803
|
|
|
$this->insertDatabaseFixture( |
1804
|
|
|
__DIR__ . '/../_fixtures/contentobjects.php' |
1805
|
|
|
); |
1806
|
|
|
|
1807
|
|
|
$gateway = $this->getDatabaseGateway(); |
1808
|
|
|
|
1809
|
|
|
$resFirst = $gateway->loadVersionInfo(11, 1); |
1810
|
|
|
$resSecond = $gateway->loadVersionInfo(11, 2); |
1811
|
|
|
|
1812
|
|
|
$res = array_merge($resFirst, $resSecond); |
1813
|
|
|
|
1814
|
|
|
$orig = include __DIR__ . '/../_fixtures/extract_version_info_from_rows_multiple_versions.php'; |
1815
|
|
|
|
1816
|
|
|
/*$this->storeFixture( |
1817
|
|
|
__DIR__ . '/../_fixtures/extract_version_info_from_rows_multiple_versions.php', |
1818
|
|
|
$res |
1819
|
|
|
);*/ |
1820
|
|
|
|
1821
|
|
|
$this->assertEquals($orig, $res, 'Fixtures differ between what was previously stored(expected) and what it now generates(actual), this hints either some mistake in impl or that the fixture (../_fixtures/extract_content_from_rows_multiple_versions.php) and tests needs to be adapted.'); |
1822
|
|
|
} |
1823
|
|
|
|
1824
|
|
|
/** |
1825
|
|
|
* Counts the number of relations in the database. |
1826
|
|
|
* |
1827
|
|
|
* @param int $fromId |
1828
|
|
|
* @param int $toId |
1829
|
|
|
* |
1830
|
|
|
* @return int |
1831
|
|
|
*/ |
1832
|
|
|
protected function countContentRelations($fromId = null, $toId = null) |
1833
|
|
|
{ |
1834
|
|
|
$query = $this->getDatabaseHandler()->createSelectQuery(); |
1835
|
|
|
$query->select('count(*)') |
1836
|
|
|
->from('ezcontentobject_link'); |
1837
|
|
|
|
1838
|
|
|
if ($fromId !== null) { |
1839
|
|
|
$query->where( |
1840
|
|
|
'from_contentobject_id=' . $fromId |
1841
|
|
|
); |
1842
|
|
|
} |
1843
|
|
|
if ($toId !== null) { |
1844
|
|
|
$query->where( |
1845
|
|
|
'to_contentobject_id=' . $toId |
1846
|
|
|
); |
1847
|
|
|
} |
1848
|
|
|
|
1849
|
|
|
$statement = $query->prepare(); |
1850
|
|
|
$statement->execute(); |
1851
|
|
|
|
1852
|
|
|
return (int)$statement->fetchColumn(); |
1853
|
|
|
} |
1854
|
|
|
|
1855
|
|
|
/** |
1856
|
|
|
* Counts the number of fields. |
1857
|
|
|
* |
1858
|
|
|
* @param int $contentId |
1859
|
|
|
* |
1860
|
|
|
* @return int |
1861
|
|
|
*/ |
1862
|
|
View Code Duplication |
protected function countContentFields($contentId = null) |
1863
|
|
|
{ |
1864
|
|
|
$query = $this->getDatabaseHandler()->createSelectQuery(); |
1865
|
|
|
$query->select('count(*)') |
1866
|
|
|
->from('ezcontentobject_attribute'); |
1867
|
|
|
|
1868
|
|
|
if ($contentId !== null) { |
1869
|
|
|
$query->where( |
1870
|
|
|
'contentobject_id=' . $contentId |
1871
|
|
|
); |
1872
|
|
|
} |
1873
|
|
|
|
1874
|
|
|
$statement = $query->prepare(); |
1875
|
|
|
$statement->execute(); |
1876
|
|
|
|
1877
|
|
|
return (int)$statement->fetchColumn(); |
1878
|
|
|
} |
1879
|
|
|
|
1880
|
|
|
/** |
1881
|
|
|
* Counts the number of versions. |
1882
|
|
|
* |
1883
|
|
|
* @param int $contentId |
1884
|
|
|
* |
1885
|
|
|
* @return int |
1886
|
|
|
*/ |
1887
|
|
View Code Duplication |
protected function countContentVersions($contentId = null) |
1888
|
|
|
{ |
1889
|
|
|
$query = $this->getDatabaseHandler()->createSelectQuery(); |
1890
|
|
|
$query->select('count(*)') |
1891
|
|
|
->from('ezcontentobject_version'); |
1892
|
|
|
|
1893
|
|
|
if ($contentId !== null) { |
1894
|
|
|
$query->where( |
1895
|
|
|
'contentobject_id=' . $contentId |
1896
|
|
|
); |
1897
|
|
|
} |
1898
|
|
|
|
1899
|
|
|
$statement = $query->prepare(); |
1900
|
|
|
$statement->execute(); |
1901
|
|
|
|
1902
|
|
|
return (int)$statement->fetchColumn(); |
1903
|
|
|
} |
1904
|
|
|
|
1905
|
|
|
/** |
1906
|
|
|
* Counts the number of content names. |
1907
|
|
|
* |
1908
|
|
|
* @param int $contentId |
1909
|
|
|
* |
1910
|
|
|
* @return int |
1911
|
|
|
*/ |
1912
|
|
View Code Duplication |
protected function countContentNames($contentId = null) |
1913
|
|
|
{ |
1914
|
|
|
$query = $this->getDatabaseHandler()->createSelectQuery(); |
1915
|
|
|
$query->select('count(*)') |
1916
|
|
|
->from('ezcontentobject_name'); |
1917
|
|
|
|
1918
|
|
|
if ($contentId !== null) { |
1919
|
|
|
$query->where( |
1920
|
|
|
'contentobject_id=' . $contentId |
1921
|
|
|
); |
1922
|
|
|
} |
1923
|
|
|
|
1924
|
|
|
$statement = $query->prepare(); |
1925
|
|
|
$statement->execute(); |
1926
|
|
|
|
1927
|
|
|
return (int)$statement->fetchColumn(); |
1928
|
|
|
} |
1929
|
|
|
|
1930
|
|
|
/** |
1931
|
|
|
* Counts the number of content objects. |
1932
|
|
|
* |
1933
|
|
|
* @param int $contentId |
1934
|
|
|
* |
1935
|
|
|
* @return int |
1936
|
|
|
*/ |
1937
|
|
View Code Duplication |
protected function countContent($contentId = null) |
1938
|
|
|
{ |
1939
|
|
|
$query = $this->getDatabaseHandler()->createSelectQuery(); |
1940
|
|
|
$query->select('count(*)') |
1941
|
|
|
->from('ezcontentobject'); |
1942
|
|
|
|
1943
|
|
|
if ($contentId !== null) { |
1944
|
|
|
$query->where( |
1945
|
|
|
'id=' . $contentId |
1946
|
|
|
); |
1947
|
|
|
} |
1948
|
|
|
|
1949
|
|
|
$statement = $query->prepare(); |
1950
|
|
|
$statement->execute(); |
1951
|
|
|
|
1952
|
|
|
return (int)$statement->fetchColumn(); |
1953
|
|
|
} |
1954
|
|
|
|
1955
|
|
|
/** |
1956
|
|
|
* Stores $fixture in $file to be required as a fixture. |
1957
|
|
|
* |
1958
|
|
|
* @param string $file |
1959
|
|
|
* @param mixed $fixture |
1960
|
|
|
*/ |
1961
|
|
|
protected function storeFixture($file, $fixture) |
1962
|
|
|
{ |
1963
|
|
|
file_put_contents( |
1964
|
|
|
$file, |
1965
|
|
|
"<?php\n\nreturn " . str_replace(" \n", "\n", var_export($fixture, true)) . ";\n" |
1966
|
|
|
); |
1967
|
|
|
} |
1968
|
|
|
|
1969
|
|
|
/** |
1970
|
|
|
* Returns a Field fixture. |
1971
|
|
|
* |
1972
|
|
|
* @return Field |
1973
|
|
|
*/ |
1974
|
|
|
protected function getFieldFixture() |
1975
|
|
|
{ |
1976
|
|
|
$field = new Field(); |
1977
|
|
|
|
1978
|
|
|
$field->fieldDefinitionId = 231; |
1979
|
|
|
$field->type = 'ezstring'; |
1980
|
|
|
$field->languageCode = 'eng-GB'; |
1981
|
|
|
$field->versionNo = 1; |
1982
|
|
|
|
1983
|
|
|
return $field; |
1984
|
|
|
} |
1985
|
|
|
|
1986
|
|
|
/** |
1987
|
|
|
* Returns a Field fixture in a different language. |
1988
|
|
|
* |
1989
|
|
|
* @return Field |
1990
|
|
|
*/ |
1991
|
|
|
protected function getOtherLanguageFieldFixture() |
1992
|
|
|
{ |
1993
|
|
|
$field = $this->getFieldFixture(); |
1994
|
|
|
$field->languageCode = 'eng-US'; |
1995
|
|
|
|
1996
|
|
|
return $field; |
1997
|
|
|
} |
1998
|
|
|
|
1999
|
|
|
/** |
2000
|
|
|
* Returns a StorageFieldValue fixture. |
2001
|
|
|
* |
2002
|
|
|
* @return StorageFieldValue |
2003
|
|
|
*/ |
2004
|
|
|
protected function getStorageValueFixture() |
2005
|
|
|
{ |
2006
|
|
|
$value = new StorageFieldValue(); |
2007
|
|
|
|
2008
|
|
|
$value->dataFloat = 24.42; |
2009
|
|
|
$value->dataInt = 42; |
2010
|
|
|
$value->dataText = 'Test text'; |
2011
|
|
|
$value->sortKeyInt = 23; |
2012
|
|
|
$value->sortKeyString = 'Test'; |
2013
|
|
|
|
2014
|
|
|
return $value; |
2015
|
|
|
} |
2016
|
|
|
|
2017
|
|
|
/** |
2018
|
|
|
* Returns a ready to test DoctrineDatabase gateway. |
2019
|
|
|
* |
2020
|
|
|
* @return \eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase |
2021
|
|
|
*/ |
2022
|
|
|
protected function getDatabaseGateway() |
2023
|
|
|
{ |
2024
|
|
|
if (!isset($this->databaseGateway)) { |
2025
|
|
|
$this->databaseGateway = new DoctrineDatabase( |
2026
|
|
|
($dbHandler = $this->getDatabaseHandler()), |
2027
|
|
|
$this->getDatabaseConnection(), |
2028
|
|
|
new DoctrineDatabase\QueryBuilder($dbHandler), |
2029
|
|
|
$this->getLanguageHandler(), |
2030
|
|
|
$this->getLanguageMaskGenerator() |
2031
|
|
|
); |
2032
|
|
|
} |
2033
|
|
|
|
2034
|
|
|
return $this->databaseGateway; |
2035
|
|
|
} |
2036
|
|
|
|
2037
|
|
|
/** |
2038
|
|
|
* DoctrineDatabaseTest::getRelationCreateStructFixture(). |
2039
|
|
|
* |
2040
|
|
|
* @return \eZ\Publish\SPI\Persistence\Content\Relation\CreateStruct |
2041
|
|
|
*/ |
2042
|
|
View Code Duplication |
protected function getRelationCreateStructFixture() |
2043
|
|
|
{ |
2044
|
|
|
$struct = new RelationCreateStruct(); |
2045
|
|
|
|
2046
|
|
|
$struct->destinationContentId = 1; |
2047
|
|
|
$struct->sourceContentId = 1; |
2048
|
|
|
$struct->sourceContentVersionNo = 1; |
2049
|
|
|
$struct->sourceFieldDefinitionId = 0; |
2050
|
|
|
$struct->type = RelationValue::COMMON; |
2051
|
|
|
|
2052
|
|
|
return $struct; |
2053
|
|
|
} |
2054
|
|
|
} |
2055
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..