1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @copyright Copyright (C) eZ Systems AS. All rights reserved. |
5
|
|
|
* @license For full copyright and license information view LICENSE file distributed with this source code. |
6
|
|
|
*/ |
7
|
|
|
namespace eZ\Publish\Core\Persistence\Legacy\Tests\Content\UrlAlias; |
8
|
|
|
|
9
|
|
|
use eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Gateway as UrlAliasGateway; |
10
|
|
|
use eZ\Publish\Core\Persistence\Legacy\Tests\TestCase; |
11
|
|
|
use eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler; |
12
|
|
|
use eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway as LocationGateway; |
13
|
|
|
use eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Mapper; |
14
|
|
|
use eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Gateway\DoctrineDatabase; |
15
|
|
|
use eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\SlugConverter; |
16
|
|
|
use eZ\Publish\Core\Persistence\Legacy\Content\Gateway; |
17
|
|
|
use eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase as ContentGateway; |
18
|
|
|
use eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway\DoctrineDatabase as DoctrineDatabaseLocation; |
19
|
|
|
use eZ\Publish\Core\Persistence\Legacy\Content\Language\Handler as LanguageHandler; |
20
|
|
|
use eZ\Publish\Core\Persistence\Legacy\Content\Language\Gateway\DoctrineDatabase as LanguageGateway; |
21
|
|
|
use eZ\Publish\Core\Persistence\Legacy\Content\Language\Mapper as LanguageMapper; |
22
|
|
|
use eZ\Publish\Core\Persistence\Legacy\Content\Language\MaskGenerator as LanguageMaskGenerator; |
23
|
|
|
use eZ\Publish\Core\Persistence\TransformationProcessor\DefinitionBased; |
24
|
|
|
use eZ\Publish\Core\Persistence\TransformationProcessor\DefinitionBased\Parser; |
25
|
|
|
use eZ\Publish\Core\Persistence\TransformationProcessor\PcreCompiler; |
26
|
|
|
use eZ\Publish\Core\Persistence\Utf8Converter; |
27
|
|
|
use eZ\Publish\SPI\Persistence\Content\UrlAlias; |
28
|
|
|
use eZ\Publish\Core\Base\Exceptions\NotFoundException; |
29
|
|
|
use eZ\Publish\SPI\Persistence\TransactionHandler; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Test case for UrlAliasHandler. |
33
|
|
|
* |
34
|
|
|
* @group urlalias-handler |
35
|
|
|
*/ |
36
|
|
|
class UrlAliasHandlerTest extends TestCase |
37
|
|
|
{ |
38
|
|
|
/** |
39
|
|
|
* Test for the lookup() method. |
40
|
|
|
* |
41
|
|
|
* Simple lookup case. |
42
|
|
|
* |
43
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::lookup |
44
|
|
|
* @group location |
45
|
|
|
* @group virtual |
46
|
|
|
* @group resource |
47
|
|
|
* @group case-correction |
48
|
|
|
* @group multiple-languages |
49
|
|
|
*/ |
50
|
|
View Code Duplication |
public function testLookup() |
51
|
|
|
{ |
52
|
|
|
$handler = $this->getHandler(); |
53
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_location.php'); |
54
|
|
|
|
55
|
|
|
$urlAlias = $handler->lookup('jedan'); |
56
|
|
|
self::assertInstanceOf(UrlAlias::class, $urlAlias); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Test for the lookup() method. |
61
|
|
|
* |
62
|
|
|
* Trying to lookup non existent URL alias throws NotFoundException. |
63
|
|
|
* |
64
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::lookup |
65
|
|
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\NotFoundException |
66
|
|
|
* @group location |
67
|
|
|
* @group virtual |
68
|
|
|
* @group resource |
69
|
|
|
*/ |
70
|
|
|
public function testLookupThrowsNotFoundException() |
71
|
|
|
{ |
72
|
|
|
$handler = $this->getHandler(); |
73
|
|
|
$handler->lookup('wooden/iron'); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* Test for the lookup() method. |
78
|
|
|
* |
79
|
|
|
* Trying to lookup URL alias with exceeded path segments limit |
80
|
|
|
* |
81
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::lookup |
82
|
|
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
83
|
|
|
* @group location |
84
|
|
|
* @group case-correction |
85
|
|
|
*/ |
86
|
|
|
public function testLookupThrowsInvalidArgumentException() |
87
|
|
|
{ |
88
|
|
|
$handler = $this->getHandler(); |
89
|
|
|
$handler->lookup(str_repeat('/1', 99)); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
public function providerForTestLookupLocationUrlAlias() |
93
|
|
|
{ |
94
|
|
|
return [ |
95
|
|
|
[ |
96
|
|
|
'jedan', |
97
|
|
|
[ |
98
|
|
|
[ |
99
|
|
|
'always-available' => true, |
100
|
|
|
'translations' => [ |
101
|
|
|
'cro-HR' => 'jedan', |
102
|
|
|
], |
103
|
|
|
], |
104
|
|
|
], |
105
|
|
|
['cro-HR'], |
106
|
|
|
true, |
107
|
|
|
314, |
108
|
|
|
'0-6896260129051a949051c3847c34466f', |
109
|
|
|
], |
110
|
|
|
[ |
111
|
|
|
'jedan/dva', |
112
|
|
|
[ |
113
|
|
|
[ |
114
|
|
|
'always-available' => true, |
115
|
|
|
'translations' => [ |
116
|
|
|
'cro-HR' => 'jedan', |
117
|
|
|
], |
118
|
|
|
], |
119
|
|
|
[ |
120
|
|
|
'always-available' => false, |
121
|
|
|
'translations' => [ |
122
|
|
|
'cro-HR' => 'dva', |
123
|
|
|
'eng-GB' => 'two', |
124
|
|
|
], |
125
|
|
|
], |
126
|
|
|
], |
127
|
|
|
['cro-HR'], |
128
|
|
|
false, |
129
|
|
|
315, |
130
|
|
|
'2-c67ed9a09ab136fae610b6a087d82e21', |
131
|
|
|
], |
132
|
|
|
[ |
133
|
|
|
'jedan/two', |
134
|
|
|
[ |
135
|
|
|
[ |
136
|
|
|
'always-available' => true, |
137
|
|
|
'translations' => [ |
138
|
|
|
'cro-HR' => 'jedan', |
139
|
|
|
], |
140
|
|
|
], |
141
|
|
|
[ |
142
|
|
|
'always-available' => false, |
143
|
|
|
'translations' => [ |
144
|
|
|
'cro-HR' => 'dva', |
145
|
|
|
'eng-GB' => 'two', |
146
|
|
|
], |
147
|
|
|
], |
148
|
|
|
], |
149
|
|
|
['eng-GB'], |
150
|
|
|
false, |
151
|
|
|
315, |
152
|
|
|
'2-b8a9f715dbb64fd5c56e7783c6820a61', |
153
|
|
|
], |
154
|
|
|
[ |
155
|
|
|
'jedan/dva/tri', |
156
|
|
|
[ |
157
|
|
|
[ |
158
|
|
|
'always-available' => true, |
159
|
|
|
'translations' => [ |
160
|
|
|
'cro-HR' => 'jedan', |
161
|
|
|
], |
162
|
|
|
], |
163
|
|
|
[ |
164
|
|
|
'always-available' => false, |
165
|
|
|
'translations' => [ |
166
|
|
|
'cro-HR' => 'dva', |
167
|
|
|
'eng-GB' => 'two', |
168
|
|
|
], |
169
|
|
|
], |
170
|
|
|
[ |
171
|
|
|
'always-available' => false, |
172
|
|
|
'translations' => [ |
173
|
|
|
'cro-HR' => 'tri', |
174
|
|
|
'eng-GB' => 'three', |
175
|
|
|
'ger-DE' => 'drei', |
176
|
|
|
], |
177
|
|
|
], |
178
|
|
|
], |
179
|
|
|
['cro-HR'], |
180
|
|
|
false, |
181
|
|
|
316, |
182
|
|
|
'3-d2cfe69af2d64330670e08efb2c86df7', |
183
|
|
|
], |
184
|
|
|
[ |
185
|
|
|
'jedan/two/three', |
186
|
|
|
[ |
187
|
|
|
[ |
188
|
|
|
'always-available' => true, |
189
|
|
|
'translations' => [ |
190
|
|
|
'cro-HR' => 'jedan', |
191
|
|
|
], |
192
|
|
|
], |
193
|
|
|
[ |
194
|
|
|
'always-available' => false, |
195
|
|
|
'translations' => [ |
196
|
|
|
'cro-HR' => 'dva', |
197
|
|
|
'eng-GB' => 'two', |
198
|
|
|
], |
199
|
|
|
], |
200
|
|
|
[ |
201
|
|
|
'always-available' => false, |
202
|
|
|
'translations' => [ |
203
|
|
|
'cro-HR' => 'tri', |
204
|
|
|
'eng-GB' => 'three', |
205
|
|
|
'ger-DE' => 'drei', |
206
|
|
|
], |
207
|
|
|
], |
208
|
|
|
], |
209
|
|
|
['eng-GB'], |
210
|
|
|
false, |
211
|
|
|
316, |
212
|
|
|
'3-35d6d33467aae9a2e3dccb4b6b027878', |
213
|
|
|
], |
214
|
|
|
[ |
215
|
|
|
'jedan/dva/three', |
216
|
|
|
[ |
217
|
|
|
[ |
218
|
|
|
'always-available' => true, |
219
|
|
|
'translations' => [ |
220
|
|
|
'cro-HR' => 'jedan', |
221
|
|
|
], |
222
|
|
|
], |
223
|
|
|
[ |
224
|
|
|
'always-available' => false, |
225
|
|
|
'translations' => [ |
226
|
|
|
'cro-HR' => 'dva', |
227
|
|
|
'eng-GB' => 'two', |
228
|
|
|
], |
229
|
|
|
], |
230
|
|
|
[ |
231
|
|
|
'always-available' => false, |
232
|
|
|
'translations' => [ |
233
|
|
|
'cro-HR' => 'tri', |
234
|
|
|
'eng-GB' => 'three', |
235
|
|
|
'ger-DE' => 'drei', |
236
|
|
|
], |
237
|
|
|
], |
238
|
|
|
], |
239
|
|
|
['eng-GB'], |
240
|
|
|
false, |
241
|
|
|
316, |
242
|
|
|
'3-35d6d33467aae9a2e3dccb4b6b027878', |
243
|
|
|
], |
244
|
|
|
[ |
245
|
|
|
'jedan/two/tri', |
246
|
|
|
[ |
247
|
|
|
[ |
248
|
|
|
'always-available' => true, |
249
|
|
|
'translations' => [ |
250
|
|
|
'cro-HR' => 'jedan', |
251
|
|
|
], |
252
|
|
|
], |
253
|
|
|
[ |
254
|
|
|
'always-available' => false, |
255
|
|
|
'translations' => [ |
256
|
|
|
'cro-HR' => 'dva', |
257
|
|
|
'eng-GB' => 'two', |
258
|
|
|
], |
259
|
|
|
], |
260
|
|
|
[ |
261
|
|
|
'always-available' => false, |
262
|
|
|
'translations' => [ |
263
|
|
|
'cro-HR' => 'tri', |
264
|
|
|
'eng-GB' => 'three', |
265
|
|
|
'ger-DE' => 'drei', |
266
|
|
|
], |
267
|
|
|
], |
268
|
|
|
], |
269
|
|
|
['cro-HR'], |
270
|
|
|
false, |
271
|
|
|
316, |
272
|
|
|
'3-d2cfe69af2d64330670e08efb2c86df7', |
273
|
|
|
], |
274
|
|
|
[ |
275
|
|
|
'jedan/dva/drei', |
276
|
|
|
[ |
277
|
|
|
[ |
278
|
|
|
'always-available' => true, |
279
|
|
|
'translations' => [ |
280
|
|
|
'cro-HR' => 'jedan', |
281
|
|
|
], |
282
|
|
|
], |
283
|
|
|
[ |
284
|
|
|
'always-available' => false, |
285
|
|
|
'translations' => [ |
286
|
|
|
'cro-HR' => 'dva', |
287
|
|
|
'eng-GB' => 'two', |
288
|
|
|
], |
289
|
|
|
], |
290
|
|
|
[ |
291
|
|
|
'always-available' => false, |
292
|
|
|
'translations' => [ |
293
|
|
|
'cro-HR' => 'tri', |
294
|
|
|
'eng-GB' => 'three', |
295
|
|
|
'ger-DE' => 'drei', |
296
|
|
|
], |
297
|
|
|
], |
298
|
|
|
], |
299
|
|
|
['ger-DE'], |
300
|
|
|
false, |
301
|
|
|
316, |
302
|
|
|
'3-1d8d2fd0a99802b89eb356a86e029d25', |
303
|
|
|
], |
304
|
|
|
[ |
305
|
|
|
'jedan/two/drei', |
306
|
|
|
[ |
307
|
|
|
[ |
308
|
|
|
'always-available' => true, |
309
|
|
|
'translations' => [ |
310
|
|
|
'cro-HR' => 'jedan', |
311
|
|
|
], |
312
|
|
|
], |
313
|
|
|
[ |
314
|
|
|
'always-available' => false, |
315
|
|
|
'translations' => [ |
316
|
|
|
'cro-HR' => 'dva', |
317
|
|
|
'eng-GB' => 'two', |
318
|
|
|
], |
319
|
|
|
], |
320
|
|
|
[ |
321
|
|
|
'always-available' => false, |
322
|
|
|
'translations' => [ |
323
|
|
|
'cro-HR' => 'tri', |
324
|
|
|
'eng-GB' => 'three', |
325
|
|
|
'ger-DE' => 'drei', |
326
|
|
|
], |
327
|
|
|
], |
328
|
|
|
], |
329
|
|
|
['ger-DE'], |
330
|
|
|
false, |
331
|
|
|
316, |
332
|
|
|
'3-1d8d2fd0a99802b89eb356a86e029d25', |
333
|
|
|
], |
334
|
|
|
]; |
335
|
|
|
} |
336
|
|
|
|
337
|
|
|
/** |
338
|
|
|
* Test for the lookup() method. |
339
|
|
|
* |
340
|
|
|
* Testing that UrlAlias is found and has expected state. |
341
|
|
|
* |
342
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::lookup |
343
|
|
|
* @dataProvider providerForTestLookupLocationUrlAlias |
344
|
|
|
* @depends testLookup |
345
|
|
|
* @group location |
346
|
|
|
*/ |
347
|
|
View Code Duplication |
public function testLookupLocationUrlAlias( |
348
|
|
|
$url, |
349
|
|
|
array $pathData, |
350
|
|
|
array $languageCodes, |
351
|
|
|
$alwaysAvailable, |
352
|
|
|
$locationId, |
353
|
|
|
$id |
354
|
|
|
) { |
355
|
|
|
$handler = $this->getHandler(); |
356
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_location.php'); |
357
|
|
|
|
358
|
|
|
$urlAlias = $handler->lookup($url); |
359
|
|
|
|
360
|
|
|
self::assertInstanceOf(UrlAlias::class, $urlAlias); |
361
|
|
|
self::assertEquals( |
362
|
|
|
new UrlAlias( |
363
|
|
|
[ |
364
|
|
|
'id' => $id, |
365
|
|
|
'type' => UrlAlias::LOCATION, |
366
|
|
|
'destination' => $locationId, |
367
|
|
|
'languageCodes' => $languageCodes, |
368
|
|
|
'pathData' => $pathData, |
369
|
|
|
'alwaysAvailable' => $alwaysAvailable, |
370
|
|
|
'isHistory' => false, |
371
|
|
|
'isCustom' => false, |
372
|
|
|
'forward' => false, |
373
|
|
|
] |
374
|
|
|
), |
375
|
|
|
$urlAlias |
376
|
|
|
); |
377
|
|
|
} |
378
|
|
|
|
379
|
|
|
/** |
380
|
|
|
* Testing that looking up case incorrect URL results in redirection to case correct path. |
381
|
|
|
* |
382
|
|
|
* Note that case corrected path is not always equal to case corrected case incorrect path, eg. "JEDAN/TWO/THREE" |
383
|
|
|
* will not always redirect to "jedan/two/three". |
384
|
|
|
* In some cases, depending on list of prioritized languages and if Content available in the different language |
385
|
|
|
* higher in the list of prioritized languages, path showing to that Content will be used. |
386
|
|
|
* Example: "JEDAN/TWO/DREI" with "eng-GB" and "ger-DE" as prioritized languages will produce redirection |
387
|
|
|
* to the "jedan/two/three", as "eng-GB" is the most prioritized language and Content that URL alias is pointing |
388
|
|
|
* to is available in it. |
389
|
|
|
* |
390
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::lookup |
391
|
|
|
* @dataProvider providerForTestLookupLocationUrlAlias |
392
|
|
|
* @depends testLookup |
393
|
|
|
* @group case-correction |
394
|
|
|
* @group location |
395
|
|
|
* |
396
|
|
|
* @todo refactor, only forward pertinent |
397
|
|
|
*/ |
398
|
|
View Code Duplication |
public function testLookupLocationCaseCorrection( |
399
|
|
|
$url, |
400
|
|
|
array $pathData, |
401
|
|
|
array $languageCodes, |
402
|
|
|
$alwaysAvailable, |
403
|
|
|
$locationId, |
404
|
|
|
$id |
405
|
|
|
) { |
406
|
|
|
$handler = $this->getHandler(); |
407
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_location.php'); |
408
|
|
|
|
409
|
|
|
$urlAlias = $handler->lookup(strtoupper($url)); |
410
|
|
|
|
411
|
|
|
self::assertInstanceOf(UrlAlias::class, $urlAlias); |
412
|
|
|
self::assertEquals( |
413
|
|
|
new UrlAlias( |
414
|
|
|
[ |
415
|
|
|
'id' => $id, |
416
|
|
|
'type' => UrlAlias::LOCATION, |
417
|
|
|
'destination' => $locationId, |
418
|
|
|
'languageCodes' => $languageCodes, |
419
|
|
|
'pathData' => $pathData, |
420
|
|
|
'alwaysAvailable' => $alwaysAvailable, |
421
|
|
|
'isHistory' => false, |
422
|
|
|
'isCustom' => false, |
423
|
|
|
'forward' => false, |
424
|
|
|
] |
425
|
|
|
), |
426
|
|
|
$urlAlias |
427
|
|
|
); |
428
|
|
|
} |
429
|
|
|
|
430
|
|
|
public function providerForTestLookupLocationMultipleLanguages() |
431
|
|
|
{ |
432
|
|
|
return [ |
433
|
|
|
[ |
434
|
|
|
'jedan/dva', |
435
|
|
|
[ |
436
|
|
|
[ |
437
|
|
|
'always-available' => true, |
438
|
|
|
'translations' => [ |
439
|
|
|
'cro-HR' => 'jedan', |
440
|
|
|
], |
441
|
|
|
], |
442
|
|
|
[ |
443
|
|
|
'always-available' => false, |
444
|
|
|
'translations' => [ |
445
|
|
|
'cro-HR' => 'dva', |
446
|
|
|
'eng-GB' => 'dva', |
447
|
|
|
], |
448
|
|
|
], |
449
|
|
|
], |
450
|
|
|
['cro-HR', 'eng-GB'], |
451
|
|
|
false, |
452
|
|
|
315, |
453
|
|
|
'2-c67ed9a09ab136fae610b6a087d82e21', |
454
|
|
|
], |
455
|
|
|
[ |
456
|
|
|
'jedan/dva/tri', |
457
|
|
|
[ |
458
|
|
|
[ |
459
|
|
|
'always-available' => true, |
460
|
|
|
'translations' => [ |
461
|
|
|
'cro-HR' => 'jedan', |
462
|
|
|
], |
463
|
|
|
], |
464
|
|
|
[ |
465
|
|
|
'always-available' => false, |
466
|
|
|
'translations' => [ |
467
|
|
|
'cro-HR' => 'dva', |
468
|
|
|
'eng-GB' => 'dva', |
469
|
|
|
], |
470
|
|
|
], |
471
|
|
|
[ |
472
|
|
|
'always-available' => false, |
473
|
|
|
'translations' => [ |
474
|
|
|
'cro-HR' => 'tri', |
475
|
|
|
'eng-GB' => 'three', |
476
|
|
|
], |
477
|
|
|
], |
478
|
|
|
], |
479
|
|
|
['cro-HR'], |
480
|
|
|
false, |
481
|
|
|
316, |
482
|
|
|
'3-d2cfe69af2d64330670e08efb2c86df7', |
483
|
|
|
], |
484
|
|
|
[ |
485
|
|
|
'jedan/dva/three', |
486
|
|
|
[ |
487
|
|
|
[ |
488
|
|
|
'always-available' => true, |
489
|
|
|
'translations' => [ |
490
|
|
|
'cro-HR' => 'jedan', |
491
|
|
|
], |
492
|
|
|
], |
493
|
|
|
[ |
494
|
|
|
'always-available' => false, |
495
|
|
|
'translations' => [ |
496
|
|
|
'cro-HR' => 'dva', |
497
|
|
|
'eng-GB' => 'dva', |
498
|
|
|
], |
499
|
|
|
], |
500
|
|
|
[ |
501
|
|
|
'always-available' => false, |
502
|
|
|
'translations' => [ |
503
|
|
|
'cro-HR' => 'tri', |
504
|
|
|
'eng-GB' => 'three', |
505
|
|
|
], |
506
|
|
|
], |
507
|
|
|
], |
508
|
|
|
['eng-GB'], |
509
|
|
|
false, |
510
|
|
|
316, |
511
|
|
|
'3-35d6d33467aae9a2e3dccb4b6b027878', |
512
|
|
|
], |
513
|
|
|
]; |
514
|
|
|
} |
515
|
|
|
|
516
|
|
|
/** |
517
|
|
|
* Test for the lookup() method. |
518
|
|
|
* |
519
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::lookup |
520
|
|
|
* @dataProvider providerForTestLookupLocationMultipleLanguages |
521
|
|
|
* @depends testLookup |
522
|
|
|
* @group multiple-languages |
523
|
|
|
* @group location |
524
|
|
|
*/ |
525
|
|
View Code Duplication |
public function testLookupLocationMultipleLanguages( |
526
|
|
|
$url, |
527
|
|
|
array $pathData, |
528
|
|
|
array $languageCodes, |
529
|
|
|
$alwaysAvailable, |
530
|
|
|
$locationId, |
531
|
|
|
$id |
532
|
|
|
) { |
533
|
|
|
$handler = $this->getHandler(); |
534
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_location_multilang.php'); |
535
|
|
|
|
536
|
|
|
$urlAlias = $handler->lookup($url); |
537
|
|
|
|
538
|
|
|
self::assertInstanceOf(UrlAlias::class, $urlAlias); |
539
|
|
|
self::assertEquals( |
540
|
|
|
new UrlAlias( |
541
|
|
|
[ |
542
|
|
|
'id' => $id, |
543
|
|
|
'type' => UrlAlias::LOCATION, |
544
|
|
|
'destination' => $locationId, |
545
|
|
|
'languageCodes' => $languageCodes, |
546
|
|
|
'pathData' => $pathData, |
547
|
|
|
'alwaysAvailable' => $alwaysAvailable, |
548
|
|
|
'isHistory' => false, |
549
|
|
|
'isCustom' => false, |
550
|
|
|
'forward' => false, |
551
|
|
|
] |
552
|
|
|
), |
553
|
|
|
$urlAlias |
554
|
|
|
); |
555
|
|
|
} |
556
|
|
|
|
557
|
|
|
/** |
558
|
|
|
* Test for the lookup() method. |
559
|
|
|
* |
560
|
|
|
* @todo document |
561
|
|
|
* |
562
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::lookup |
563
|
|
|
* @depends testLookup |
564
|
|
|
* @group history |
565
|
|
|
* @group location |
566
|
|
|
*/ |
567
|
|
|
public function testLookupLocationHistoryUrlAlias() |
568
|
|
|
{ |
569
|
|
|
$handler = $this->getHandler(); |
570
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_location.php'); |
571
|
|
|
|
572
|
|
|
$urlAlias = $handler->lookup('jedan/dva/tri-history'); |
573
|
|
|
|
574
|
|
|
self::assertEquals( |
575
|
|
|
$this->getHistoryAlias(), |
576
|
|
|
$urlAlias |
577
|
|
|
); |
578
|
|
|
} |
579
|
|
|
|
580
|
|
|
public function providerForTestLookupCustomLocationUrlAlias() |
581
|
|
|
{ |
582
|
|
|
return [ |
583
|
|
|
[ |
584
|
|
|
'autogenerated-hello/everybody', |
585
|
|
|
[ |
586
|
|
|
[ |
587
|
|
|
'always-available' => true, |
588
|
|
|
'translations' => [ |
589
|
|
|
'eng-GB' => 'autogenerated-hello', |
590
|
|
|
], |
591
|
|
|
], |
592
|
|
|
[ |
593
|
|
|
'always-available' => true, |
594
|
|
|
'translations' => [ |
595
|
|
|
'eng-GB' => 'everybody', |
596
|
|
|
], |
597
|
|
|
], |
598
|
|
|
], |
599
|
|
|
['eng-GB'], |
600
|
|
|
false, |
601
|
|
|
true, |
602
|
|
|
315, |
603
|
|
|
'2-88150d7d17390010ba6222de68bfafb5', |
604
|
|
|
], |
605
|
|
|
[ |
606
|
|
|
'hello', |
607
|
|
|
[ |
608
|
|
|
[ |
609
|
|
|
'always-available' => false, |
610
|
|
|
'translations' => [ |
611
|
|
|
'eng-GB' => 'hello', |
612
|
|
|
], |
613
|
|
|
], |
614
|
|
|
], |
615
|
|
|
['eng-GB'], |
616
|
|
|
true, |
617
|
|
|
false, |
618
|
|
|
314, |
619
|
|
|
'0-5d41402abc4b2a76b9719d911017c592', |
620
|
|
|
], |
621
|
|
|
[ |
622
|
|
|
'hello/and/goodbye', |
623
|
|
|
[ |
624
|
|
|
[ |
625
|
|
|
'always-available' => false, |
626
|
|
|
'translations' => [ |
627
|
|
|
'eng-GB' => 'hello', |
628
|
|
|
], |
629
|
|
|
], |
630
|
|
|
[ |
631
|
|
|
'always-available' => true, |
632
|
|
|
'translations' => [ |
633
|
|
|
'always-available' => 'and', |
634
|
|
|
], |
635
|
|
|
], |
636
|
|
|
[ |
637
|
|
|
'always-available' => false, |
638
|
|
|
'translations' => [ |
639
|
|
|
'eng-GB' => 'goodbye', |
640
|
|
|
], |
641
|
|
|
], |
642
|
|
|
], |
643
|
|
|
['eng-GB'], |
644
|
|
|
true, |
645
|
|
|
false, |
646
|
|
|
316, |
647
|
|
|
'8-69faab6268350295550de7d587bc323d', |
648
|
|
|
], |
649
|
|
|
[ |
650
|
|
|
'hello/everyone', |
651
|
|
|
[ |
652
|
|
|
[ |
653
|
|
|
'always-available' => false, |
654
|
|
|
'translations' => [ |
655
|
|
|
'eng-GB' => 'hello', |
656
|
|
|
], |
657
|
|
|
], |
658
|
|
|
[ |
659
|
|
|
'always-available' => false, |
660
|
|
|
'translations' => [ |
661
|
|
|
'eng-GB' => 'everyone', |
662
|
|
|
], |
663
|
|
|
], |
664
|
|
|
], |
665
|
|
|
['eng-GB'], |
666
|
|
|
true, |
667
|
|
|
false, |
668
|
|
|
315, |
669
|
|
|
'6-ed881bac6397ede33c0a285c9f50bb83', |
670
|
|
|
], |
671
|
|
|
[ |
672
|
|
|
'well/ha-ha-ha', |
673
|
|
|
[ |
674
|
|
|
[ |
675
|
|
|
'always-available' => true, |
676
|
|
|
'translations' => [ |
677
|
|
|
'always-available' => 'well', |
678
|
|
|
], |
679
|
|
|
], |
680
|
|
|
[ |
681
|
|
|
'always-available' => false, |
682
|
|
|
'translations' => [ |
683
|
|
|
'eng-GB' => 'ha-ha-ha', |
684
|
|
|
], |
685
|
|
|
], |
686
|
|
|
], |
687
|
|
|
['eng-GB'], |
688
|
|
|
false, |
689
|
|
|
false, |
690
|
|
|
317, |
691
|
|
|
'10-17a197f4bbe127c368b889a67effd1b3', |
692
|
|
|
], |
693
|
|
|
]; |
694
|
|
|
} |
695
|
|
|
|
696
|
|
|
/** |
697
|
|
|
* Test for the lookup() method. |
698
|
|
|
* |
699
|
|
|
* Testing that UrlAlias is found and has expected state. |
700
|
|
|
* |
701
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::lookup |
702
|
|
|
* @dataProvider providerForTestLookupCustomLocationUrlAlias |
703
|
|
|
* @depends testLookup |
704
|
|
|
* @group location |
705
|
|
|
* @group custom |
706
|
|
|
*/ |
707
|
|
View Code Duplication |
public function testLookupCustomLocationUrlAlias( |
708
|
|
|
$url, |
709
|
|
|
array $pathData, |
710
|
|
|
array $languageCodes, |
711
|
|
|
$forward, |
712
|
|
|
$alwaysAvailable, |
713
|
|
|
$destination, |
714
|
|
|
$id |
715
|
|
|
) { |
716
|
|
|
$handler = $this->getHandler(); |
717
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_location_custom.php'); |
718
|
|
|
|
719
|
|
|
$urlAlias = $handler->lookup($url); |
720
|
|
|
self::assertInstanceOf(UrlAlias::class, $urlAlias); |
721
|
|
|
self::assertEquals( |
722
|
|
|
new UrlAlias( |
723
|
|
|
[ |
724
|
|
|
'id' => $id, |
725
|
|
|
'type' => UrlAlias::LOCATION, |
726
|
|
|
'destination' => $destination, |
727
|
|
|
'languageCodes' => $languageCodes, |
728
|
|
|
'pathData' => $pathData, |
729
|
|
|
'alwaysAvailable' => $alwaysAvailable, |
730
|
|
|
'isHistory' => false, |
731
|
|
|
'isCustom' => true, |
732
|
|
|
'forward' => $forward, |
733
|
|
|
] |
734
|
|
|
), |
735
|
|
|
$urlAlias |
736
|
|
|
); |
737
|
|
|
} |
738
|
|
|
|
739
|
|
|
/** |
740
|
|
|
* Test for the lookup() method. |
741
|
|
|
* |
742
|
|
|
* Testing that UrlAlias is found and has expected state. |
743
|
|
|
* |
744
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::lookup |
745
|
|
|
* @dataProvider providerForTestLookupCustomLocationUrlAlias |
746
|
|
|
* @depends testLookup |
747
|
|
|
* @group location |
748
|
|
|
* @group custom |
749
|
|
|
*/ |
750
|
|
View Code Duplication |
public function testLookupCustomLocationUrlAliasCaseCorrection( |
751
|
|
|
$url, |
752
|
|
|
array $pathData, |
753
|
|
|
array $languageCodes, |
754
|
|
|
$forward, |
755
|
|
|
$alwaysAvailable, |
756
|
|
|
$destination, |
757
|
|
|
$id |
758
|
|
|
) { |
759
|
|
|
$handler = $this->getHandler(); |
760
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_location_custom.php'); |
761
|
|
|
|
762
|
|
|
$urlAlias = $handler->lookup(strtoupper($url)); |
763
|
|
|
|
764
|
|
|
self::assertInstanceOf(UrlAlias::class, $urlAlias); |
765
|
|
|
self::assertEquals( |
766
|
|
|
new UrlAlias( |
767
|
|
|
[ |
768
|
|
|
'id' => $id, |
769
|
|
|
'type' => UrlAlias::LOCATION, |
770
|
|
|
'destination' => $destination, |
771
|
|
|
'languageCodes' => $languageCodes, |
772
|
|
|
'pathData' => $pathData, |
773
|
|
|
'alwaysAvailable' => $alwaysAvailable, |
774
|
|
|
'isHistory' => false, |
775
|
|
|
'isCustom' => true, |
776
|
|
|
'forward' => $forward, |
777
|
|
|
] |
778
|
|
|
), |
779
|
|
|
$urlAlias |
780
|
|
|
); |
781
|
|
|
} |
782
|
|
|
|
783
|
|
|
public function providerForTestLookupVirtualUrlAlias() |
784
|
|
|
{ |
785
|
|
|
return [ |
786
|
|
|
[ |
787
|
|
|
'hello/and', |
788
|
|
|
'6-be5d5d37542d75f93a87094459f76678', |
789
|
|
|
], |
790
|
|
|
[ |
791
|
|
|
'HELLO/AND', |
792
|
|
|
'6-be5d5d37542d75f93a87094459f76678', |
793
|
|
|
], |
794
|
|
|
]; |
795
|
|
|
} |
796
|
|
|
|
797
|
|
|
/** |
798
|
|
|
* Test for the lookup() method. |
799
|
|
|
* |
800
|
|
|
* Testing that NOP action redirects to site root. |
801
|
|
|
* |
802
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::lookup |
803
|
|
|
* @dataProvider providerForTestLookupVirtualUrlAlias |
804
|
|
|
* @depends testLookup |
805
|
|
|
* @group virtual |
806
|
|
|
*/ |
807
|
|
View Code Duplication |
public function testLookupVirtualUrlAlias($url, $id) |
808
|
|
|
{ |
809
|
|
|
$handler = $this->getHandler(); |
810
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_location_custom.php'); |
811
|
|
|
|
812
|
|
|
$urlAlias = $handler->lookup($url); |
813
|
|
|
|
814
|
|
|
$this->assertVirtualUrlAliasValid($urlAlias, $id); |
815
|
|
|
} |
816
|
|
|
|
817
|
|
|
public function providerForTestLookupResourceUrlAlias() |
818
|
|
|
{ |
819
|
|
|
return [ |
820
|
|
|
[ |
821
|
|
|
'is-alive', |
822
|
|
|
[ |
823
|
|
|
[ |
824
|
|
|
'always-available' => true, |
825
|
|
|
'translations' => [ |
826
|
|
|
'eng-GB' => 'is-alive', |
827
|
|
|
], |
828
|
|
|
], |
829
|
|
|
], |
830
|
|
|
['eng-GB'], |
831
|
|
|
true, |
832
|
|
|
true, |
833
|
|
|
'ezinfo/isalive', |
834
|
|
|
'0-d003895fa282a14c8ec3eddf23ca4ca2', |
835
|
|
|
], |
836
|
|
|
[ |
837
|
|
|
'is-alive/then/search', |
838
|
|
|
[ |
839
|
|
|
[ |
840
|
|
|
'always-available' => true, |
841
|
|
|
'translations' => [ |
842
|
|
|
'eng-GB' => 'is-alive', |
843
|
|
|
], |
844
|
|
|
], |
845
|
|
|
[ |
846
|
|
|
'always-available' => true, |
847
|
|
|
'translations' => [ |
848
|
|
|
'always-available' => 'then', |
849
|
|
|
], |
850
|
|
|
], |
851
|
|
|
[ |
852
|
|
|
'always-available' => false, |
853
|
|
|
'translations' => [ |
854
|
|
|
'cro-HR' => 'search', |
855
|
|
|
], |
856
|
|
|
], |
857
|
|
|
], |
858
|
|
|
['cro-HR'], |
859
|
|
|
false, |
860
|
|
|
false, |
861
|
|
|
'content/search', |
862
|
|
|
'3-06a943c59f33a34bb5924aaf72cd2995', |
863
|
|
|
], |
864
|
|
|
]; |
865
|
|
|
} |
866
|
|
|
|
867
|
|
|
/** |
868
|
|
|
* Test for the lookup() method. |
869
|
|
|
* |
870
|
|
|
* Testing that UrlAlias is found and has expected state. |
871
|
|
|
* |
872
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::lookup |
873
|
|
|
* @dataProvider providerForTestLookupResourceUrlAlias |
874
|
|
|
* @depends testLookup |
875
|
|
|
* @group resource |
876
|
|
|
*/ |
877
|
|
View Code Duplication |
public function testLookupResourceUrlAlias( |
878
|
|
|
$url, |
879
|
|
|
$pathData, |
880
|
|
|
array $languageCodes, |
881
|
|
|
$forward, |
882
|
|
|
$alwaysAvailable, |
883
|
|
|
$destination, |
884
|
|
|
$id |
885
|
|
|
) { |
886
|
|
|
$handler = $this->getHandler(); |
887
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_resource.php'); |
888
|
|
|
|
889
|
|
|
$urlAlias = $handler->lookup($url); |
890
|
|
|
|
891
|
|
|
self::assertInstanceOf(UrlAlias::class, $urlAlias); |
892
|
|
|
self::assertEquals( |
893
|
|
|
new UrlAlias( |
894
|
|
|
[ |
895
|
|
|
'id' => $id, |
896
|
|
|
'type' => UrlAlias::RESOURCE, |
897
|
|
|
'destination' => $destination, |
898
|
|
|
'languageCodes' => $languageCodes, |
899
|
|
|
'pathData' => $pathData, |
900
|
|
|
'alwaysAvailable' => $alwaysAvailable, |
901
|
|
|
'isHistory' => false, |
902
|
|
|
'isCustom' => true, |
903
|
|
|
'forward' => $forward, |
904
|
|
|
] |
905
|
|
|
), |
906
|
|
|
$urlAlias |
907
|
|
|
); |
908
|
|
|
} |
909
|
|
|
|
910
|
|
|
/** |
911
|
|
|
* Test for the lookup() method. |
912
|
|
|
* |
913
|
|
|
* Testing that UrlAlias is found and has expected state. |
914
|
|
|
* |
915
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::lookup |
916
|
|
|
* @dataProvider providerForTestLookupResourceUrlAlias |
917
|
|
|
* @depends testLookup |
918
|
|
|
* @group resource |
919
|
|
|
*/ |
920
|
|
View Code Duplication |
public function testLookupResourceUrlAliasCaseInsensitive( |
921
|
|
|
$url, |
922
|
|
|
$pathData, |
923
|
|
|
array $languageCodes, |
924
|
|
|
$forward, |
925
|
|
|
$alwaysAvailable, |
926
|
|
|
$destination, |
927
|
|
|
$id |
928
|
|
|
) { |
929
|
|
|
$handler = $this->getHandler(); |
930
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_resource.php'); |
931
|
|
|
|
932
|
|
|
$urlAlias = $handler->lookup(strtoupper($url)); |
933
|
|
|
|
934
|
|
|
self::assertInstanceOf(UrlAlias::class, $urlAlias); |
935
|
|
|
self::assertEquals( |
936
|
|
|
new UrlAlias( |
937
|
|
|
[ |
938
|
|
|
'id' => $id, |
939
|
|
|
'type' => UrlAlias::RESOURCE, |
940
|
|
|
'destination' => $destination, |
941
|
|
|
'languageCodes' => $languageCodes, |
942
|
|
|
'pathData' => $pathData, |
943
|
|
|
'alwaysAvailable' => $alwaysAvailable, |
944
|
|
|
'isHistory' => false, |
945
|
|
|
'isCustom' => true, |
946
|
|
|
'forward' => $forward, |
947
|
|
|
] |
948
|
|
|
), |
949
|
|
|
$urlAlias |
950
|
|
|
); |
951
|
|
|
} |
952
|
|
|
|
953
|
|
|
/** |
954
|
|
|
* Test for the lookup() method with uppercase utf8 characters. |
955
|
|
|
* |
956
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::lookup |
957
|
|
|
* @depends testLookup |
958
|
|
|
*/ |
959
|
|
View Code Duplication |
public function testLookupUppercaseIri() |
960
|
|
|
{ |
961
|
|
|
$handler = $this->getHandler(); |
962
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_location_iri.php'); |
963
|
|
|
|
964
|
|
|
$urlAlias = $handler->lookup('΀'); |
965
|
|
|
self::assertInstanceOf(UrlAlias::class, $urlAlias); |
966
|
|
|
} |
967
|
|
|
|
968
|
|
|
protected function assertVirtualUrlAliasValid(UrlAlias $urlAlias, $id) |
969
|
|
|
{ |
970
|
|
|
self::assertInstanceOf(UrlAlias::class, $urlAlias); |
971
|
|
|
self::assertEquals($id, $urlAlias->id); |
972
|
|
|
self::assertEquals(UrlAlias::VIRTUAL, $urlAlias->type); |
973
|
|
|
/*self::assertEquals( |
974
|
|
|
new UrlAlias( |
975
|
|
|
array( |
976
|
|
|
"id" => $id, |
977
|
|
|
"type" => UrlAlias::VIRTUAL, |
978
|
|
|
"destination" => null, |
979
|
|
|
"languageCodes" => array(), |
980
|
|
|
"pathData" => null, |
981
|
|
|
"alwaysAvailable" => true, |
982
|
|
|
"isHistory" => true, |
983
|
|
|
"isCustom" => false, |
984
|
|
|
"forward" => false |
985
|
|
|
) |
986
|
|
|
), |
987
|
|
|
$urlAlias |
988
|
|
|
);*/ |
989
|
|
|
} |
990
|
|
|
|
991
|
|
|
/** |
992
|
|
|
* Test for the listURLAliasesForLocation() method. |
993
|
|
|
* |
994
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::listURLAliasesForLocation |
995
|
|
|
*/ |
996
|
|
|
public function testListURLAliasesForLocation() |
997
|
|
|
{ |
998
|
|
|
$handler = $this->getHandler(); |
999
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_location.php'); |
1000
|
|
|
|
1001
|
|
|
$urlAliases = $handler->listURLAliasesForLocation(315); |
1002
|
|
|
|
1003
|
|
|
self::assertEquals( |
1004
|
|
|
[ |
1005
|
|
|
new UrlAlias( |
1006
|
|
|
[ |
1007
|
|
|
'id' => '2-b8a9f715dbb64fd5c56e7783c6820a61', |
1008
|
|
|
'type' => UrlAlias::LOCATION, |
1009
|
|
|
'destination' => 315, |
1010
|
|
|
'languageCodes' => ['eng-GB'], |
1011
|
|
|
'pathData' => [ |
1012
|
|
|
[ |
1013
|
|
|
'always-available' => true, |
1014
|
|
|
'translations' => ['cro-HR' => 'jedan'], |
1015
|
|
|
], |
1016
|
|
|
[ |
1017
|
|
|
'always-available' => false, |
1018
|
|
|
'translations' => [ |
1019
|
|
|
'cro-HR' => 'dva', |
1020
|
|
|
'eng-GB' => 'two', |
1021
|
|
|
], |
1022
|
|
|
], |
1023
|
|
|
], |
1024
|
|
|
'alwaysAvailable' => false, |
1025
|
|
|
'isHistory' => false, |
1026
|
|
|
'isCustom' => false, |
1027
|
|
|
'forward' => false, |
1028
|
|
|
] |
1029
|
|
|
), |
1030
|
|
|
new UrlAlias( |
1031
|
|
|
[ |
1032
|
|
|
'id' => '2-c67ed9a09ab136fae610b6a087d82e21', |
1033
|
|
|
'type' => UrlAlias::LOCATION, |
1034
|
|
|
'destination' => 315, |
1035
|
|
|
'languageCodes' => ['cro-HR'], |
1036
|
|
|
'pathData' => [ |
1037
|
|
|
[ |
1038
|
|
|
'always-available' => true, |
1039
|
|
|
'translations' => ['cro-HR' => 'jedan'], |
1040
|
|
|
], |
1041
|
|
|
[ |
1042
|
|
|
'always-available' => false, |
1043
|
|
|
'translations' => [ |
1044
|
|
|
'cro-HR' => 'dva', |
1045
|
|
|
'eng-GB' => 'two', |
1046
|
|
|
], |
1047
|
|
|
], |
1048
|
|
|
], |
1049
|
|
|
'alwaysAvailable' => false, |
1050
|
|
|
'isHistory' => false, |
1051
|
|
|
'isCustom' => false, |
1052
|
|
|
'forward' => false, |
1053
|
|
|
] |
1054
|
|
|
), |
1055
|
|
|
], |
1056
|
|
|
$urlAliases |
1057
|
|
|
); |
1058
|
|
|
} |
1059
|
|
|
|
1060
|
|
|
/** |
1061
|
|
|
* Test for the publishUrlAliasForLocation() method. |
1062
|
|
|
* |
1063
|
|
|
* @todo document |
1064
|
|
|
* |
1065
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::publishUrlAliasForLocation |
1066
|
|
|
* @depends testLookupLocationUrlAlias |
1067
|
|
|
* @group publish |
1068
|
|
|
*/ |
1069
|
|
View Code Duplication |
public function testPublishUrlAliasForLocation() |
1070
|
|
|
{ |
1071
|
|
|
$handler = $this->getHandler(); |
1072
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/publish_base.php'); |
1073
|
|
|
|
1074
|
|
|
$handler->publishUrlAliasForLocation(314, 2, 'simple', 'eng-GB', true); |
1075
|
|
|
$publishedUrlAlias = $handler->lookup('simple'); |
1076
|
|
|
|
1077
|
|
|
self::assertEquals(4, $this->countRows()); |
1078
|
|
|
self::assertEquals( |
1079
|
|
|
new UrlAlias( |
1080
|
|
|
[ |
1081
|
|
|
'id' => '0-' . md5('simple'), |
1082
|
|
|
'type' => UrlAlias::LOCATION, |
1083
|
|
|
'destination' => 314, |
1084
|
|
|
'languageCodes' => ['eng-GB'], |
1085
|
|
|
'pathData' => [ |
1086
|
|
|
[ |
1087
|
|
|
'always-available' => true, |
1088
|
|
|
'translations' => [ |
1089
|
|
|
'eng-GB' => 'simple', |
1090
|
|
|
'cro-HR' => 'path314', |
1091
|
|
|
], |
1092
|
|
|
], |
1093
|
|
|
], |
1094
|
|
|
'alwaysAvailable' => true, |
1095
|
|
|
'isHistory' => false, |
1096
|
|
|
'isCustom' => false, |
1097
|
|
|
'forward' => false, |
1098
|
|
|
] |
1099
|
|
|
), |
1100
|
|
|
$publishedUrlAlias |
1101
|
|
|
); |
1102
|
|
|
} |
1103
|
|
|
|
1104
|
|
|
/** |
1105
|
|
|
* Test for the publishUrlAliasForLocation() method. |
1106
|
|
|
* |
1107
|
|
|
* @todo document |
1108
|
|
|
* |
1109
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::publishUrlAliasForLocation |
1110
|
|
|
* @depends testPublishUrlAliasForLocation |
1111
|
|
|
* @group publish |
1112
|
|
|
*/ |
1113
|
|
|
public function testPublishUrlAliasForLocationRepublish() |
1114
|
|
|
{ |
1115
|
|
|
$handler = $this->getHandler(); |
1116
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/publish_base.php'); |
1117
|
|
|
|
1118
|
|
|
$handler->publishUrlAliasForLocation(314, 2, 'simple', 'eng-GB', true); |
1119
|
|
|
$publishedUrlAlias = $handler->lookup('simple'); |
1120
|
|
|
$handler->publishUrlAliasForLocation(314, 2, 'simple', 'eng-GB', true); |
1121
|
|
|
$republishedUrlAlias = $handler->lookup('simple'); |
1122
|
|
|
|
1123
|
|
|
self::assertEquals(4, $this->countRows()); |
1124
|
|
|
self::assertEquals( |
1125
|
|
|
$publishedUrlAlias, |
1126
|
|
|
$republishedUrlAlias |
1127
|
|
|
); |
1128
|
|
|
} |
1129
|
|
|
|
1130
|
|
|
/** |
1131
|
|
|
* Test for the publishUrlAliasForLocation() method. |
1132
|
|
|
* |
1133
|
|
|
* @todo document |
1134
|
|
|
* |
1135
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::publishUrlAliasForLocation |
1136
|
|
|
* @depends testPublishUrlAliasForLocation |
1137
|
|
|
* @group publish |
1138
|
|
|
*/ |
1139
|
|
View Code Duplication |
public function testPublishUrlAliasCreatesUniqueAlias() |
1140
|
|
|
{ |
1141
|
|
|
$handler = $this->getHandler(); |
1142
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/publish_base.php'); |
1143
|
|
|
|
1144
|
|
|
$handler->publishUrlAliasForLocation(314, 2, 'simple', 'eng-GB', true); |
1145
|
|
|
$handler->publishUrlAliasForLocation(315, 2, 'simple', 'eng-GB', true); |
1146
|
|
|
self::assertEquals(5, $this->countRows()); |
1147
|
|
|
|
1148
|
|
|
$urlAlias = $handler->lookup('simple2'); |
1149
|
|
|
self::assertEquals( |
1150
|
|
|
new UrlAlias( |
1151
|
|
|
[ |
1152
|
|
|
'id' => '0-' . md5('simple2'), |
1153
|
|
|
'type' => UrlAlias::LOCATION, |
1154
|
|
|
'destination' => 315, |
1155
|
|
|
'languageCodes' => ['eng-GB'], |
1156
|
|
|
'pathData' => [ |
1157
|
|
|
[ |
1158
|
|
|
'always-available' => true, |
1159
|
|
|
'translations' => [ |
1160
|
|
|
'eng-GB' => 'simple2', |
1161
|
|
|
], |
1162
|
|
|
], |
1163
|
|
|
], |
1164
|
|
|
'alwaysAvailable' => true, |
1165
|
|
|
'isHistory' => false, |
1166
|
|
|
'isCustom' => false, |
1167
|
|
|
'forward' => false, |
1168
|
|
|
] |
1169
|
|
|
), |
1170
|
|
|
$urlAlias |
1171
|
|
|
); |
1172
|
|
|
} |
1173
|
|
|
|
1174
|
|
|
/** |
1175
|
|
|
* @return array |
1176
|
|
|
*/ |
1177
|
|
|
public function providerForTestPublishUrlAliasForLocationComplex() |
1178
|
|
|
{ |
1179
|
|
|
return $this->providerForTestLookupLocationUrlAlias(); |
1180
|
|
|
} |
1181
|
|
|
|
1182
|
|
|
/** |
1183
|
|
|
* Test for the publishUrlAliasForLocation() method. |
1184
|
|
|
* |
1185
|
|
|
* @todo document |
1186
|
|
|
* |
1187
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::publishUrlAliasForLocation |
1188
|
|
|
* @dataProvider providerForTestPublishUrlAliasForLocationComplex |
1189
|
|
|
* @depends testPublishUrlAliasForLocation |
1190
|
|
|
* @group publish |
1191
|
|
|
*/ |
1192
|
|
|
public function testPublishUrlAliasForLocationComplex( |
1193
|
|
|
$url, |
1194
|
|
|
$pathData, |
1195
|
|
|
array $languageCodes, |
1196
|
|
|
$alwaysAvailable, |
1197
|
|
|
$locationId, |
1198
|
|
|
$id |
1199
|
|
|
) { |
1200
|
|
|
$handler = $this->getHandler(); |
1201
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/publish_base.php'); |
1202
|
|
|
|
1203
|
|
|
$handler->publishUrlAliasForLocation(314, 2, 'jedan', 'cro-HR', true); |
1204
|
|
|
$handler->publishUrlAliasForLocation(315, 314, 'dva', 'cro-HR', false); |
1205
|
|
|
$handler->publishUrlAliasForLocation(315, 314, 'two', 'eng-GB', false); |
1206
|
|
|
$handler->publishUrlAliasForLocation(316, 315, 'tri', 'cro-HR', false); |
1207
|
|
|
$handler->publishUrlAliasForLocation(316, 315, 'three', 'eng-GB', false); |
1208
|
|
|
$handler->publishUrlAliasForLocation(316, 315, 'drei', 'ger-DE', false); |
1209
|
|
|
|
1210
|
|
|
$urlAlias = $handler->lookup($url); |
1211
|
|
|
|
1212
|
|
|
self::assertInstanceOf(UrlAlias::class, $urlAlias); |
1213
|
|
|
self::assertEquals( |
1214
|
|
|
new UrlAlias( |
1215
|
|
|
[ |
1216
|
|
|
'id' => $id, |
1217
|
|
|
'type' => UrlAlias::LOCATION, |
1218
|
|
|
'destination' => $locationId, |
1219
|
|
|
'languageCodes' => $languageCodes, |
1220
|
|
|
'pathData' => $pathData, |
1221
|
|
|
'alwaysAvailable' => $alwaysAvailable, |
1222
|
|
|
'isHistory' => false, |
1223
|
|
|
'isCustom' => false, |
1224
|
|
|
'forward' => false, |
1225
|
|
|
] |
1226
|
|
|
), |
1227
|
|
|
$urlAlias |
1228
|
|
|
); |
1229
|
|
|
} |
1230
|
|
|
|
1231
|
|
|
/** |
1232
|
|
|
* Test for the publishUrlAliasForLocation() method. |
1233
|
|
|
* |
1234
|
|
|
* @todo document |
1235
|
|
|
* |
1236
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::publishUrlAliasForLocation |
1237
|
|
|
* @depends testPublishUrlAliasForLocation |
1238
|
|
|
* @group publish |
1239
|
|
|
*/ |
1240
|
|
|
public function testPublishUrlAliasForLocationSameAliasForMultipleLanguages() |
1241
|
|
|
{ |
1242
|
|
|
$handler = $this->getHandler(); |
1243
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/publish_base.php'); |
1244
|
|
|
|
1245
|
|
|
$handler->publishUrlAliasForLocation(314, 2, 'jedan', 'cro-HR', false); |
1246
|
|
|
$urlAlias1 = $handler->lookup('jedan'); |
1247
|
|
|
$handler->publishUrlAliasForLocation(314, 2, 'jedan', 'eng-GB', false); |
1248
|
|
|
$urlAlias2 = $handler->lookup('jedan'); |
1249
|
|
|
|
1250
|
|
|
self::assertEquals(4, $this->countRows()); |
1251
|
|
|
|
1252
|
|
|
foreach ($urlAlias2 as $propertyName => $propertyValue) { |
|
|
|
|
1253
|
|
|
if ($propertyName === 'languageCodes') { |
1254
|
|
|
self::assertEquals( |
1255
|
|
|
['cro-HR', 'eng-GB'], |
1256
|
|
|
$urlAlias2->languageCodes |
1257
|
|
|
); |
1258
|
|
|
} elseif ($propertyName === 'pathData') { |
1259
|
|
|
self::assertEquals( |
1260
|
|
|
[ |
1261
|
|
|
[ |
1262
|
|
|
'always-available' => false, |
1263
|
|
|
'translations' => [ |
1264
|
|
|
'cro-HR' => 'jedan', |
1265
|
|
|
'eng-GB' => 'jedan', |
1266
|
|
|
], |
1267
|
|
|
], |
1268
|
|
|
], |
1269
|
|
|
$urlAlias2->pathData |
1270
|
|
|
); |
1271
|
|
|
} else { |
1272
|
|
|
self::assertEquals( |
1273
|
|
|
$urlAlias1->$propertyName, |
1274
|
|
|
$urlAlias2->$propertyName |
1275
|
|
|
); |
1276
|
|
|
} |
1277
|
|
|
} |
1278
|
|
|
} |
1279
|
|
|
|
1280
|
|
|
/** |
1281
|
|
|
* Test for the publishUrlAliasForLocation() method. |
1282
|
|
|
* |
1283
|
|
|
* @todo document |
1284
|
|
|
* |
1285
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::publishUrlAliasForLocation |
1286
|
|
|
* @depends testPublishUrlAliasForLocation |
1287
|
|
|
* @group publish |
1288
|
|
|
*/ |
1289
|
|
|
public function testPublishUrlAliasForLocationDowngradesOldEntryToHistory() |
1290
|
|
|
{ |
1291
|
|
|
$handler = $this->getHandler(); |
1292
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/publish_base.php'); |
1293
|
|
|
|
1294
|
|
|
$handler->publishUrlAliasForLocation(314, 2, 'jedan', 'cro-HR', false); |
1295
|
|
|
$handler->publishUrlAliasForLocation(314, 2, 'dva', 'cro-HR', true); |
1296
|
|
|
|
1297
|
|
|
self::assertEquals(5, $this->countRows()); |
1298
|
|
|
|
1299
|
|
|
$newUrlAlias = $handler->lookup('dva'); |
1300
|
|
|
|
1301
|
|
|
self::assertEquals( |
1302
|
|
|
new UrlAlias( |
1303
|
|
|
[ |
1304
|
|
|
'id' => '0-c67ed9a09ab136fae610b6a087d82e21', |
1305
|
|
|
'type' => 0, |
1306
|
|
|
'destination' => 314, |
1307
|
|
|
'languageCodes' => ['cro-HR'], |
1308
|
|
|
'pathData' => [ |
1309
|
|
|
[ |
1310
|
|
|
'always-available' => true, |
1311
|
|
|
'translations' => [ |
1312
|
|
|
'cro-HR' => 'dva', |
1313
|
|
|
], |
1314
|
|
|
], |
1315
|
|
|
], |
1316
|
|
|
'alwaysAvailable' => true, |
1317
|
|
|
'isHistory' => false, |
1318
|
|
|
'isCustom' => false, |
1319
|
|
|
'forward' => false, |
1320
|
|
|
] |
1321
|
|
|
), |
1322
|
|
|
$newUrlAlias |
1323
|
|
|
); |
1324
|
|
|
|
1325
|
|
|
$historyUrlAlias = $handler->lookup('jedan'); |
1326
|
|
|
|
1327
|
|
|
self::assertEquals( |
1328
|
|
|
new UrlAlias( |
1329
|
|
|
[ |
1330
|
|
|
'id' => '0-6896260129051a949051c3847c34466f', |
1331
|
|
|
'type' => 0, |
1332
|
|
|
'destination' => 314, |
1333
|
|
|
'languageCodes' => ['cro-HR'], |
1334
|
|
|
'pathData' => [ |
1335
|
|
|
[ |
1336
|
|
|
'always-available' => false, |
1337
|
|
|
'translations' => [ |
1338
|
|
|
'cro-HR' => 'jedan', |
1339
|
|
|
], |
1340
|
|
|
], |
1341
|
|
|
], |
1342
|
|
|
'alwaysAvailable' => false, |
1343
|
|
|
'isHistory' => true, |
1344
|
|
|
'isCustom' => false, |
1345
|
|
|
'forward' => false, |
1346
|
|
|
] |
1347
|
|
|
), |
1348
|
|
|
$historyUrlAlias |
1349
|
|
|
); |
1350
|
|
|
} |
1351
|
|
|
|
1352
|
|
|
/** |
1353
|
|
|
* Test for the publishUrlAliasForLocation() method. |
1354
|
|
|
* |
1355
|
|
|
* @todo document |
1356
|
|
|
* |
1357
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::publishUrlAliasForLocation |
1358
|
|
|
* @depends testPublishUrlAliasForLocation |
1359
|
|
|
* @depends testPublishUrlAliasForLocationSameAliasForMultipleLanguages |
1360
|
|
|
* @group publish |
1361
|
|
|
* @group downgrade |
1362
|
|
|
*/ |
1363
|
|
|
public function testPublishUrlAliasForLocationDowngradesOldEntryRemovesLanguage() |
1364
|
|
|
{ |
1365
|
|
|
$handler = $this->getHandler(); |
1366
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/publish_base.php'); |
1367
|
|
|
|
1368
|
|
|
$handler->publishUrlAliasForLocation(314, 2, 'jedan', 'cro-HR'); |
1369
|
|
|
$handler->publishUrlAliasForLocation(314, 2, 'jedan', 'eng-GB'); |
1370
|
|
|
$handler->publishUrlAliasForLocation(314, 2, 'dva', 'eng-GB'); |
1371
|
|
|
|
1372
|
|
|
self::assertEquals(5, $this->countRows()); |
1373
|
|
|
|
1374
|
|
|
$urlAlias = $handler->lookup('dva'); |
1375
|
|
|
self::assertEquals( |
1376
|
|
|
new UrlAlias( |
1377
|
|
|
[ |
1378
|
|
|
'id' => '0-c67ed9a09ab136fae610b6a087d82e21', |
1379
|
|
|
'type' => UrlAlias::LOCATION, |
1380
|
|
|
'destination' => 314, |
1381
|
|
|
'languageCodes' => ['eng-GB'], |
1382
|
|
|
'pathData' => [ |
1383
|
|
|
[ |
1384
|
|
|
'always-available' => false, |
1385
|
|
|
'translations' => [ |
1386
|
|
|
'cro-HR' => 'jedan', |
1387
|
|
|
'eng-GB' => 'dva', |
1388
|
|
|
], |
1389
|
|
|
], |
1390
|
|
|
], |
1391
|
|
|
'alwaysAvailable' => false, |
1392
|
|
|
'isHistory' => false, |
1393
|
|
|
'isCustom' => false, |
1394
|
|
|
'forward' => false, |
1395
|
|
|
] |
1396
|
|
|
), |
1397
|
|
|
$urlAlias |
1398
|
|
|
); |
1399
|
|
|
|
1400
|
|
|
$downgradedUrlAlias = $handler->lookup('jedan'); |
1401
|
|
|
self::assertEquals( |
1402
|
|
|
new UrlAlias( |
1403
|
|
|
[ |
1404
|
|
|
'id' => '0-6896260129051a949051c3847c34466f', |
1405
|
|
|
'type' => UrlAlias::LOCATION, |
1406
|
|
|
'destination' => 314, |
1407
|
|
|
'languageCodes' => ['cro-HR'], |
1408
|
|
|
'pathData' => [ |
1409
|
|
|
[ |
1410
|
|
|
'always-available' => false, |
1411
|
|
|
'translations' => [ |
1412
|
|
|
'cro-HR' => 'jedan', |
1413
|
|
|
'eng-GB' => 'dva', |
1414
|
|
|
], |
1415
|
|
|
], |
1416
|
|
|
], |
1417
|
|
|
'alwaysAvailable' => false, |
1418
|
|
|
'isHistory' => false, |
1419
|
|
|
'isCustom' => false, |
1420
|
|
|
'forward' => false, |
1421
|
|
|
] |
1422
|
|
|
), |
1423
|
|
|
$downgradedUrlAlias |
1424
|
|
|
); |
1425
|
|
|
} |
1426
|
|
|
|
1427
|
|
|
/** |
1428
|
|
|
* Test for the publishUrlAliasForLocation() method. |
1429
|
|
|
* |
1430
|
|
|
* @todo document |
1431
|
|
|
* |
1432
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::publishUrlAliasForLocation |
1433
|
|
|
* @depends testPublishUrlAliasForLocation |
1434
|
|
|
* @depends testPublishUrlAliasForLocationDowngradesOldEntryToHistory |
1435
|
|
|
* @group publish |
1436
|
|
|
*/ |
1437
|
|
|
public function testPublishUrlAliasForLocationReusesHistory() |
1438
|
|
|
{ |
1439
|
|
|
$handler = $this->getHandler(); |
1440
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/publish_base.php'); |
1441
|
|
|
|
1442
|
|
|
$handler->publishUrlAliasForLocation(314, 2, 'jedan', 'cro-HR'); |
1443
|
|
|
$urlAlias = $handler->lookup('jedan'); |
1444
|
|
|
$handler->publishUrlAliasForLocation(314, 2, 'dva', 'cro-HR'); |
1445
|
|
|
$countBeforeReusing = $this->countRows(); |
1446
|
|
|
$handler->publishUrlAliasForLocation(314, 2, 'jedan', 'cro-HR'); |
1447
|
|
|
$urlAliasReusesHistory = $handler->lookup('jedan'); |
1448
|
|
|
|
1449
|
|
|
self::assertEquals( |
1450
|
|
|
$countBeforeReusing, |
1451
|
|
|
$this->countRows() |
1452
|
|
|
); |
1453
|
|
|
|
1454
|
|
|
self::assertEquals( |
1455
|
|
|
$urlAlias, |
1456
|
|
|
$urlAliasReusesHistory |
1457
|
|
|
); |
1458
|
|
|
} |
1459
|
|
|
|
1460
|
|
|
/** |
1461
|
|
|
* Test for the publishUrlAliasForLocation() method. |
1462
|
|
|
* |
1463
|
|
|
* @todo document |
1464
|
|
|
* |
1465
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::publishUrlAliasForLocation |
1466
|
|
|
* @depends testPublishUrlAliasForLocation |
1467
|
|
|
* @depends testPublishUrlAliasForLocationDowngradesOldEntryToHistory |
1468
|
|
|
* @group publish |
1469
|
|
|
*/ |
1470
|
|
|
public function testPublishUrlAliasForLocationReusesHistoryOfDifferentLanguage() |
1471
|
|
|
{ |
1472
|
|
|
$handler = $this->getHandler(); |
1473
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/publish_base.php'); |
1474
|
|
|
|
1475
|
|
|
$handler->publishUrlAliasForLocation(314, 2, 'jedan', 'cro-HR'); |
1476
|
|
|
$handler->publishUrlAliasForLocation(314, 2, 'one-history', 'eng-GB'); |
1477
|
|
|
$handler->publishUrlAliasForLocation(314, 2, 'one-new', 'eng-GB'); |
1478
|
|
|
$countBeforeReusing = $this->countRows(); |
1479
|
|
|
$handler->publishUrlAliasForLocation(314, 2, 'one-history', 'cro-HR'); |
1480
|
|
|
$urlAliasReusesHistory = $handler->lookup('one-history'); |
1481
|
|
|
|
1482
|
|
|
self::assertEquals( |
1483
|
|
|
$countBeforeReusing, |
1484
|
|
|
$this->countRows() |
1485
|
|
|
); |
1486
|
|
|
|
1487
|
|
|
self::assertEquals( |
1488
|
|
|
new UrlAlias( |
1489
|
|
|
[ |
1490
|
|
|
'id' => '0-' . md5('one-history'), |
1491
|
|
|
'type' => UrlAlias::LOCATION, |
1492
|
|
|
'destination' => 314, |
1493
|
|
|
'languageCodes' => ['cro-HR'], |
1494
|
|
|
'pathData' => [ |
1495
|
|
|
[ |
1496
|
|
|
'always-available' => false, |
1497
|
|
|
'translations' => [ |
1498
|
|
|
'cro-HR' => 'one-history', |
1499
|
|
|
'eng-GB' => 'one-new', |
1500
|
|
|
], |
1501
|
|
|
], |
1502
|
|
|
], |
1503
|
|
|
'alwaysAvailable' => false, |
1504
|
|
|
'isHistory' => false, |
1505
|
|
|
'isCustom' => false, |
1506
|
|
|
'forward' => false, |
1507
|
|
|
] |
1508
|
|
|
), |
1509
|
|
|
$urlAliasReusesHistory |
1510
|
|
|
); |
1511
|
|
|
} |
1512
|
|
|
|
1513
|
|
|
/** |
1514
|
|
|
* Test for the publishUrlAliasForLocation() method. |
1515
|
|
|
* |
1516
|
|
|
* @todo document |
1517
|
|
|
* |
1518
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::publishUrlAliasForLocation |
1519
|
|
|
* @depends testPublishUrlAliasForLocation |
1520
|
|
|
* @group publish |
1521
|
|
|
*/ |
1522
|
|
View Code Duplication |
public function testPublishUrlAliasForLocationReusesCustomAlias() |
1523
|
|
|
{ |
1524
|
|
|
$handler = $this->getHandler(); |
1525
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_reusing.php'); |
1526
|
|
|
|
1527
|
|
|
$countBeforeReusing = $this->countRows(); |
1528
|
|
|
$handler->publishUrlAliasForLocation(314, 2, 'custom-hello', 'eng-GB', false); |
1529
|
|
|
$urlAlias = $handler->lookup('custom-hello'); |
1530
|
|
|
|
1531
|
|
|
self::assertEquals( |
1532
|
|
|
$countBeforeReusing, |
1533
|
|
|
$this->countRows() |
1534
|
|
|
); |
1535
|
|
|
self::assertFalse($urlAlias->isCustom); |
1536
|
|
|
} |
1537
|
|
|
|
1538
|
|
|
/** |
1539
|
|
|
* Test for the publishUrlAliasForLocation() method. |
1540
|
|
|
* |
1541
|
|
|
* @todo document |
1542
|
|
|
* |
1543
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::publishUrlAliasForLocation |
1544
|
|
|
* @depends testPublishUrlAliasForLocation |
1545
|
|
|
*/ |
1546
|
|
|
public function testPublishUrlAliasForLocationReusingNopElement() |
1547
|
|
|
{ |
1548
|
|
|
$handler = $this->getHandler(); |
1549
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_reusing.php'); |
1550
|
|
|
|
1551
|
|
|
$countBeforeReusing = $this->countRows(); |
1552
|
|
|
$virtualUrlAlias = $handler->lookup('nop-element/search'); |
1553
|
|
|
$handler->publishUrlAliasForLocation(315, 2, 'nop-element', 'eng-GB', false); |
1554
|
|
|
$publishedLocationUrlAlias = $handler->lookup('nop-element'); |
1555
|
|
|
|
1556
|
|
|
self::assertEquals( |
1557
|
|
|
$countBeforeReusing, |
1558
|
|
|
$this->countRows() |
1559
|
|
|
); |
1560
|
|
|
|
1561
|
|
|
self::assertInstanceOf(UrlAlias::class, $publishedLocationUrlAlias); |
1562
|
|
|
self::assertEquals( |
1563
|
|
|
new UrlAlias( |
1564
|
|
|
[ |
1565
|
|
|
'id' => '0-de55c2fff721217cc4cb67b58dc35f85', |
1566
|
|
|
'type' => UrlAlias::LOCATION, |
1567
|
|
|
'destination' => 315, |
1568
|
|
|
'languageCodes' => ['eng-GB'], |
1569
|
|
|
'pathData' => [ |
1570
|
|
|
[ |
1571
|
|
|
'always-available' => false, |
1572
|
|
|
'translations' => ['eng-GB' => 'nop-element'], |
1573
|
|
|
], |
1574
|
|
|
], |
1575
|
|
|
'alwaysAvailable' => false, |
1576
|
|
|
'isHistory' => false, |
1577
|
|
|
'isCustom' => false, |
1578
|
|
|
'forward' => false, |
1579
|
|
|
] |
1580
|
|
|
), |
1581
|
|
|
$publishedLocationUrlAlias |
1582
|
|
|
); |
1583
|
|
|
|
1584
|
|
|
$virtualUrlAliasReloaded = $handler->lookup('nop-element/search'); |
1585
|
|
View Code Duplication |
foreach ($virtualUrlAliasReloaded as $propertyName => $propertyValue) { |
|
|
|
|
1586
|
|
|
if ($propertyName === 'pathData') { |
1587
|
|
|
self::assertEquals( |
1588
|
|
|
[ |
1589
|
|
|
[ |
1590
|
|
|
'always-available' => false, |
1591
|
|
|
'translations' => ['eng-GB' => 'nop-element'], |
1592
|
|
|
], |
1593
|
|
|
[ |
1594
|
|
|
'always-available' => false, |
1595
|
|
|
'translations' => ['eng-GB' => 'search'], |
1596
|
|
|
], |
1597
|
|
|
], |
1598
|
|
|
$virtualUrlAliasReloaded->pathData |
1599
|
|
|
); |
1600
|
|
|
} else { |
1601
|
|
|
self::assertEquals( |
1602
|
|
|
$virtualUrlAlias->$propertyName, |
1603
|
|
|
$virtualUrlAliasReloaded->$propertyName |
1604
|
|
|
); |
1605
|
|
|
} |
1606
|
|
|
} |
1607
|
|
|
} |
1608
|
|
|
|
1609
|
|
|
/** |
1610
|
|
|
* Test for the publishUrlAliasForLocation() method. |
1611
|
|
|
* |
1612
|
|
|
* @todo document |
1613
|
|
|
* |
1614
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::publishUrlAliasForLocation |
1615
|
|
|
* @depends testPublishUrlAliasForLocation |
1616
|
|
|
* @depends testPublishUrlAliasForLocationReusingNopElement |
1617
|
|
|
*/ |
1618
|
|
|
public function testPublishUrlAliasForLocationReusingNopElementChangesCustomPath() |
1619
|
|
|
{ |
1620
|
|
|
$handler = $this->getHandler(); |
1621
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_reusing.php'); |
1622
|
|
|
|
1623
|
|
|
$countBeforeReusing = $this->countRows(); |
1624
|
|
|
$virtualUrlAlias = $handler->lookup('nop-element/search'); |
1625
|
|
|
$handler->publishUrlAliasForLocation(315, 2, 'nop-element', 'eng-GB', false); |
1626
|
|
|
$handler->publishUrlAliasForLocation(315, 2, 'nop-element-renamed', 'eng-GB', false); |
1627
|
|
|
$virtualUrlAliasChanged = $handler->lookup('nop-element-renamed/search'); |
1628
|
|
|
|
1629
|
|
|
self::assertEquals( |
1630
|
|
|
$countBeforeReusing + 1, |
1631
|
|
|
$this->countRows() |
1632
|
|
|
); |
1633
|
|
|
|
1634
|
|
View Code Duplication |
foreach ($virtualUrlAliasChanged as $propertyName => $propertyValue) { |
|
|
|
|
1635
|
|
|
if ($propertyName === 'pathData') { |
1636
|
|
|
self::assertEquals( |
1637
|
|
|
[ |
1638
|
|
|
[ |
1639
|
|
|
'always-available' => false, |
1640
|
|
|
'translations' => ['eng-GB' => 'nop-element-renamed'], |
1641
|
|
|
], |
1642
|
|
|
[ |
1643
|
|
|
'always-available' => false, |
1644
|
|
|
'translations' => ['eng-GB' => 'search'], |
1645
|
|
|
], |
1646
|
|
|
], |
1647
|
|
|
$virtualUrlAliasChanged->pathData |
1648
|
|
|
); |
1649
|
|
|
} else { |
1650
|
|
|
self::assertEquals( |
1651
|
|
|
$virtualUrlAlias->$propertyName, |
1652
|
|
|
$virtualUrlAliasChanged->$propertyName |
1653
|
|
|
); |
1654
|
|
|
} |
1655
|
|
|
} |
1656
|
|
|
} |
1657
|
|
|
|
1658
|
|
|
/** |
1659
|
|
|
* Test for the publishUrlAliasForLocation() method. |
1660
|
|
|
* |
1661
|
|
|
* @todo document |
1662
|
|
|
* |
1663
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::publishUrlAliasForLocation |
1664
|
|
|
* @depends testPublishUrlAliasForLocation |
1665
|
|
|
* @depends testPublishUrlAliasForLocationReusingNopElementChangesCustomPath |
1666
|
|
|
*/ |
1667
|
|
|
public function testPublishUrlAliasForLocationReusingNopElementChangesCustomPathAndCreatesHistory() |
1668
|
|
|
{ |
1669
|
|
|
$handler = $this->getHandler(); |
1670
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_reusing.php'); |
1671
|
|
|
|
1672
|
|
|
$handler->publishUrlAliasForLocation(315, 2, 'nop-element', 'eng-GB', false); |
1673
|
|
|
$handler->publishUrlAliasForLocation(315, 2, 'nop-element-renamed', 'eng-GB', false); |
1674
|
|
|
|
1675
|
|
|
$customUrlAliasChanged = $handler->lookup('nop-element-renamed/search'); |
1676
|
|
|
$customUrlAliasHistory = $handler->lookup('nop-element/search'); |
1677
|
|
|
|
1678
|
|
|
self::assertTrue($customUrlAliasHistory->isHistory); |
1679
|
|
|
$customUrlAliasHistory->isHistory = false; |
1680
|
|
|
self::assertEquals( |
1681
|
|
|
$customUrlAliasChanged, |
1682
|
|
|
$customUrlAliasHistory |
1683
|
|
|
); |
1684
|
|
|
} |
1685
|
|
|
|
1686
|
|
|
/** |
1687
|
|
|
* Test for the publishUrlAliasForLocation() method. |
1688
|
|
|
* |
1689
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::publishUrlAliasForLocation |
1690
|
|
|
*/ |
1691
|
|
|
public function testPublishUrlAliasForLocationUpdatesLocationPathIdentificationString() |
1692
|
|
|
{ |
1693
|
|
|
$handler = $this->getHandler(); |
1694
|
|
|
$locationGateway = $this->getLocationGateway(); |
1695
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/publish_base.php'); |
1696
|
|
|
|
1697
|
|
|
// Publishes the alias indicating that language is main, triggering updating of path_identification_string |
1698
|
|
|
$handler->publishUrlAliasForLocation(316, 315, 'TEST TEST TEST', 'eng-GB', false, true); |
1699
|
|
|
|
1700
|
|
|
$locationData = $locationGateway->getBasicNodeData(316); |
1701
|
|
|
|
1702
|
|
|
self::assertEquals('path314/path315/test_test_test', $locationData['path_identification_string']); |
1703
|
|
|
} |
1704
|
|
|
|
1705
|
|
|
/** |
1706
|
|
|
* Test for the publishUrlAliasForLocation() method. |
1707
|
|
|
* |
1708
|
|
|
* @group cleanup |
1709
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::publishUrlAliasForLocation |
1710
|
|
|
*/ |
1711
|
|
|
public function testPublishUrlAliasReuseNopCleanupCustomAliasIsDestroyed() |
1712
|
|
|
{ |
1713
|
|
|
$handler = $this->getHandler(); |
1714
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_cleanup_nop.php'); |
1715
|
|
|
|
1716
|
|
|
$handler->lookup('nop-element/search'); |
1717
|
|
|
$handler->publishUrlAliasForLocation(314, 2, 'nop-element', 'cro-HR', false); |
1718
|
|
|
|
1719
|
|
|
$urlAlias = $handler->lookup('jedan'); |
1720
|
|
|
$this->assertEquals( |
1721
|
|
|
new UrlAlias( |
1722
|
|
|
[ |
1723
|
|
|
'id' => '0-' . md5('jedan'), |
1724
|
|
|
'type' => UrlAlias::LOCATION, |
1725
|
|
|
'destination' => 314, |
1726
|
|
|
'pathData' => [ |
1727
|
|
|
[ |
1728
|
|
|
'always-available' => false, |
1729
|
|
|
'translations' => ['cro-HR' => 'jedan'], |
1730
|
|
|
], |
1731
|
|
|
], |
1732
|
|
|
'languageCodes' => ['cro-HR'], |
1733
|
|
|
'alwaysAvailable' => false, |
1734
|
|
|
'isHistory' => true, |
1735
|
|
|
'isCustom' => false, |
1736
|
|
|
'forward' => false, |
1737
|
|
|
] |
1738
|
|
|
), |
1739
|
|
|
$urlAlias |
1740
|
|
|
); |
1741
|
|
|
|
1742
|
|
|
$urlAlias = $handler->lookup('nop-element'); |
1743
|
|
|
$this->assertEquals( |
1744
|
|
|
new UrlAlias( |
1745
|
|
|
[ |
1746
|
|
|
'id' => '0-' . md5('nop-element'), |
1747
|
|
|
'type' => UrlAlias::LOCATION, |
1748
|
|
|
'destination' => 314, |
1749
|
|
|
'pathData' => [ |
1750
|
|
|
[ |
1751
|
|
|
'always-available' => false, |
1752
|
|
|
'translations' => [ |
1753
|
|
|
'cro-HR' => 'nop-element', |
1754
|
|
|
'eng-GB' => 'dva', |
1755
|
|
|
], |
1756
|
|
|
], |
1757
|
|
|
], |
1758
|
|
|
'languageCodes' => [ |
1759
|
|
|
'cro-HR', |
1760
|
|
|
], |
1761
|
|
|
'alwaysAvailable' => false, |
1762
|
|
|
'isHistory' => false, |
1763
|
|
|
'isCustom' => false, |
1764
|
|
|
'forward' => false, |
1765
|
|
|
] |
1766
|
|
|
), |
1767
|
|
|
$urlAlias |
1768
|
|
|
); |
1769
|
|
|
|
1770
|
|
|
try { |
1771
|
|
|
$handler->lookup('nop-element/search'); |
1772
|
|
|
$this->fail('Custom alias is not destroyed'); |
1773
|
|
|
} catch (NotFoundException $e) { |
1774
|
|
|
// Custom alias is destroyed by reusing NOP entry with existing autogenerated alias |
1775
|
|
|
// on the same level (that means link and ID are updated to the existing alias ID, |
1776
|
|
|
// so custom alias children entries are no longer properly linked (parent-link)) |
1777
|
|
|
} |
1778
|
|
|
} |
1779
|
|
|
|
1780
|
|
|
/** |
1781
|
|
|
* Test for the publishUrlAliasForLocation() method. |
1782
|
|
|
* |
1783
|
|
|
* @group cleanup |
1784
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::publishUrlAliasForLocation |
1785
|
|
|
*/ |
1786
|
|
View Code Duplication |
public function testPublishUrlAliasReuseHistoryCleanup() |
1787
|
|
|
{ |
1788
|
|
|
$handler = $this->getHandler(); |
1789
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_cleanup_history.php'); |
1790
|
|
|
|
1791
|
|
|
$handler->publishUrlAliasForLocation(314, 2, 'tri', 'cro-HR', false); |
1792
|
|
|
|
1793
|
|
|
$urlAlias = $handler->lookup('jedan'); |
1794
|
|
|
$this->assertEquals( |
1795
|
|
|
new UrlAlias( |
1796
|
|
|
[ |
1797
|
|
|
'id' => '0-' . md5('jedan'), |
1798
|
|
|
'type' => UrlAlias::LOCATION, |
1799
|
|
|
'destination' => 314, |
1800
|
|
|
'pathData' => [ |
1801
|
|
|
[ |
1802
|
|
|
'always-available' => false, |
1803
|
|
|
'translations' => ['cro-HR' => 'jedan'], |
1804
|
|
|
], |
1805
|
|
|
], |
1806
|
|
|
'languageCodes' => ['cro-HR'], |
1807
|
|
|
'alwaysAvailable' => false, |
1808
|
|
|
'isHistory' => true, |
1809
|
|
|
'isCustom' => false, |
1810
|
|
|
'forward' => false, |
1811
|
|
|
] |
1812
|
|
|
), |
1813
|
|
|
$urlAlias |
1814
|
|
|
); |
1815
|
|
|
|
1816
|
|
|
$urlAlias = $handler->lookup('tri'); |
1817
|
|
|
$this->assertEquals( |
1818
|
|
|
new UrlAlias( |
1819
|
|
|
[ |
1820
|
|
|
'id' => '0-' . md5('tri'), |
1821
|
|
|
'type' => UrlAlias::LOCATION, |
1822
|
|
|
'destination' => 314, |
1823
|
|
|
'pathData' => [ |
1824
|
|
|
[ |
1825
|
|
|
'always-available' => false, |
1826
|
|
|
'translations' => [ |
1827
|
|
|
'cro-HR' => 'tri', |
1828
|
|
|
'eng-GB' => 'dva', |
1829
|
|
|
], |
1830
|
|
|
], |
1831
|
|
|
], |
1832
|
|
|
'languageCodes' => [ |
1833
|
|
|
'cro-HR', |
1834
|
|
|
], |
1835
|
|
|
'alwaysAvailable' => false, |
1836
|
|
|
'isHistory' => false, |
1837
|
|
|
'isCustom' => false, |
1838
|
|
|
'forward' => false, |
1839
|
|
|
] |
1840
|
|
|
), |
1841
|
|
|
$urlAlias |
1842
|
|
|
); |
1843
|
|
|
} |
1844
|
|
|
|
1845
|
|
|
/** |
1846
|
|
|
* Test for the publishUrlAliasForLocation() method. |
1847
|
|
|
* |
1848
|
|
|
* @group cleanup |
1849
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::publishUrlAliasForLocation |
1850
|
|
|
*/ |
1851
|
|
View Code Duplication |
public function testPublishUrlAliasReuseAutogeneratedCleanup() |
1852
|
|
|
{ |
1853
|
|
|
$handler = $this->getHandler(); |
1854
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_cleanup_reusing.php'); |
1855
|
|
|
|
1856
|
|
|
$handler->publishUrlAliasForLocation(314, 2, 'dva', 'cro-HR', false); |
1857
|
|
|
|
1858
|
|
|
$urlAlias = $handler->lookup('jedan'); |
1859
|
|
|
$this->assertEquals( |
1860
|
|
|
new UrlAlias( |
1861
|
|
|
[ |
1862
|
|
|
'id' => '0-' . md5('jedan'), |
1863
|
|
|
'type' => UrlAlias::LOCATION, |
1864
|
|
|
'destination' => 314, |
1865
|
|
|
'pathData' => [ |
1866
|
|
|
[ |
1867
|
|
|
'always-available' => false, |
1868
|
|
|
'translations' => ['cro-HR' => 'jedan'], |
1869
|
|
|
], |
1870
|
|
|
], |
1871
|
|
|
'languageCodes' => ['cro-HR'], |
1872
|
|
|
'alwaysAvailable' => false, |
1873
|
|
|
'isHistory' => true, |
1874
|
|
|
'isCustom' => false, |
1875
|
|
|
'forward' => false, |
1876
|
|
|
] |
1877
|
|
|
), |
1878
|
|
|
$urlAlias |
1879
|
|
|
); |
1880
|
|
|
|
1881
|
|
|
$urlAlias = $handler->lookup('dva'); |
1882
|
|
|
$this->assertEquals( |
1883
|
|
|
new UrlAlias( |
1884
|
|
|
[ |
1885
|
|
|
'id' => '0-' . md5('dva'), |
1886
|
|
|
'type' => UrlAlias::LOCATION, |
1887
|
|
|
'destination' => 314, |
1888
|
|
|
'pathData' => [ |
1889
|
|
|
[ |
1890
|
|
|
'always-available' => false, |
1891
|
|
|
'translations' => [ |
1892
|
|
|
'cro-HR' => 'dva', |
1893
|
|
|
'eng-GB' => 'dva', |
1894
|
|
|
], |
1895
|
|
|
], |
1896
|
|
|
], |
1897
|
|
|
'languageCodes' => [ |
1898
|
|
|
'cro-HR', |
1899
|
|
|
'eng-GB', |
1900
|
|
|
], |
1901
|
|
|
'alwaysAvailable' => false, |
1902
|
|
|
'isHistory' => false, |
1903
|
|
|
'isCustom' => false, |
1904
|
|
|
'forward' => false, |
1905
|
|
|
] |
1906
|
|
|
), |
1907
|
|
|
$urlAlias |
1908
|
|
|
); |
1909
|
|
|
} |
1910
|
|
|
|
1911
|
|
|
/** |
1912
|
|
|
* Test for the createCustomUrlAlias() method. |
1913
|
|
|
* |
1914
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::createCustomUrlAlias |
1915
|
|
|
* @group create |
1916
|
|
|
* @group custom |
1917
|
|
|
*/ |
1918
|
|
View Code Duplication |
public function testCreateCustomUrlAliasBehaviour() |
1919
|
|
|
{ |
1920
|
|
|
$handlerMock = $this->getPartlyMockedHandler(['createUrlAlias']); |
1921
|
|
|
|
1922
|
|
|
$handlerMock->expects( |
1923
|
|
|
$this->once() |
1924
|
|
|
)->method( |
1925
|
|
|
'createUrlAlias' |
1926
|
|
|
)->with( |
1927
|
|
|
$this->equalTo('eznode:1'), |
1928
|
|
|
$this->equalTo('path'), |
1929
|
|
|
$this->equalTo(false), |
1930
|
|
|
$this->equalTo(null), |
1931
|
|
|
$this->equalTo(false) |
1932
|
|
|
)->will( |
1933
|
|
|
$this->returnValue( |
1934
|
|
|
new UrlAlias() |
1935
|
|
|
) |
1936
|
|
|
); |
1937
|
|
|
|
1938
|
|
|
$this->assertInstanceOf( |
1939
|
|
|
UrlAlias::class, |
1940
|
|
|
$handlerMock->createCustomUrlAlias(1, 'path') |
1941
|
|
|
); |
1942
|
|
|
} |
1943
|
|
|
|
1944
|
|
|
/** |
1945
|
|
|
* Test for the createGlobalUrlAlias() method. |
1946
|
|
|
* |
1947
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::createGlobalUrlAlias |
1948
|
|
|
* @group create |
1949
|
|
|
* @group global |
1950
|
|
|
*/ |
1951
|
|
View Code Duplication |
public function testCreateGlobalUrlAliasBehaviour() |
1952
|
|
|
{ |
1953
|
|
|
$handlerMock = $this->getPartlyMockedHandler(['createUrlAlias']); |
1954
|
|
|
|
1955
|
|
|
$handlerMock->expects( |
1956
|
|
|
$this->once() |
1957
|
|
|
)->method( |
1958
|
|
|
'createUrlAlias' |
1959
|
|
|
)->with( |
1960
|
|
|
$this->equalTo('module/module'), |
1961
|
|
|
$this->equalTo('path'), |
1962
|
|
|
$this->equalTo(false), |
1963
|
|
|
$this->equalTo(null), |
1964
|
|
|
$this->equalTo(false) |
1965
|
|
|
)->will( |
1966
|
|
|
$this->returnValue( |
1967
|
|
|
new UrlAlias() |
1968
|
|
|
) |
1969
|
|
|
); |
1970
|
|
|
|
1971
|
|
|
$this->assertInstanceOf( |
1972
|
|
|
UrlAlias::class, |
1973
|
|
|
$handlerMock->createGlobalUrlAlias('module/module', 'path') |
1974
|
|
|
); |
1975
|
|
|
} |
1976
|
|
|
|
1977
|
|
|
/** |
1978
|
|
|
* Test for the createUrlAlias() method. |
1979
|
|
|
* |
1980
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::createUrlAlias |
1981
|
|
|
* @group create |
1982
|
|
|
* @group custom |
1983
|
|
|
*/ |
1984
|
|
|
public function testCreateCustomUrlAlias() |
1985
|
|
|
{ |
1986
|
|
|
$handler = $this->getHandler(); |
1987
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/publish_base.php'); |
1988
|
|
|
|
1989
|
|
|
$path = 'custom-location-alias'; |
1990
|
|
|
$customUrlAlias = $handler->createCustomUrlAlias( |
1991
|
|
|
314, |
1992
|
|
|
$path, |
1993
|
|
|
false, |
1994
|
|
|
'cro-HR', |
1995
|
|
|
false |
1996
|
|
|
); |
1997
|
|
|
|
1998
|
|
|
self::assertEquals(4, $this->countRows()); |
1999
|
|
|
self::assertEquals( |
2000
|
|
|
new UrlAlias( |
2001
|
|
|
[ |
2002
|
|
|
'id' => '0-' . md5($path), |
2003
|
|
|
'type' => UrlAlias::LOCATION, |
2004
|
|
|
'destination' => 314, |
2005
|
|
|
'pathData' => [ |
2006
|
|
|
[ |
2007
|
|
|
'always-available' => false, |
2008
|
|
|
'translations' => [ |
2009
|
|
|
'cro-HR' => 'custom-location-alias', |
2010
|
|
|
], |
2011
|
|
|
], |
2012
|
|
|
], |
2013
|
|
|
'languageCodes' => ['cro-HR'], |
2014
|
|
|
'alwaysAvailable' => false, |
2015
|
|
|
'isHistory' => false, |
2016
|
|
|
'isCustom' => true, |
2017
|
|
|
'forward' => false, |
2018
|
|
|
] |
2019
|
|
|
), |
2020
|
|
|
$customUrlAlias |
2021
|
|
|
); |
2022
|
|
|
} |
2023
|
|
|
|
2024
|
|
|
/** |
2025
|
|
|
* Test for the createUrlAlias() method. |
2026
|
|
|
* |
2027
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::createUrlAlias |
2028
|
|
|
* @group create |
2029
|
|
|
* @group custom |
2030
|
|
|
*/ |
2031
|
|
|
public function testCreateCustomUrlAliasWithNonameParts() |
2032
|
|
|
{ |
2033
|
|
|
$handler = $this->getHandler(); |
2034
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/publish_base.php'); |
2035
|
|
|
|
2036
|
|
|
$path = 'there-is-a//custom-location-alias//here'; |
2037
|
|
|
$customUrlAlias = $handler->createCustomUrlAlias( |
2038
|
|
|
314, |
2039
|
|
|
$path, |
2040
|
|
|
false, |
2041
|
|
|
'cro-HR', |
2042
|
|
|
false |
2043
|
|
|
); |
2044
|
|
|
|
2045
|
|
|
self::assertEquals(8, $this->countRows()); |
2046
|
|
|
|
2047
|
|
|
self::assertEquals( |
2048
|
|
|
new UrlAlias( |
2049
|
|
|
[ |
2050
|
|
|
'id' => '7-' . md5('here'), |
2051
|
|
|
'type' => UrlAlias::LOCATION, |
2052
|
|
|
'destination' => 314, |
2053
|
|
|
'pathData' => [ |
2054
|
|
|
[ |
2055
|
|
|
'always-available' => true, |
2056
|
|
|
'translations' => [ |
2057
|
|
|
'always-available' => 'there-is-a', |
2058
|
|
|
], |
2059
|
|
|
], |
2060
|
|
|
[ |
2061
|
|
|
'always-available' => true, |
2062
|
|
|
'translations' => [ |
2063
|
|
|
'always-available' => 'noname2', |
2064
|
|
|
], |
2065
|
|
|
], |
2066
|
|
|
[ |
2067
|
|
|
'always-available' => true, |
2068
|
|
|
'translations' => [ |
2069
|
|
|
'always-available' => 'custom-location-alias', |
2070
|
|
|
], |
2071
|
|
|
], |
2072
|
|
|
[ |
2073
|
|
|
'always-available' => true, |
2074
|
|
|
'translations' => [ |
2075
|
|
|
'always-available' => 'noname4', |
2076
|
|
|
], |
2077
|
|
|
], |
2078
|
|
|
[ |
2079
|
|
|
'always-available' => false, |
2080
|
|
|
'translations' => [ |
2081
|
|
|
'cro-HR' => 'here', |
2082
|
|
|
], |
2083
|
|
|
], |
2084
|
|
|
], |
2085
|
|
|
'languageCodes' => ['cro-HR'], |
2086
|
|
|
'alwaysAvailable' => false, |
2087
|
|
|
'isHistory' => false, |
2088
|
|
|
'isCustom' => true, |
2089
|
|
|
'forward' => false, |
2090
|
|
|
] |
2091
|
|
|
), |
2092
|
|
|
$customUrlAlias |
2093
|
|
|
); |
2094
|
|
|
} |
2095
|
|
|
|
2096
|
|
|
/** |
2097
|
|
|
* Test for the createUrlAlias() method. |
2098
|
|
|
* |
2099
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::createUrlAlias |
2100
|
|
|
* @group create |
2101
|
|
|
* @group custom |
2102
|
|
|
* |
2103
|
|
|
* @todo pathData |
2104
|
|
|
*/ |
2105
|
|
|
public function testCreatedCustomUrlAliasIsLoadable() |
2106
|
|
|
{ |
2107
|
|
|
$handler = $this->getHandler(); |
2108
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/publish_base.php'); |
2109
|
|
|
|
2110
|
|
|
$path = 'custom-location-alias'; |
2111
|
|
|
$customUrlAlias = $handler->createCustomUrlAlias( |
2112
|
|
|
314, |
2113
|
|
|
$path, |
2114
|
|
|
false, |
2115
|
|
|
'cro-HR', |
2116
|
|
|
false |
2117
|
|
|
); |
2118
|
|
|
$loadedCustomUrlAlias = $handler->lookup($path); |
2119
|
|
|
|
2120
|
|
|
self::assertEquals(4, $this->countRows()); |
2121
|
|
|
|
2122
|
|
|
foreach ($loadedCustomUrlAlias as $propertyName => $propertyValue) { |
|
|
|
|
2123
|
|
|
if ($propertyName === 'pathData') { |
2124
|
|
|
self::assertEquals( |
2125
|
|
|
[ |
2126
|
|
|
[ |
2127
|
|
|
'always-available' => false, |
2128
|
|
|
'translations' => ['cro-HR' => $path], |
2129
|
|
|
], |
2130
|
|
|
], |
2131
|
|
|
$loadedCustomUrlAlias->$propertyName |
2132
|
|
|
); |
2133
|
|
|
} else { |
2134
|
|
|
self::assertEquals( |
2135
|
|
|
$customUrlAlias->$propertyName, |
2136
|
|
|
$loadedCustomUrlAlias->$propertyName |
2137
|
|
|
); |
2138
|
|
|
} |
2139
|
|
|
} |
2140
|
|
|
} |
2141
|
|
|
|
2142
|
|
|
/** |
2143
|
|
|
* Test for the createUrlAlias() method. |
2144
|
|
|
* |
2145
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::createUrlAlias |
2146
|
|
|
* @group create |
2147
|
|
|
* @group custom |
2148
|
|
|
*/ |
2149
|
|
|
public function testCreateCustomUrlAliasWithNopElement() |
2150
|
|
|
{ |
2151
|
|
|
$handler = $this->getHandler(); |
2152
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/publish_base.php'); |
2153
|
|
|
|
2154
|
|
|
$path = 'ribar/palunko'; |
2155
|
|
|
$customUrlAlias = $handler->createCustomUrlAlias( |
2156
|
|
|
314, |
2157
|
|
|
$path, |
2158
|
|
|
false, |
2159
|
|
|
'cro-HR', |
2160
|
|
|
true |
2161
|
|
|
); |
2162
|
|
|
|
2163
|
|
|
self::assertEquals(5, $this->countRows()); |
2164
|
|
|
self::assertEquals( |
2165
|
|
|
new UrlAlias( |
2166
|
|
|
[ |
2167
|
|
|
'id' => '4-' . md5('palunko'), |
2168
|
|
|
'type' => UrlAlias::LOCATION, |
2169
|
|
|
'destination' => 314, |
2170
|
|
|
'pathData' => [ |
2171
|
|
|
[ |
2172
|
|
|
'always-available' => true, |
2173
|
|
|
'translations' => [ |
2174
|
|
|
'always-available' => 'ribar', |
2175
|
|
|
], |
2176
|
|
|
], |
2177
|
|
|
[ |
2178
|
|
|
'always-available' => true, |
2179
|
|
|
'translations' => [ |
2180
|
|
|
'cro-HR' => 'palunko', |
2181
|
|
|
], |
2182
|
|
|
], |
2183
|
|
|
], |
2184
|
|
|
'languageCodes' => ['cro-HR'], |
2185
|
|
|
'alwaysAvailable' => true, |
2186
|
|
|
'isHistory' => false, |
2187
|
|
|
'isCustom' => true, |
2188
|
|
|
'forward' => false, |
2189
|
|
|
] |
2190
|
|
|
), |
2191
|
|
|
$customUrlAlias |
2192
|
|
|
); |
2193
|
|
|
|
2194
|
|
|
return $handler; |
2195
|
|
|
} |
2196
|
|
|
|
2197
|
|
|
/** |
2198
|
|
|
* Test for the createUrlAlias() method. |
2199
|
|
|
* |
2200
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::createUrlAlias |
2201
|
|
|
* @depends testCreateCustomUrlAliasWithNopElement |
2202
|
|
|
* @group create |
2203
|
|
|
* @group custom |
2204
|
|
|
*/ |
2205
|
|
|
public function testCreateUrlAliasWithNopElementCreatesValidNopElement(Handler $handler) |
2206
|
|
|
{ |
2207
|
|
|
$url = 'ribar'; |
2208
|
|
|
$urlAlias = $handler->lookup($url); |
2209
|
|
|
|
2210
|
|
|
$this->assertVirtualUrlAliasValid( |
2211
|
|
|
$urlAlias, |
2212
|
|
|
'0-' . md5($url) |
2213
|
|
|
); |
2214
|
|
|
} |
2215
|
|
|
|
2216
|
|
|
/** |
2217
|
|
|
* Test for the createUrlAlias() method. |
2218
|
|
|
* |
2219
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::createUrlAlias |
2220
|
|
|
* @group create |
2221
|
|
|
* @group custom |
2222
|
|
|
*/ |
2223
|
|
View Code Duplication |
public function testCreateCustomUrlAliasReusesHistory() |
2224
|
|
|
{ |
2225
|
|
|
$handler = $this->getHandler(); |
2226
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_reusing.php'); |
2227
|
|
|
|
2228
|
|
|
$countBeforeReusing = $this->countRows(); |
2229
|
|
|
$handler->createCustomUrlAlias( |
2230
|
|
|
314, |
2231
|
|
|
'history-hello', |
2232
|
|
|
true, |
2233
|
|
|
'eng-GB', |
2234
|
|
|
true |
2235
|
|
|
); |
2236
|
|
|
|
2237
|
|
|
self::assertEquals( |
2238
|
|
|
$countBeforeReusing, |
2239
|
|
|
$this->countRows() |
2240
|
|
|
); |
2241
|
|
|
self::assertEquals( |
2242
|
|
|
new UrlAlias( |
2243
|
|
|
[ |
2244
|
|
|
'id' => '0-da94285592c46d4396d3ca6904a4aa8f', |
2245
|
|
|
'type' => UrlAlias::LOCATION, |
2246
|
|
|
'destination' => 314, |
2247
|
|
|
'languageCodes' => ['eng-GB'], |
2248
|
|
|
'pathData' => [ |
2249
|
|
|
[ |
2250
|
|
|
'always-available' => true, |
2251
|
|
|
'translations' => ['eng-GB' => 'history-hello'], |
2252
|
|
|
], |
2253
|
|
|
], |
2254
|
|
|
'alwaysAvailable' => true, |
2255
|
|
|
'isHistory' => false, |
2256
|
|
|
'isCustom' => true, |
2257
|
|
|
'forward' => true, |
2258
|
|
|
] |
2259
|
|
|
), |
2260
|
|
|
$handler->lookup('history-hello') |
2261
|
|
|
); |
2262
|
|
|
} |
2263
|
|
|
|
2264
|
|
|
/** |
2265
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::createUrlAlias |
2266
|
|
|
* @group create |
2267
|
|
|
* @group custom |
2268
|
|
|
*/ |
2269
|
|
|
public function testCreateCustomUrlAliasAddLanguage(): void |
2270
|
|
|
{ |
2271
|
|
|
$handler = $this->getHandler(); |
2272
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/publish_base.php'); |
2273
|
|
|
|
2274
|
|
|
// create a new custom entry since the existing one is a system URL |
2275
|
|
|
$handler->createCustomUrlAlias(314, 'custom-path314', false, 'cro-HR', true); |
2276
|
|
|
|
2277
|
|
|
$countBeforeReusing = $this->countRows(); |
2278
|
|
|
$handler->createCustomUrlAlias( |
2279
|
|
|
314, |
2280
|
|
|
'custom-path314', |
2281
|
|
|
false, |
2282
|
|
|
'eng-GB', |
2283
|
|
|
true |
2284
|
|
|
); |
2285
|
|
|
|
2286
|
|
|
self::assertEquals( |
2287
|
|
|
$countBeforeReusing, |
2288
|
|
|
$this->countRows() |
2289
|
|
|
); |
2290
|
|
|
self::assertEquals( |
2291
|
|
|
new UrlAlias( |
2292
|
|
|
[ |
2293
|
|
|
'id' => '0-e8797691eeba6b598a353e5c5af99438', |
2294
|
|
|
'type' => UrlAlias::LOCATION, |
2295
|
|
|
'destination' => '314', |
2296
|
|
|
'languageCodes' => ['cro-HR', 'eng-GB'], |
2297
|
|
|
'pathData' => [ |
2298
|
|
|
[ |
2299
|
|
|
'always-available' => true, |
2300
|
|
|
'translations' => [ |
2301
|
|
|
'cro-HR' => 'custom-path314', |
2302
|
|
|
'eng-GB' => 'custom-path314', |
2303
|
|
|
], |
2304
|
|
|
], |
2305
|
|
|
], |
2306
|
|
|
'alwaysAvailable' => true, |
2307
|
|
|
'isHistory' => false, |
2308
|
|
|
'isCustom' => true, |
2309
|
|
|
'forward' => false, |
2310
|
|
|
] |
2311
|
|
|
), |
2312
|
|
|
$handler->lookup('custom-path314') |
2313
|
|
|
); |
2314
|
|
|
} |
2315
|
|
|
|
2316
|
|
|
/** |
2317
|
|
|
* Test for the createUrlAlias() method. |
2318
|
|
|
* |
2319
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::createUrlAlias |
2320
|
|
|
* @group create |
2321
|
|
|
* @group custom |
2322
|
|
|
*/ |
2323
|
|
View Code Duplication |
public function testCreateCustomUrlAliasReusesHistoryOfDifferentLanguage() |
2324
|
|
|
{ |
2325
|
|
|
$handler = $this->getHandler(); |
2326
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_reusing.php'); |
2327
|
|
|
|
2328
|
|
|
$countBeforeReusing = $this->countRows(); |
2329
|
|
|
$handler->createCustomUrlAlias( |
2330
|
|
|
314, |
2331
|
|
|
'history-hello', |
2332
|
|
|
true, |
2333
|
|
|
'cro-HR', |
2334
|
|
|
true |
2335
|
|
|
); |
2336
|
|
|
|
2337
|
|
|
self::assertEquals( |
2338
|
|
|
$countBeforeReusing, |
2339
|
|
|
$this->countRows() |
2340
|
|
|
); |
2341
|
|
|
self::assertEquals( |
2342
|
|
|
new UrlAlias( |
2343
|
|
|
[ |
2344
|
|
|
'id' => '0-da94285592c46d4396d3ca6904a4aa8f', |
2345
|
|
|
'type' => UrlAlias::LOCATION, |
2346
|
|
|
'destination' => 314, |
2347
|
|
|
'languageCodes' => ['cro-HR'], |
2348
|
|
|
'pathData' => [ |
2349
|
|
|
[ |
2350
|
|
|
'always-available' => true, |
2351
|
|
|
'translations' => ['cro-HR' => 'history-hello'], |
2352
|
|
|
], |
2353
|
|
|
], |
2354
|
|
|
'alwaysAvailable' => true, |
2355
|
|
|
'isHistory' => false, |
2356
|
|
|
'isCustom' => true, |
2357
|
|
|
'forward' => true, |
2358
|
|
|
] |
2359
|
|
|
), |
2360
|
|
|
$handler->lookup('history-hello') |
2361
|
|
|
); |
2362
|
|
|
} |
2363
|
|
|
|
2364
|
|
|
/** |
2365
|
|
|
* Test for the createUrlAlias() method. |
2366
|
|
|
* |
2367
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::createUrlAlias |
2368
|
|
|
* @group create |
2369
|
|
|
* @group custom |
2370
|
|
|
*/ |
2371
|
|
|
public function testCreateCustomUrlAliasReusesNopElement() |
2372
|
|
|
{ |
2373
|
|
|
$handler = $this->getHandler(); |
2374
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_reusing.php'); |
2375
|
|
|
|
2376
|
|
|
$countBeforeReusing = $this->countRows(); |
2377
|
|
|
$handler->createCustomUrlAlias( |
2378
|
|
|
314, |
2379
|
|
|
'nop-element', |
2380
|
|
|
true, |
2381
|
|
|
'cro-HR', |
2382
|
|
|
true |
2383
|
|
|
); |
2384
|
|
|
|
2385
|
|
|
self::assertEquals( |
2386
|
|
|
$countBeforeReusing, |
2387
|
|
|
$this->countRows() |
2388
|
|
|
); |
2389
|
|
|
|
2390
|
|
|
// Check that custom alias whose nop element was reused still works as expected |
2391
|
|
|
self::assertEquals( |
2392
|
|
|
new UrlAlias( |
2393
|
|
|
[ |
2394
|
|
|
'id' => '2-06a943c59f33a34bb5924aaf72cd2995', |
2395
|
|
|
'type' => UrlAlias::RESOURCE, |
2396
|
|
|
'destination' => 'content/search', |
2397
|
|
|
'languageCodes' => ['eng-GB'], |
2398
|
|
|
'pathData' => [ |
2399
|
|
|
[ |
2400
|
|
|
'always-available' => true, |
2401
|
|
|
'translations' => ['cro-HR' => 'nop-element'], |
2402
|
|
|
], |
2403
|
|
|
[ |
2404
|
|
|
'always-available' => false, |
2405
|
|
|
'translations' => ['eng-GB' => 'search'], |
2406
|
|
|
], |
2407
|
|
|
], |
2408
|
|
|
'alwaysAvailable' => false, |
2409
|
|
|
'isHistory' => false, |
2410
|
|
|
'isCustom' => true, |
2411
|
|
|
'forward' => false, |
2412
|
|
|
] |
2413
|
|
|
), |
2414
|
|
|
$handler->lookup('nop-element/search') |
2415
|
|
|
); |
2416
|
|
|
} |
2417
|
|
|
|
2418
|
|
|
/** |
2419
|
|
|
* Test for the createUrlAlias() method. |
2420
|
|
|
* |
2421
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::createUrlAlias |
2422
|
|
|
* @group create |
2423
|
|
|
* @group custom |
2424
|
|
|
*/ |
2425
|
|
View Code Duplication |
public function testCreateCustomUrlAliasReusesLocationElement() |
2426
|
|
|
{ |
2427
|
|
|
$handler = $this->getHandler(); |
2428
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_reusing.php'); |
2429
|
|
|
|
2430
|
|
|
$countBeforeReusing = $this->countRows(); |
2431
|
|
|
$locationUrlAlias = $handler->lookup('autogenerated-hello'); |
2432
|
|
|
$handler->createCustomUrlAlias( |
2433
|
|
|
315, |
2434
|
|
|
'autogenerated-hello/custom-location-alias-for-315', |
2435
|
|
|
true, |
2436
|
|
|
'cro-HR', |
2437
|
|
|
true |
2438
|
|
|
); |
2439
|
|
|
|
2440
|
|
|
self::assertEquals( |
2441
|
|
|
$countBeforeReusing + 1, |
2442
|
|
|
$this->countRows() |
2443
|
|
|
); |
2444
|
|
|
|
2445
|
|
|
// Check that location alias still works as expected |
2446
|
|
|
self::assertEquals( |
2447
|
|
|
$locationUrlAlias, |
2448
|
|
|
$handler->lookup('autogenerated-hello') |
2449
|
|
|
); |
2450
|
|
|
} |
2451
|
|
|
|
2452
|
|
|
/** |
2453
|
|
|
* Test for the listGlobalURLAliases() method. |
2454
|
|
|
* |
2455
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::listGlobalURLAliases |
2456
|
|
|
* @depends testLookupResourceUrlAlias |
2457
|
|
|
*/ |
2458
|
|
|
public function testListGlobalURLAliases() |
2459
|
|
|
{ |
2460
|
|
|
$handler = $this->getHandler(); |
2461
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_resource.php'); |
2462
|
|
|
|
2463
|
|
|
$globalAliasList = $handler->listGlobalURLAliases(); |
2464
|
|
|
|
2465
|
|
|
self::assertEquals( |
2466
|
|
|
[ |
2467
|
|
|
$handler->lookup('is-alive'), |
2468
|
|
|
$handler->lookup('is-alive/then/search'), |
2469
|
|
|
$handler->lookup('nop-element/search'), |
2470
|
|
|
], |
2471
|
|
|
$globalAliasList |
2472
|
|
|
); |
2473
|
|
|
} |
2474
|
|
|
|
2475
|
|
|
/** |
2476
|
|
|
* Test for the listGlobalURLAliases() method. |
2477
|
|
|
* |
2478
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::listGlobalURLAliases |
2479
|
|
|
* @depends testLookupResourceUrlAlias |
2480
|
|
|
*/ |
2481
|
|
View Code Duplication |
public function testListGlobalURLAliasesWithLanguageCode() |
2482
|
|
|
{ |
2483
|
|
|
$handler = $this->getHandler(); |
2484
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_resource.php'); |
2485
|
|
|
|
2486
|
|
|
$globalAliasList = $handler->listGlobalURLAliases('eng-GB'); |
2487
|
|
|
|
2488
|
|
|
self::assertEquals( |
2489
|
|
|
[ |
2490
|
|
|
$handler->lookup('is-alive'), |
2491
|
|
|
$handler->lookup('nop-element/search'), |
2492
|
|
|
], |
2493
|
|
|
$globalAliasList |
2494
|
|
|
); |
2495
|
|
|
} |
2496
|
|
|
|
2497
|
|
|
/** |
2498
|
|
|
* Test for the listGlobalURLAliases() method. |
2499
|
|
|
* |
2500
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::listGlobalURLAliases |
2501
|
|
|
* @depends testLookupResourceUrlAlias |
2502
|
|
|
*/ |
2503
|
|
|
public function testListGlobalURLAliasesWithOffset() |
2504
|
|
|
{ |
2505
|
|
|
$handler = $this->getHandler(); |
2506
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_resource.php'); |
2507
|
|
|
|
2508
|
|
|
$globalAliasList = $handler->listGlobalURLAliases(null, 2); |
2509
|
|
|
|
2510
|
|
|
self::assertEquals( |
2511
|
|
|
[ |
2512
|
|
|
$handler->lookup('nop-element/search'), |
2513
|
|
|
], |
2514
|
|
|
$globalAliasList |
2515
|
|
|
); |
2516
|
|
|
} |
2517
|
|
|
|
2518
|
|
|
/** |
2519
|
|
|
* Test for the listGlobalURLAliases() method. |
2520
|
|
|
* |
2521
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::listGlobalURLAliases |
2522
|
|
|
* @depends testLookupResourceUrlAlias |
2523
|
|
|
*/ |
2524
|
|
|
public function testListGlobalURLAliasesWithOffsetAndLimit() |
2525
|
|
|
{ |
2526
|
|
|
$handler = $this->getHandler(); |
2527
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_resource.php'); |
2528
|
|
|
|
2529
|
|
|
$globalAliasList = $handler->listGlobalURLAliases(null, 1, 1); |
2530
|
|
|
|
2531
|
|
|
self::assertEquals( |
2532
|
|
|
[ |
2533
|
|
|
$handler->lookup('is-alive/then/search'), |
2534
|
|
|
], |
2535
|
|
|
$globalAliasList |
2536
|
|
|
); |
2537
|
|
|
} |
2538
|
|
|
|
2539
|
|
|
/** |
2540
|
|
|
* Test for the locationDeleted() method. |
2541
|
|
|
* |
2542
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::locationDeleted |
2543
|
|
|
*/ |
2544
|
|
|
public function testLocationDeleted() |
2545
|
|
|
{ |
2546
|
|
|
$handler = $this->getHandler(); |
2547
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_location_delete.php'); |
2548
|
|
|
|
2549
|
|
|
$countBeforeDeleting = $this->countRows(); |
2550
|
|
|
$countAfterFirstDeleting = $countBeforeDeleting - 5; |
2551
|
|
|
|
2552
|
|
|
$handler->locationDeleted(5); |
2553
|
|
|
|
2554
|
|
|
self::assertEquals( |
2555
|
|
|
$countAfterFirstDeleting, |
2556
|
|
|
$this->countRows() |
2557
|
|
|
); |
2558
|
|
|
|
2559
|
|
|
self::assertEmpty( |
2560
|
|
|
$handler->listURLAliasesForLocation(5) |
2561
|
|
|
); |
2562
|
|
|
|
2563
|
|
|
$removedAliases = [ |
2564
|
|
|
'moved-original-parent/moved-history', |
2565
|
|
|
'moved-original-parent/sub', |
2566
|
|
|
'moved-original-parent', |
2567
|
|
|
'moved-original-parent-history', |
2568
|
|
|
'custom-below/moved-original-parent-custom', |
2569
|
|
|
]; |
2570
|
|
|
foreach ($removedAliases as $path) { |
2571
|
|
|
try { |
2572
|
|
|
$handler->lookup($path); |
2573
|
|
|
$this->fail("Alias '$path' not removed!"); |
2574
|
|
|
} catch (NotFoundException $e) { |
2575
|
|
|
// Do nothing |
2576
|
|
|
} |
2577
|
|
|
} |
2578
|
|
|
|
2579
|
|
|
// Deleting location historically related with some relative alias |
2580
|
|
|
$handler->locationDeleted(9); |
2581
|
|
|
|
2582
|
|
|
self::assertEquals( |
2583
|
|
|
$countAfterFirstDeleting - 1, |
2584
|
|
|
$this->countRows() |
2585
|
|
|
); |
2586
|
|
|
self::assertCount( |
2587
|
|
|
1, |
2588
|
|
|
$handler->listURLAliasesForLocation(10) |
2589
|
|
|
); |
2590
|
|
|
|
2591
|
|
|
$handler->lookup('to-delete-folder/article-to-move-relative-alias'); |
2592
|
|
|
} |
2593
|
|
|
|
2594
|
|
|
/** |
2595
|
|
|
* Test for the locationMoved() method. |
2596
|
|
|
* |
2597
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::locationMoved |
2598
|
|
|
*/ |
2599
|
|
View Code Duplication |
public function testLocationMovedHistorize() |
2600
|
|
|
{ |
2601
|
|
|
$handler = $this->getHandler(); |
2602
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_move.php'); |
2603
|
|
|
|
2604
|
|
|
$handler->publishUrlAliasForLocation(4, 3, 'move-this', 'eng-GB', false); |
2605
|
|
|
$handler->locationMoved(4, 2, 3); |
2606
|
|
|
|
2607
|
|
|
$urlAlias = $handler->lookup('move-this'); |
2608
|
|
|
self::assertEquals( |
2609
|
|
|
new UrlAlias( |
2610
|
|
|
[ |
2611
|
|
|
'id' => '0-' . md5('move-this'), |
2612
|
|
|
'type' => UrlAlias::LOCATION, |
2613
|
|
|
'destination' => '4', |
2614
|
|
|
'languageCodes' => ['eng-GB'], |
2615
|
|
|
'pathData' => [ |
2616
|
|
|
[ |
2617
|
|
|
'always-available' => false, |
2618
|
|
|
'translations' => ['eng-GB' => 'move-this'], |
2619
|
|
|
], |
2620
|
|
|
], |
2621
|
|
|
'alwaysAvailable' => false, |
2622
|
|
|
'isHistory' => true, |
2623
|
|
|
'isCustom' => false, |
2624
|
|
|
'forward' => false, |
2625
|
|
|
] |
2626
|
|
|
), |
2627
|
|
|
$urlAlias |
2628
|
|
|
); |
2629
|
|
|
} |
2630
|
|
|
|
2631
|
|
|
/** |
2632
|
|
|
* Test for the locationMoved() method. |
2633
|
|
|
* |
2634
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::locationMoved |
2635
|
|
|
*/ |
2636
|
|
View Code Duplication |
public function testLocationMovedHistory() |
2637
|
|
|
{ |
2638
|
|
|
$handler = $this->getHandler(); |
2639
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_move.php'); |
2640
|
|
|
|
2641
|
|
|
$handler->publishUrlAliasForLocation(4, 3, 'move-this', 'eng-GB', false); |
2642
|
|
|
$handler->locationMoved(4, 2, 3); |
2643
|
|
|
|
2644
|
|
|
$urlAlias = $handler->lookup('move-this-history'); |
2645
|
|
|
self::assertEquals( |
2646
|
|
|
new UrlAlias( |
2647
|
|
|
[ |
2648
|
|
|
'id' => '0-' . md5('move-this-history'), |
2649
|
|
|
'type' => UrlAlias::LOCATION, |
2650
|
|
|
'destination' => '4', |
2651
|
|
|
'languageCodes' => ['eng-GB'], |
2652
|
|
|
'pathData' => [ |
2653
|
|
|
[ |
2654
|
|
|
'always-available' => false, |
2655
|
|
|
'translations' => ['eng-GB' => 'move-this-history'], |
2656
|
|
|
], |
2657
|
|
|
], |
2658
|
|
|
'alwaysAvailable' => false, |
2659
|
|
|
'isHistory' => true, |
2660
|
|
|
'isCustom' => false, |
2661
|
|
|
'forward' => false, |
2662
|
|
|
] |
2663
|
|
|
), |
2664
|
|
|
$urlAlias |
2665
|
|
|
); |
2666
|
|
|
} |
2667
|
|
|
|
2668
|
|
|
/** |
2669
|
|
|
* Test for the locationMoved() method. |
2670
|
|
|
* |
2671
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::locationMoved |
2672
|
|
|
*/ |
2673
|
|
View Code Duplication |
public function testLocationMovedHistorySubtree() |
2674
|
|
|
{ |
2675
|
|
|
$handler = $this->getHandler(); |
2676
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_move.php'); |
2677
|
|
|
|
2678
|
|
|
$handler->publishUrlAliasForLocation(4, 3, 'move-this', 'eng-GB', false); |
2679
|
|
|
$handler->locationMoved(4, 2, 3); |
2680
|
|
|
|
2681
|
|
|
$urlAlias = $handler->lookup('move-this/sub1/sub2'); |
2682
|
|
|
self::assertEquals( |
2683
|
|
|
new UrlAlias( |
2684
|
|
|
[ |
2685
|
|
|
'id' => '5-' . md5('sub2'), |
2686
|
|
|
'type' => UrlAlias::LOCATION, |
2687
|
|
|
'destination' => '6', |
2688
|
|
|
'languageCodes' => ['eng-GB'], |
2689
|
|
|
'pathData' => [ |
2690
|
|
|
[ |
2691
|
|
|
'always-available' => false, |
2692
|
|
|
'translations' => ['eng-GB' => 'move-this'], |
2693
|
|
|
], |
2694
|
|
|
[ |
2695
|
|
|
'always-available' => false, |
2696
|
|
|
'translations' => ['eng-GB' => 'sub1'], |
2697
|
|
|
], |
2698
|
|
|
[ |
2699
|
|
|
'always-available' => false, |
2700
|
|
|
'translations' => ['eng-GB' => 'sub2'], |
2701
|
|
|
], |
2702
|
|
|
], |
2703
|
|
|
'alwaysAvailable' => false, |
2704
|
|
|
'isHistory' => true, |
2705
|
|
|
'isCustom' => false, |
2706
|
|
|
'forward' => false, |
2707
|
|
|
] |
2708
|
|
|
), |
2709
|
|
|
$urlAlias |
2710
|
|
|
); |
2711
|
|
|
} |
2712
|
|
|
|
2713
|
|
|
/** |
2714
|
|
|
* Test for the locationMoved() method. |
2715
|
|
|
* |
2716
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::locationMoved |
2717
|
|
|
*/ |
2718
|
|
View Code Duplication |
public function testLocationMovedReparent() |
2719
|
|
|
{ |
2720
|
|
|
$handler = $this->getHandler(); |
2721
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_move.php'); |
2722
|
|
|
|
2723
|
|
|
$handler->publishUrlAliasForLocation(4, 3, 'move-this', 'eng-GB', false); |
2724
|
|
|
$handler->locationMoved(4, 2, 3); |
2725
|
|
|
|
2726
|
|
|
$urlAlias = $handler->lookup('move-here/move-this/sub1'); |
2727
|
|
|
self::assertEquals( |
2728
|
|
|
new UrlAlias( |
2729
|
|
|
[ |
2730
|
|
|
'id' => '9-' . md5('sub1'), |
2731
|
|
|
'type' => UrlAlias::LOCATION, |
2732
|
|
|
'destination' => '5', |
2733
|
|
|
'languageCodes' => ['eng-GB'], |
2734
|
|
|
'pathData' => [ |
2735
|
|
|
[ |
2736
|
|
|
'always-available' => false, |
2737
|
|
|
'translations' => ['eng-GB' => 'move-here'], |
2738
|
|
|
], |
2739
|
|
|
[ |
2740
|
|
|
'always-available' => false, |
2741
|
|
|
'translations' => ['eng-GB' => 'move-this'], |
2742
|
|
|
], |
2743
|
|
|
[ |
2744
|
|
|
'always-available' => false, |
2745
|
|
|
'translations' => ['eng-GB' => 'sub1'], |
2746
|
|
|
], |
2747
|
|
|
], |
2748
|
|
|
'alwaysAvailable' => false, |
2749
|
|
|
'isHistory' => false, |
2750
|
|
|
'isCustom' => false, |
2751
|
|
|
'forward' => false, |
2752
|
|
|
] |
2753
|
|
|
), |
2754
|
|
|
$urlAlias |
2755
|
|
|
); |
2756
|
|
|
} |
2757
|
|
|
|
2758
|
|
|
/** |
2759
|
|
|
* Test for the locationMoved() method. |
2760
|
|
|
* |
2761
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::locationMoved |
2762
|
|
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\NotFoundException |
2763
|
|
|
*/ |
2764
|
|
View Code Duplication |
public function testLocationMovedReparentHistory() |
2765
|
|
|
{ |
2766
|
|
|
$handler = $this->getHandler(); |
2767
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_move.php'); |
2768
|
|
|
|
2769
|
|
|
$handler->publishUrlAliasForLocation(4, 3, 'move-this', 'eng-GB', false); |
2770
|
|
|
$handler->locationMoved(4, 2, 3); |
2771
|
|
|
|
2772
|
|
|
$handler->lookup('move-here/move-this-history'); |
2773
|
|
|
} |
2774
|
|
|
|
2775
|
|
|
/** |
2776
|
|
|
* Test for the locationMoved() method. |
2777
|
|
|
* |
2778
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::locationMoved |
2779
|
|
|
*/ |
2780
|
|
View Code Duplication |
public function testLocationMovedReparentSubtree() |
2781
|
|
|
{ |
2782
|
|
|
$handler = $this->getHandler(); |
2783
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_move.php'); |
2784
|
|
|
|
2785
|
|
|
$handler->publishUrlAliasForLocation(4, 3, 'move-this', 'eng-GB', false); |
2786
|
|
|
$handler->locationMoved(4, 2, 3); |
2787
|
|
|
|
2788
|
|
|
$urlAlias = $handler->lookup('move-here/move-this/sub1/sub2'); |
2789
|
|
|
self::assertEquals( |
2790
|
|
|
new UrlAlias( |
2791
|
|
|
[ |
2792
|
|
|
'id' => '5-' . md5('sub2'), |
2793
|
|
|
'type' => UrlAlias::LOCATION, |
2794
|
|
|
'destination' => '6', |
2795
|
|
|
'languageCodes' => ['eng-GB'], |
2796
|
|
|
'pathData' => [ |
2797
|
|
|
[ |
2798
|
|
|
'always-available' => false, |
2799
|
|
|
'translations' => ['eng-GB' => 'move-here'], |
2800
|
|
|
], |
2801
|
|
|
[ |
2802
|
|
|
'always-available' => false, |
2803
|
|
|
'translations' => ['eng-GB' => 'move-this'], |
2804
|
|
|
], |
2805
|
|
|
[ |
2806
|
|
|
'always-available' => false, |
2807
|
|
|
'translations' => ['eng-GB' => 'sub1'], |
2808
|
|
|
], |
2809
|
|
|
[ |
2810
|
|
|
'always-available' => false, |
2811
|
|
|
'translations' => ['eng-GB' => 'sub2'], |
2812
|
|
|
], |
2813
|
|
|
], |
2814
|
|
|
'alwaysAvailable' => false, |
2815
|
|
|
'isHistory' => false, |
2816
|
|
|
'isCustom' => false, |
2817
|
|
|
'forward' => false, |
2818
|
|
|
] |
2819
|
|
|
), |
2820
|
|
|
$urlAlias |
2821
|
|
|
); |
2822
|
|
|
} |
2823
|
|
|
|
2824
|
|
|
/** |
2825
|
|
|
* Test for the locationMoved() method. |
2826
|
|
|
* |
2827
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::locationMoved |
2828
|
|
|
*/ |
2829
|
|
View Code Duplication |
public function testLocationMovedReparentSubtreeHistory() |
2830
|
|
|
{ |
2831
|
|
|
$handler = $this->getHandler(); |
2832
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_move.php'); |
2833
|
|
|
|
2834
|
|
|
$handler->publishUrlAliasForLocation(4, 3, 'move-this', 'eng-GB', false); |
2835
|
|
|
$handler->locationMoved(4, 2, 3); |
2836
|
|
|
|
2837
|
|
|
$urlAlias = $handler->lookup('move-here/move-this/sub1/sub2-history'); |
2838
|
|
|
self::assertEquals( |
2839
|
|
|
new UrlAlias( |
2840
|
|
|
[ |
2841
|
|
|
'id' => '5-' . md5('sub2-history'), |
2842
|
|
|
'type' => UrlAlias::LOCATION, |
2843
|
|
|
'destination' => '6', |
2844
|
|
|
'languageCodes' => ['eng-GB'], |
2845
|
|
|
'pathData' => [ |
2846
|
|
|
[ |
2847
|
|
|
'always-available' => false, |
2848
|
|
|
'translations' => ['eng-GB' => 'move-here'], |
2849
|
|
|
], |
2850
|
|
|
[ |
2851
|
|
|
'always-available' => false, |
2852
|
|
|
'translations' => ['eng-GB' => 'move-this'], |
2853
|
|
|
], |
2854
|
|
|
[ |
2855
|
|
|
'always-available' => false, |
2856
|
|
|
'translations' => ['eng-GB' => 'sub1'], |
2857
|
|
|
], |
2858
|
|
|
[ |
2859
|
|
|
'always-available' => false, |
2860
|
|
|
'translations' => ['eng-GB' => 'sub2-history'], |
2861
|
|
|
], |
2862
|
|
|
], |
2863
|
|
|
'alwaysAvailable' => false, |
2864
|
|
|
'isHistory' => true, |
2865
|
|
|
'isCustom' => false, |
2866
|
|
|
'forward' => false, |
2867
|
|
|
] |
2868
|
|
|
), |
2869
|
|
|
$urlAlias |
2870
|
|
|
); |
2871
|
|
|
} |
2872
|
|
|
|
2873
|
|
|
/** |
2874
|
|
|
* Test for the locationCopied() method. |
2875
|
|
|
* |
2876
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::locationCopied |
2877
|
|
|
*/ |
2878
|
|
View Code Duplication |
public function testLocationCopiedCopiedLocationAliasIsValid() |
2879
|
|
|
{ |
2880
|
|
|
$handler = $this->getHandler(); |
2881
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_copy.php'); |
2882
|
|
|
|
2883
|
|
|
$urlAlias = $handler->lookup('move-this'); |
2884
|
|
|
|
2885
|
|
|
$handler->locationCopied(4, 400, 3); |
2886
|
|
|
|
2887
|
|
|
self::assertEquals( |
2888
|
|
|
$urlAlias, |
2889
|
|
|
$handler->lookup('move-this') |
2890
|
|
|
); |
2891
|
|
|
} |
2892
|
|
|
|
2893
|
|
|
/** |
2894
|
|
|
* Test for the locationCopied() method. |
2895
|
|
|
* |
2896
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::locationCopied |
2897
|
|
|
*/ |
2898
|
|
View Code Duplication |
public function testLocationCopiedCopiedSubtreeIsValid() |
2899
|
|
|
{ |
2900
|
|
|
$handler = $this->getHandler(); |
2901
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_copy.php'); |
2902
|
|
|
|
2903
|
|
|
$urlAlias = $handler->lookup('move-this/sub1/sub2'); |
2904
|
|
|
|
2905
|
|
|
$handler->locationCopied(4, 400, 3); |
2906
|
|
|
|
2907
|
|
|
self::assertEquals( |
2908
|
|
|
$urlAlias, |
2909
|
|
|
$handler->lookup('move-this/sub1/sub2') |
2910
|
|
|
); |
2911
|
|
|
} |
2912
|
|
|
|
2913
|
|
|
/** |
2914
|
|
|
* Test for the locationCopied() method. |
2915
|
|
|
* |
2916
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::locationCopied |
2917
|
|
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\NotFoundException |
2918
|
|
|
*/ |
2919
|
|
View Code Duplication |
public function testLocationCopiedHistoryNotCopied() |
2920
|
|
|
{ |
2921
|
|
|
$handler = $this->getHandler(); |
2922
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_copy.php'); |
2923
|
|
|
|
2924
|
|
|
$handler->locationCopied(4, 400, 3); |
2925
|
|
|
|
2926
|
|
|
$handler->lookup('move-here/move-this-history'); |
2927
|
|
|
} |
2928
|
|
|
|
2929
|
|
|
/** |
2930
|
|
|
* Test for the locationCopied() method. |
2931
|
|
|
* |
2932
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::locationCopied |
2933
|
|
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\NotFoundException |
2934
|
|
|
*/ |
2935
|
|
View Code Duplication |
public function testLocationCopiedSubtreeHistoryNotCopied() |
2936
|
|
|
{ |
2937
|
|
|
$handler = $this->getHandler(); |
2938
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_copy.php'); |
2939
|
|
|
|
2940
|
|
|
$handler->locationCopied(4, 400, 3); |
2941
|
|
|
|
2942
|
|
|
$handler->lookup('move-here/move-this/sub1/sub2-history'); |
2943
|
|
|
} |
2944
|
|
|
|
2945
|
|
|
/** |
2946
|
|
|
* Test for the locationCopied() method. |
2947
|
|
|
* |
2948
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::locationCopied |
2949
|
|
|
*/ |
2950
|
|
|
public function testLocationCopiedSubtree() |
2951
|
|
|
{ |
2952
|
|
|
$handler = $this->getHandler(); |
2953
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_copy.php'); |
2954
|
|
|
|
2955
|
|
|
$countBeforeCopying = $this->countRows(); |
2956
|
|
|
|
2957
|
|
|
$handler->locationCopied(4, 400, 3); |
2958
|
|
|
|
2959
|
|
|
self::assertEquals( |
2960
|
|
|
$countBeforeCopying + 2, |
2961
|
|
|
$this->countRows() |
2962
|
|
|
); |
2963
|
|
|
|
2964
|
|
|
$urlAlias = $handler->lookup('move-here/move-this/sub1/sub2'); |
2965
|
|
|
self::assertEquals( |
2966
|
|
|
new UrlAlias( |
2967
|
|
|
[ |
2968
|
|
|
'id' => '10-' . md5('sub2'), |
2969
|
|
|
'type' => UrlAlias::LOCATION, |
2970
|
|
|
'destination' => 600, |
2971
|
|
|
'languageCodes' => ['eng-GB'], |
2972
|
|
|
'pathData' => [ |
2973
|
|
|
[ |
2974
|
|
|
'always-available' => false, |
2975
|
|
|
'translations' => ['eng-GB' => 'move-here'], |
2976
|
|
|
], |
2977
|
|
|
[ |
2978
|
|
|
'always-available' => false, |
2979
|
|
|
'translations' => ['eng-GB' => 'move-this'], |
2980
|
|
|
], |
2981
|
|
|
[ |
2982
|
|
|
'always-available' => false, |
2983
|
|
|
'translations' => ['eng-GB' => 'sub1'], |
2984
|
|
|
], |
2985
|
|
|
[ |
2986
|
|
|
'always-available' => false, |
2987
|
|
|
'translations' => ['eng-GB' => 'sub2'], |
2988
|
|
|
], |
2989
|
|
|
], |
2990
|
|
|
'alwaysAvailable' => false, |
2991
|
|
|
'isHistory' => false, |
2992
|
|
|
'isCustom' => false, |
2993
|
|
|
'forward' => false, |
2994
|
|
|
] |
2995
|
|
|
), |
2996
|
|
|
$urlAlias |
2997
|
|
|
); |
2998
|
|
|
} |
2999
|
|
|
|
3000
|
|
|
/** |
3001
|
|
|
* Test for the loadUrlAlias() method. |
3002
|
|
|
* |
3003
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::loadUrlAlias |
3004
|
|
|
* @dataProvider providerForTestLookupLocationMultipleLanguages |
3005
|
|
|
*/ |
3006
|
|
View Code Duplication |
public function testLoadAutogeneratedUrlAlias( |
3007
|
|
|
$url, |
|
|
|
|
3008
|
|
|
array $pathData, |
3009
|
|
|
array $languageCodes, |
3010
|
|
|
$alwaysAvailable, |
3011
|
|
|
$locationId, |
3012
|
|
|
$id |
3013
|
|
|
) { |
3014
|
|
|
$handler = $this->getHandler(); |
3015
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_location_multilang.php'); |
3016
|
|
|
|
3017
|
|
|
$urlAlias = $handler->loadUrlAlias($id); |
3018
|
|
|
|
3019
|
|
|
self::assertInstanceOf(UrlAlias::class, $urlAlias); |
3020
|
|
|
self::assertEquals( |
3021
|
|
|
new UrlAlias( |
3022
|
|
|
[ |
3023
|
|
|
'id' => $id, |
3024
|
|
|
'type' => UrlAlias::LOCATION, |
3025
|
|
|
'destination' => $locationId, |
3026
|
|
|
'languageCodes' => $languageCodes, |
3027
|
|
|
'pathData' => $pathData, |
3028
|
|
|
'alwaysAvailable' => $alwaysAvailable, |
3029
|
|
|
'isHistory' => false, |
3030
|
|
|
'isCustom' => false, |
3031
|
|
|
'forward' => false, |
3032
|
|
|
] |
3033
|
|
|
), |
3034
|
|
|
$urlAlias |
3035
|
|
|
); |
3036
|
|
|
} |
3037
|
|
|
|
3038
|
|
|
/** |
3039
|
|
|
* Test for the loadUrlAlias() method. |
3040
|
|
|
* |
3041
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::loadUrlAlias |
3042
|
|
|
* @dataProvider providerForTestLookupResourceUrlAlias |
3043
|
|
|
*/ |
3044
|
|
View Code Duplication |
public function testLoadResourceUrlAlias( |
3045
|
|
|
$url, |
|
|
|
|
3046
|
|
|
$pathData, |
3047
|
|
|
array $languageCodes, |
3048
|
|
|
$forward, |
3049
|
|
|
$alwaysAvailable, |
3050
|
|
|
$destination, |
3051
|
|
|
$id |
3052
|
|
|
) { |
3053
|
|
|
$handler = $this->getHandler(); |
3054
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_resource.php'); |
3055
|
|
|
|
3056
|
|
|
$urlAlias = $handler->loadUrlAlias($id); |
3057
|
|
|
|
3058
|
|
|
self::assertInstanceOf(UrlAlias::class, $urlAlias); |
3059
|
|
|
self::assertEquals( |
3060
|
|
|
new UrlAlias( |
3061
|
|
|
[ |
3062
|
|
|
'id' => $id, |
3063
|
|
|
'type' => UrlAlias::RESOURCE, |
3064
|
|
|
'destination' => $destination, |
3065
|
|
|
'languageCodes' => $languageCodes, |
3066
|
|
|
'pathData' => $pathData, |
3067
|
|
|
'alwaysAvailable' => $alwaysAvailable, |
3068
|
|
|
'isHistory' => false, |
3069
|
|
|
'isCustom' => true, |
3070
|
|
|
'forward' => $forward, |
3071
|
|
|
] |
3072
|
|
|
), |
3073
|
|
|
$urlAlias |
3074
|
|
|
); |
3075
|
|
|
} |
3076
|
|
|
|
3077
|
|
|
/** |
3078
|
|
|
* Test for the loadUrlAlias() method. |
3079
|
|
|
* |
3080
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::loadUrlAlias |
3081
|
|
|
* @dataProvider providerForTestLookupVirtualUrlAlias |
3082
|
|
|
*/ |
3083
|
|
View Code Duplication |
public function testLoadVirtualUrlAlias($url, $id) |
|
|
|
|
3084
|
|
|
{ |
3085
|
|
|
$handler = $this->getHandler(); |
3086
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_location_custom.php'); |
3087
|
|
|
|
3088
|
|
|
$urlAlias = $handler->loadUrlAlias($id); |
3089
|
|
|
|
3090
|
|
|
$this->assertVirtualUrlAliasValid($urlAlias, $id); |
3091
|
|
|
} |
3092
|
|
|
|
3093
|
|
|
protected function getHistoryAlias() |
3094
|
|
|
{ |
3095
|
|
|
return new UrlAlias( |
3096
|
|
|
[ |
3097
|
|
|
'id' => '3-5f46413bb0ba5998caef84ab1ea590e1', |
3098
|
|
|
'type' => UrlAlias::LOCATION, |
3099
|
|
|
'destination' => '316', |
3100
|
|
|
'pathData' => [ |
3101
|
|
|
[ |
3102
|
|
|
'always-available' => true, |
3103
|
|
|
'translations' => ['cro-HR' => 'jedan'], |
3104
|
|
|
], |
3105
|
|
|
[ |
3106
|
|
|
'always-available' => false, |
3107
|
|
|
'translations' => [ |
3108
|
|
|
'cro-HR' => 'dva', |
3109
|
|
|
'eng-GB' => 'two', |
3110
|
|
|
], |
3111
|
|
|
], |
3112
|
|
|
[ |
3113
|
|
|
'always-available' => false, |
3114
|
|
|
'translations' => [ |
3115
|
|
|
'cro-HR' => 'tri-history', |
3116
|
|
|
], |
3117
|
|
|
], |
3118
|
|
|
], |
3119
|
|
|
'languageCodes' => ['cro-HR'], |
3120
|
|
|
'alwaysAvailable' => false, |
3121
|
|
|
'isHistory' => true, |
3122
|
|
|
'isCustom' => false, |
3123
|
|
|
'forward' => false, |
3124
|
|
|
] |
3125
|
|
|
); |
3126
|
|
|
} |
3127
|
|
|
|
3128
|
|
|
/** |
3129
|
|
|
* Test for the loadUrlAlias() method. |
3130
|
|
|
* |
3131
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::loadUrlAlias |
3132
|
|
|
*/ |
3133
|
|
|
public function testLoadHistoryUrlAlias() |
3134
|
|
|
{ |
3135
|
|
|
$handler = $this->getHandler(); |
3136
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_location.php'); |
3137
|
|
|
|
3138
|
|
|
$historyAlias = $this->getHistoryAlias(); |
3139
|
|
|
$urlAlias = $handler->loadUrlAlias($historyAlias->id); |
3140
|
|
|
|
3141
|
|
|
self::assertEquals( |
3142
|
|
|
$historyAlias, |
3143
|
|
|
$urlAlias |
3144
|
|
|
); |
3145
|
|
|
} |
3146
|
|
|
|
3147
|
|
|
/** |
3148
|
|
|
* Test for the loadUrlAlias() method. |
3149
|
|
|
* |
3150
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::loadUrlAlias |
3151
|
|
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\NotFoundException |
3152
|
|
|
*/ |
3153
|
|
|
public function testLoadUrlAliasThrowsNotFoundException() |
3154
|
|
|
{ |
3155
|
|
|
$handler = $this->getHandler(); |
3156
|
|
|
|
3157
|
|
|
$handler->loadUrlAlias('non-existent'); |
3158
|
|
|
} |
3159
|
|
|
|
3160
|
|
|
public function providerForTestPublishUrlAliasForLocationSkipsReservedWord() |
3161
|
|
|
{ |
3162
|
|
|
return [ |
3163
|
|
|
[ |
3164
|
|
|
'section', |
3165
|
|
|
'section2', |
3166
|
|
|
], |
3167
|
|
|
[ |
3168
|
|
|
'claß', |
3169
|
|
|
'class2', |
3170
|
|
|
], |
3171
|
|
|
]; |
3172
|
|
|
} |
3173
|
|
|
|
3174
|
|
|
/** |
3175
|
|
|
* Test for the publishUrlAliasForLocation() method. |
3176
|
|
|
* |
3177
|
|
|
* @dataProvider providerForTestPublishUrlAliasForLocationSkipsReservedWord |
3178
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::publishUrlAliasForLocation |
3179
|
|
|
* @group publish |
3180
|
|
|
*/ |
3181
|
|
|
public function testPublishUrlAliasForLocationSkipsReservedWord($text, $alias) |
3182
|
|
|
{ |
3183
|
|
|
$handler = $this->getHandler(); |
3184
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/publish_base.php'); |
3185
|
|
|
|
3186
|
|
|
$handler->publishUrlAliasForLocation(314, 2, $text, 'kli-KR'); |
3187
|
|
|
|
3188
|
|
|
$urlAlias = $handler->lookup($alias); |
3189
|
|
|
|
3190
|
|
|
$this->assertEquals(314, $urlAlias->destination); |
3191
|
|
|
$this->assertEquals(['kli-KR'], $urlAlias->languageCodes); |
3192
|
|
|
} |
3193
|
|
|
|
3194
|
|
|
/** |
3195
|
|
|
* Test for the locationSwapped() method. |
3196
|
|
|
* |
3197
|
|
|
* @group swap |
3198
|
|
|
*/ |
3199
|
|
|
public function testLocationSwappedSimple() |
3200
|
|
|
{ |
3201
|
|
|
$handler = $this->getHandler(); |
3202
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_swap_simple.php'); |
3203
|
|
|
|
3204
|
|
|
$countBeforeReusing = $this->countRows(); |
3205
|
|
|
|
3206
|
|
|
$handler->locationSwapped(316, 314, 317, 315); |
3207
|
|
|
|
3208
|
|
|
$this->assertEquals( |
3209
|
|
|
$countBeforeReusing, |
3210
|
|
|
$this->countRows() |
3211
|
|
|
); |
3212
|
|
|
|
3213
|
|
|
$urlAlias = $handler->lookup('jedan/swap'); |
3214
|
|
|
$this->assertEquals( |
3215
|
|
|
new UrlAlias( |
3216
|
|
|
[ |
3217
|
|
|
'id' => '2-' . md5('swap'), |
3218
|
|
|
'type' => UrlAlias::LOCATION, |
3219
|
|
|
'destination' => 316, |
3220
|
|
|
'languageCodes' => [ |
3221
|
|
|
'cro-HR', |
3222
|
|
|
], |
3223
|
|
|
'pathData' => [ |
3224
|
|
|
[ |
3225
|
|
|
'always-available' => false, |
3226
|
|
|
'translations' => [ |
3227
|
|
|
'cro-HR' => 'jedan', |
3228
|
|
|
], |
3229
|
|
|
], |
3230
|
|
|
[ |
3231
|
|
|
'always-available' => false, |
3232
|
|
|
'translations' => [ |
3233
|
|
|
'cro-HR' => 'swap', |
3234
|
|
|
], |
3235
|
|
|
], |
3236
|
|
|
], |
3237
|
|
|
'alwaysAvailable' => false, |
3238
|
|
|
'isHistory' => false, |
3239
|
|
|
'isCustom' => false, |
3240
|
|
|
'forward' => false, |
3241
|
|
|
] |
3242
|
|
|
), |
3243
|
|
|
$urlAlias |
3244
|
|
|
); |
3245
|
|
|
|
3246
|
|
|
$urlAlias = $handler->lookup('dva/swap'); |
3247
|
|
|
$this->assertEquals( |
3248
|
|
|
new UrlAlias( |
3249
|
|
|
[ |
3250
|
|
|
'id' => '3-' . md5('swap'), |
3251
|
|
|
'type' => UrlAlias::LOCATION, |
3252
|
|
|
'destination' => 317, |
3253
|
|
|
'languageCodes' => [ |
3254
|
|
|
'cro-HR', |
3255
|
|
|
], |
3256
|
|
|
'pathData' => [ |
3257
|
|
|
[ |
3258
|
|
|
'always-available' => false, |
3259
|
|
|
'translations' => [ |
3260
|
|
|
'cro-HR' => 'dva', |
3261
|
|
|
], |
3262
|
|
|
], |
3263
|
|
|
[ |
3264
|
|
|
'always-available' => false, |
3265
|
|
|
'translations' => [ |
3266
|
|
|
'cro-HR' => 'swap', |
3267
|
|
|
], |
3268
|
|
|
], |
3269
|
|
|
], |
3270
|
|
|
'alwaysAvailable' => false, |
3271
|
|
|
'isHistory' => false, |
3272
|
|
|
'isCustom' => false, |
3273
|
|
|
'forward' => false, |
3274
|
|
|
] |
3275
|
|
|
), |
3276
|
|
|
$urlAlias |
3277
|
|
|
); |
3278
|
|
|
} |
3279
|
|
|
|
3280
|
|
|
/** |
3281
|
|
|
* Test for the locationSwapped() method. |
3282
|
|
|
* |
3283
|
|
|
* @group swap |
3284
|
|
|
*/ |
3285
|
|
View Code Duplication |
public function testLocationSwappedSimpleWithHistory() |
3286
|
|
|
{ |
3287
|
|
|
$handler = $this->getHandler(); |
3288
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_swap_simple_history.php'); |
3289
|
|
|
|
3290
|
|
|
$countBeforeReusing = $this->countRows(); |
3291
|
|
|
|
3292
|
|
|
$handler->locationSwapped(316, 314, 317, 315); |
3293
|
|
|
|
3294
|
|
|
$this->assertEquals( |
3295
|
|
|
$countBeforeReusing, |
3296
|
|
|
$this->countRows() |
3297
|
|
|
); |
3298
|
|
|
|
3299
|
|
|
$urlAlias = $handler->lookup('jedan/swap'); |
3300
|
|
|
$this->assertEquals( |
3301
|
|
|
new UrlAlias( |
3302
|
|
|
[ |
3303
|
|
|
'id' => '2-' . md5('swap'), |
3304
|
|
|
'type' => UrlAlias::LOCATION, |
3305
|
|
|
'destination' => 316, |
3306
|
|
|
'languageCodes' => [ |
3307
|
|
|
'cro-HR', |
3308
|
|
|
], |
3309
|
|
|
'pathData' => [ |
3310
|
|
|
[ |
3311
|
|
|
'always-available' => false, |
3312
|
|
|
'translations' => [ |
3313
|
|
|
'cro-HR' => 'jedan', |
3314
|
|
|
], |
3315
|
|
|
], |
3316
|
|
|
[ |
3317
|
|
|
'always-available' => false, |
3318
|
|
|
'translations' => [ |
3319
|
|
|
'cro-HR' => 'swap', |
3320
|
|
|
], |
3321
|
|
|
], |
3322
|
|
|
], |
3323
|
|
|
'alwaysAvailable' => false, |
3324
|
|
|
'isHistory' => true, |
3325
|
|
|
'isCustom' => false, |
3326
|
|
|
'forward' => false, |
3327
|
|
|
] |
3328
|
|
|
), |
3329
|
|
|
$urlAlias |
3330
|
|
|
); |
3331
|
|
|
|
3332
|
|
|
$urlAlias = $handler->lookup('dva/swap'); |
3333
|
|
|
$this->assertEquals( |
3334
|
|
|
new UrlAlias( |
3335
|
|
|
[ |
3336
|
|
|
'id' => '3-' . md5('swap'), |
3337
|
|
|
'type' => UrlAlias::LOCATION, |
3338
|
|
|
'destination' => 317, |
3339
|
|
|
'languageCodes' => [ |
3340
|
|
|
'cro-HR', |
3341
|
|
|
], |
3342
|
|
|
'pathData' => [ |
3343
|
|
|
[ |
3344
|
|
|
'always-available' => false, |
3345
|
|
|
'translations' => [ |
3346
|
|
|
'cro-HR' => 'dva', |
3347
|
|
|
], |
3348
|
|
|
], |
3349
|
|
|
[ |
3350
|
|
|
'always-available' => false, |
3351
|
|
|
'translations' => [ |
3352
|
|
|
'cro-HR' => 'swap', |
3353
|
|
|
], |
3354
|
|
|
], |
3355
|
|
|
], |
3356
|
|
|
'alwaysAvailable' => false, |
3357
|
|
|
'isHistory' => true, |
3358
|
|
|
'isCustom' => false, |
3359
|
|
|
'forward' => false, |
3360
|
|
|
] |
3361
|
|
|
), |
3362
|
|
|
$urlAlias |
3363
|
|
|
); |
3364
|
|
|
|
3365
|
|
|
$urlAlias = $handler->lookup('jedan/swap-new'); |
3366
|
|
|
$this->assertEquals( |
3367
|
|
|
new UrlAlias( |
3368
|
|
|
[ |
3369
|
|
|
'id' => '2-' . md5('swap-new'), |
3370
|
|
|
'type' => UrlAlias::LOCATION, |
3371
|
|
|
'destination' => 316, |
3372
|
|
|
'languageCodes' => [ |
3373
|
|
|
'cro-HR', |
3374
|
|
|
], |
3375
|
|
|
'pathData' => [ |
3376
|
|
|
[ |
3377
|
|
|
'always-available' => false, |
3378
|
|
|
'translations' => [ |
3379
|
|
|
'cro-HR' => 'jedan', |
3380
|
|
|
], |
3381
|
|
|
], |
3382
|
|
|
[ |
3383
|
|
|
'always-available' => false, |
3384
|
|
|
'translations' => [ |
3385
|
|
|
'cro-HR' => 'swap-new', |
3386
|
|
|
], |
3387
|
|
|
], |
3388
|
|
|
], |
3389
|
|
|
'alwaysAvailable' => false, |
3390
|
|
|
'isHistory' => false, |
3391
|
|
|
'isCustom' => false, |
3392
|
|
|
'forward' => false, |
3393
|
|
|
] |
3394
|
|
|
), |
3395
|
|
|
$urlAlias |
3396
|
|
|
); |
3397
|
|
|
|
3398
|
|
|
$urlAlias = $handler->lookup('dva/swap-new'); |
3399
|
|
|
$this->assertEquals( |
3400
|
|
|
new UrlAlias( |
3401
|
|
|
[ |
3402
|
|
|
'id' => '3-' . md5('swap-new'), |
3403
|
|
|
'type' => UrlAlias::LOCATION, |
3404
|
|
|
'destination' => 317, |
3405
|
|
|
'languageCodes' => [ |
3406
|
|
|
'cro-HR', |
3407
|
|
|
], |
3408
|
|
|
'pathData' => [ |
3409
|
|
|
[ |
3410
|
|
|
'always-available' => false, |
3411
|
|
|
'translations' => [ |
3412
|
|
|
'cro-HR' => 'dva', |
3413
|
|
|
], |
3414
|
|
|
], |
3415
|
|
|
[ |
3416
|
|
|
'always-available' => false, |
3417
|
|
|
'translations' => [ |
3418
|
|
|
'cro-HR' => 'swap-new', |
3419
|
|
|
], |
3420
|
|
|
], |
3421
|
|
|
], |
3422
|
|
|
'alwaysAvailable' => false, |
3423
|
|
|
'isHistory' => false, |
3424
|
|
|
'isCustom' => false, |
3425
|
|
|
'forward' => false, |
3426
|
|
|
] |
3427
|
|
|
), |
3428
|
|
|
$urlAlias |
3429
|
|
|
); |
3430
|
|
|
} |
3431
|
|
|
|
3432
|
|
|
/** |
3433
|
|
|
* Test for the locationSwapped() method. |
3434
|
|
|
* |
3435
|
|
|
* @group swap |
3436
|
|
|
*/ |
3437
|
|
|
public function testLocationSwappedSimpleWithConflict() |
3438
|
|
|
{ |
3439
|
|
|
$handler = $this->getHandler(); |
3440
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_swap_simple_conflict.php'); |
3441
|
|
|
|
3442
|
|
|
$urlAlias1TakenExpected = $handler->lookup('jedan/swap-new-2'); |
3443
|
|
|
$urlAlias2TakenExpected = $handler->lookup('dva/swap-new-1'); |
3444
|
|
|
|
3445
|
|
|
$urlAlias1HistorizedExpected = $handler->lookup('jedan/swap-new-1'); |
3446
|
|
|
$urlAlias1HistorizedExpected->isHistory = true; |
3447
|
|
|
$urlAlias2HistorizedExpected = $handler->lookup('dva/swap-new-2'); |
3448
|
|
|
$urlAlias2HistorizedExpected->isHistory = true; |
3449
|
|
|
|
3450
|
|
|
$countBeforeReusing = $this->countRows(); |
3451
|
|
|
|
3452
|
|
|
$handler->locationSwapped(316, 314, 317, 315); |
3453
|
|
|
|
3454
|
|
|
$this->assertEquals( |
3455
|
|
|
$countBeforeReusing + 2, |
3456
|
|
|
$this->countRows() |
3457
|
|
|
); |
3458
|
|
|
|
3459
|
|
|
$urlAlias1Taken = $handler->lookup('jedan/swap-new-2'); |
3460
|
|
|
$urlAlias2Taken = $handler->lookup('dva/swap-new-1'); |
3461
|
|
|
|
3462
|
|
|
$urlAlias1Historized = $handler->lookup('jedan/swap-new-1'); |
3463
|
|
|
$urlAlias2Historized = $handler->lookup('dva/swap-new-2'); |
3464
|
|
|
|
3465
|
|
|
$this->assertEquals($urlAlias1TakenExpected, $urlAlias1Taken); |
3466
|
|
|
$this->assertEquals($urlAlias2TakenExpected, $urlAlias2Taken); |
3467
|
|
|
|
3468
|
|
|
$this->assertEquals($urlAlias1HistorizedExpected, $urlAlias1Historized); |
3469
|
|
|
$this->assertEquals($urlAlias2HistorizedExpected, $urlAlias2Historized); |
3470
|
|
|
|
3471
|
|
|
$urlAlias1New = $handler->lookup('jedan/swap-new-22'); |
3472
|
|
|
$this->assertEquals( |
3473
|
|
|
new UrlAlias( |
3474
|
|
|
[ |
3475
|
|
|
'id' => '2-' . md5('swap-new-22'), |
3476
|
|
|
'type' => UrlAlias::LOCATION, |
3477
|
|
|
'destination' => 316, |
3478
|
|
|
'languageCodes' => [ |
3479
|
|
|
'cro-HR', |
3480
|
|
|
], |
3481
|
|
|
'pathData' => [ |
3482
|
|
|
[ |
3483
|
|
|
'always-available' => false, |
3484
|
|
|
'translations' => [ |
3485
|
|
|
'cro-HR' => 'jedan', |
3486
|
|
|
], |
3487
|
|
|
], |
3488
|
|
|
[ |
3489
|
|
|
'always-available' => false, |
3490
|
|
|
'translations' => [ |
3491
|
|
|
'cro-HR' => 'swap-new-22', |
3492
|
|
|
], |
3493
|
|
|
], |
3494
|
|
|
], |
3495
|
|
|
'alwaysAvailable' => false, |
3496
|
|
|
'isHistory' => false, |
3497
|
|
|
'isCustom' => false, |
3498
|
|
|
'forward' => false, |
3499
|
|
|
] |
3500
|
|
|
), |
3501
|
|
|
$urlAlias1New |
3502
|
|
|
); |
3503
|
|
|
|
3504
|
|
|
$urlAlias2New = $handler->lookup('dva/swap-new-12'); |
3505
|
|
|
$this->assertEquals( |
3506
|
|
|
new UrlAlias( |
3507
|
|
|
[ |
3508
|
|
|
'id' => '3-' . md5('swap-new-12'), |
3509
|
|
|
'type' => UrlAlias::LOCATION, |
3510
|
|
|
'destination' => 317, |
3511
|
|
|
'languageCodes' => [ |
3512
|
|
|
'cro-HR', |
3513
|
|
|
], |
3514
|
|
|
'pathData' => [ |
3515
|
|
|
[ |
3516
|
|
|
'always-available' => false, |
3517
|
|
|
'translations' => [ |
3518
|
|
|
'cro-HR' => 'dva', |
3519
|
|
|
], |
3520
|
|
|
], |
3521
|
|
|
[ |
3522
|
|
|
'always-available' => false, |
3523
|
|
|
'translations' => [ |
3524
|
|
|
'cro-HR' => 'swap-new-12', |
3525
|
|
|
], |
3526
|
|
|
], |
3527
|
|
|
], |
3528
|
|
|
'alwaysAvailable' => false, |
3529
|
|
|
'isHistory' => false, |
3530
|
|
|
'isCustom' => false, |
3531
|
|
|
'forward' => false, |
3532
|
|
|
] |
3533
|
|
|
), |
3534
|
|
|
$urlAlias2New |
3535
|
|
|
); |
3536
|
|
|
} |
3537
|
|
|
|
3538
|
|
|
/** |
3539
|
|
|
* Test for the locationSwapped() method. |
3540
|
|
|
* |
3541
|
|
|
* @group swap |
3542
|
|
|
*/ |
3543
|
|
View Code Duplication |
public function testLocationSwappedSiblingsSimple() |
3544
|
|
|
{ |
3545
|
|
|
$handler = $this->getHandler(); |
3546
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_swap_siblings_simple.php'); |
3547
|
|
|
|
3548
|
|
|
$countBeforeReusing = $this->countRows(); |
3549
|
|
|
|
3550
|
|
|
$handler->locationSwapped(314, 2, 315, 2); |
3551
|
|
|
|
3552
|
|
|
$this->assertEquals( |
3553
|
|
|
$countBeforeReusing, |
3554
|
|
|
$this->countRows() |
3555
|
|
|
); |
3556
|
|
|
|
3557
|
|
|
$urlAlias = $handler->lookup('jedan'); |
3558
|
|
|
$this->assertEquals( |
3559
|
|
|
new UrlAlias( |
3560
|
|
|
[ |
3561
|
|
|
'id' => '0-' . md5('jedan'), |
3562
|
|
|
'type' => UrlAlias::LOCATION, |
3563
|
|
|
'destination' => 315, |
3564
|
|
|
'languageCodes' => [ |
3565
|
|
|
'cro-HR', |
3566
|
|
|
], |
3567
|
|
|
'pathData' => [ |
3568
|
|
|
[ |
3569
|
|
|
'always-available' => false, |
3570
|
|
|
'translations' => [ |
3571
|
|
|
'cro-HR' => 'jedan', |
3572
|
|
|
], |
3573
|
|
|
], |
3574
|
|
|
], |
3575
|
|
|
'alwaysAvailable' => false, |
3576
|
|
|
'isHistory' => false, |
3577
|
|
|
'isCustom' => false, |
3578
|
|
|
'forward' => false, |
3579
|
|
|
] |
3580
|
|
|
), |
3581
|
|
|
$urlAlias |
3582
|
|
|
); |
3583
|
|
|
|
3584
|
|
|
$urlAlias = $handler->lookup('dva'); |
3585
|
|
|
$this->assertEquals( |
3586
|
|
|
new UrlAlias( |
3587
|
|
|
[ |
3588
|
|
|
'id' => '0-' . md5('dva'), |
3589
|
|
|
'type' => UrlAlias::LOCATION, |
3590
|
|
|
'destination' => 314, |
3591
|
|
|
'languageCodes' => [ |
3592
|
|
|
'cro-HR', |
3593
|
|
|
], |
3594
|
|
|
'pathData' => [ |
3595
|
|
|
[ |
3596
|
|
|
'always-available' => false, |
3597
|
|
|
'translations' => [ |
3598
|
|
|
'cro-HR' => 'dva', |
3599
|
|
|
], |
3600
|
|
|
], |
3601
|
|
|
], |
3602
|
|
|
'alwaysAvailable' => false, |
3603
|
|
|
'isHistory' => false, |
3604
|
|
|
'isCustom' => false, |
3605
|
|
|
'forward' => false, |
3606
|
|
|
] |
3607
|
|
|
), |
3608
|
|
|
$urlAlias |
3609
|
|
|
); |
3610
|
|
|
} |
3611
|
|
|
|
3612
|
|
|
/** |
3613
|
|
|
* Test for the locationSwapped() method. |
3614
|
|
|
* |
3615
|
|
|
* @group swap |
3616
|
|
|
*/ |
3617
|
|
View Code Duplication |
public function testLocationSwappedSiblingsSimpleReverse() |
3618
|
|
|
{ |
3619
|
|
|
$handler = $this->getHandler(); |
3620
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_swap_siblings_simple.php'); |
3621
|
|
|
|
3622
|
|
|
$countBeforeReusing = $this->countRows(); |
3623
|
|
|
|
3624
|
|
|
$handler->locationSwapped(315, 2, 314, 2); |
3625
|
|
|
|
3626
|
|
|
$this->assertEquals( |
3627
|
|
|
$countBeforeReusing, |
3628
|
|
|
$this->countRows() |
3629
|
|
|
); |
3630
|
|
|
|
3631
|
|
|
$urlAlias = $handler->lookup('jedan'); |
3632
|
|
|
$this->assertEquals( |
3633
|
|
|
new UrlAlias( |
3634
|
|
|
[ |
3635
|
|
|
'id' => '0-' . md5('jedan'), |
3636
|
|
|
'type' => UrlAlias::LOCATION, |
3637
|
|
|
'destination' => 315, |
3638
|
|
|
'languageCodes' => [ |
3639
|
|
|
'cro-HR', |
3640
|
|
|
], |
3641
|
|
|
'pathData' => [ |
3642
|
|
|
[ |
3643
|
|
|
'always-available' => false, |
3644
|
|
|
'translations' => [ |
3645
|
|
|
'cro-HR' => 'jedan', |
3646
|
|
|
], |
3647
|
|
|
], |
3648
|
|
|
], |
3649
|
|
|
'alwaysAvailable' => false, |
3650
|
|
|
'isHistory' => false, |
3651
|
|
|
'isCustom' => false, |
3652
|
|
|
'forward' => false, |
3653
|
|
|
] |
3654
|
|
|
), |
3655
|
|
|
$urlAlias |
3656
|
|
|
); |
3657
|
|
|
|
3658
|
|
|
$urlAlias = $handler->lookup('dva'); |
3659
|
|
|
$this->assertEquals( |
3660
|
|
|
new UrlAlias( |
3661
|
|
|
[ |
3662
|
|
|
'id' => '0-' . md5('dva'), |
3663
|
|
|
'type' => UrlAlias::LOCATION, |
3664
|
|
|
'destination' => 314, |
3665
|
|
|
'languageCodes' => [ |
3666
|
|
|
'cro-HR', |
3667
|
|
|
], |
3668
|
|
|
'pathData' => [ |
3669
|
|
|
[ |
3670
|
|
|
'always-available' => false, |
3671
|
|
|
'translations' => [ |
3672
|
|
|
'cro-HR' => 'dva', |
3673
|
|
|
], |
3674
|
|
|
], |
3675
|
|
|
], |
3676
|
|
|
'alwaysAvailable' => false, |
3677
|
|
|
'isHistory' => false, |
3678
|
|
|
'isCustom' => false, |
3679
|
|
|
'forward' => false, |
3680
|
|
|
] |
3681
|
|
|
), |
3682
|
|
|
$urlAlias |
3683
|
|
|
); |
3684
|
|
|
} |
3685
|
|
|
|
3686
|
|
|
/** |
3687
|
|
|
* Test for the locationSwapped() method. |
3688
|
|
|
* |
3689
|
|
|
* @group swap |
3690
|
|
|
*/ |
3691
|
|
View Code Duplication |
public function testLocationSwappedSiblingsSimpleWithHistory() |
3692
|
|
|
{ |
3693
|
|
|
$handler = $this->getHandler(); |
3694
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_swap_siblings_simple_history.php'); |
3695
|
|
|
|
3696
|
|
|
$countBeforeReusing = $this->countRows(); |
3697
|
|
|
|
3698
|
|
|
$handler->locationSwapped(314, 2, 315, 2); |
3699
|
|
|
|
3700
|
|
|
$this->assertEquals( |
3701
|
|
|
$countBeforeReusing, |
3702
|
|
|
$this->countRows() |
3703
|
|
|
); |
3704
|
|
|
|
3705
|
|
|
$urlAlias = $handler->lookup('jedan'); |
3706
|
|
|
$this->assertEquals( |
3707
|
|
|
new UrlAlias( |
3708
|
|
|
[ |
3709
|
|
|
'id' => '0-' . md5('jedan'), |
3710
|
|
|
'type' => UrlAlias::LOCATION, |
3711
|
|
|
'destination' => 314, |
3712
|
|
|
'languageCodes' => [ |
3713
|
|
|
'cro-HR', |
3714
|
|
|
], |
3715
|
|
|
'pathData' => [ |
3716
|
|
|
[ |
3717
|
|
|
'always-available' => false, |
3718
|
|
|
'translations' => [ |
3719
|
|
|
'cro-HR' => 'jedan', |
3720
|
|
|
], |
3721
|
|
|
], |
3722
|
|
|
], |
3723
|
|
|
'alwaysAvailable' => false, |
3724
|
|
|
'isHistory' => true, |
3725
|
|
|
'isCustom' => false, |
3726
|
|
|
'forward' => false, |
3727
|
|
|
] |
3728
|
|
|
), |
3729
|
|
|
$urlAlias |
3730
|
|
|
); |
3731
|
|
|
|
3732
|
|
|
$urlAlias = $handler->lookup('dva'); |
3733
|
|
|
$this->assertEquals( |
3734
|
|
|
new UrlAlias( |
3735
|
|
|
[ |
3736
|
|
|
'id' => '0-' . md5('dva'), |
3737
|
|
|
'type' => UrlAlias::LOCATION, |
3738
|
|
|
'destination' => 315, |
3739
|
|
|
'languageCodes' => [ |
3740
|
|
|
'cro-HR', |
3741
|
|
|
], |
3742
|
|
|
'pathData' => [ |
3743
|
|
|
[ |
3744
|
|
|
'always-available' => false, |
3745
|
|
|
'translations' => [ |
3746
|
|
|
'cro-HR' => 'dva', |
3747
|
|
|
], |
3748
|
|
|
], |
3749
|
|
|
], |
3750
|
|
|
'alwaysAvailable' => false, |
3751
|
|
|
'isHistory' => true, |
3752
|
|
|
'isCustom' => false, |
3753
|
|
|
'forward' => false, |
3754
|
|
|
] |
3755
|
|
|
), |
3756
|
|
|
$urlAlias |
3757
|
|
|
); |
3758
|
|
|
|
3759
|
|
|
$urlAlias = $handler->lookup('jedan-new'); |
3760
|
|
|
$this->assertEquals( |
3761
|
|
|
new UrlAlias( |
3762
|
|
|
[ |
3763
|
|
|
'id' => '0-' . md5('jedan-new'), |
3764
|
|
|
'type' => UrlAlias::LOCATION, |
3765
|
|
|
'destination' => 315, |
3766
|
|
|
'languageCodes' => [ |
3767
|
|
|
'cro-HR', |
3768
|
|
|
], |
3769
|
|
|
'pathData' => [ |
3770
|
|
|
[ |
3771
|
|
|
'always-available' => false, |
3772
|
|
|
'translations' => [ |
3773
|
|
|
'cro-HR' => 'jedan-new', |
3774
|
|
|
], |
3775
|
|
|
], |
3776
|
|
|
], |
3777
|
|
|
'alwaysAvailable' => false, |
3778
|
|
|
'isHistory' => false, |
3779
|
|
|
'isCustom' => false, |
3780
|
|
|
'forward' => false, |
3781
|
|
|
] |
3782
|
|
|
), |
3783
|
|
|
$urlAlias |
3784
|
|
|
); |
3785
|
|
|
|
3786
|
|
|
$urlAlias = $handler->lookup('dva-new'); |
3787
|
|
|
$this->assertEquals( |
3788
|
|
|
new UrlAlias( |
3789
|
|
|
[ |
3790
|
|
|
'id' => '0-' . md5('dva-new'), |
3791
|
|
|
'type' => UrlAlias::LOCATION, |
3792
|
|
|
'destination' => 314, |
3793
|
|
|
'languageCodes' => [ |
3794
|
|
|
'cro-HR', |
3795
|
|
|
], |
3796
|
|
|
'pathData' => [ |
3797
|
|
|
[ |
3798
|
|
|
'always-available' => false, |
3799
|
|
|
'translations' => [ |
3800
|
|
|
'cro-HR' => 'dva-new', |
3801
|
|
|
], |
3802
|
|
|
], |
3803
|
|
|
], |
3804
|
|
|
'alwaysAvailable' => false, |
3805
|
|
|
'isHistory' => false, |
3806
|
|
|
'isCustom' => false, |
3807
|
|
|
'forward' => false, |
3808
|
|
|
] |
3809
|
|
|
), |
3810
|
|
|
$urlAlias |
3811
|
|
|
); |
3812
|
|
|
} |
3813
|
|
|
|
3814
|
|
|
/** |
3815
|
|
|
* Test for the locationSwapped() method. |
3816
|
|
|
* |
3817
|
|
|
* @group swap |
3818
|
|
|
*/ |
3819
|
|
View Code Duplication |
public function testLocationSwappedSiblingsSimpleWithHistoryReverse() |
3820
|
|
|
{ |
3821
|
|
|
$handler = $this->getHandler(); |
3822
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_swap_siblings_simple_history.php'); |
3823
|
|
|
|
3824
|
|
|
$countBeforeReusing = $this->countRows(); |
3825
|
|
|
|
3826
|
|
|
$handler->locationSwapped(315, 2, 314, 2); |
3827
|
|
|
|
3828
|
|
|
$this->assertEquals( |
3829
|
|
|
$countBeforeReusing, |
3830
|
|
|
$this->countRows() |
3831
|
|
|
); |
3832
|
|
|
|
3833
|
|
|
$urlAlias = $handler->lookup('jedan'); |
3834
|
|
|
$this->assertEquals( |
3835
|
|
|
new UrlAlias( |
3836
|
|
|
[ |
3837
|
|
|
'id' => '0-' . md5('jedan'), |
3838
|
|
|
'type' => UrlAlias::LOCATION, |
3839
|
|
|
'destination' => 314, |
3840
|
|
|
'languageCodes' => [ |
3841
|
|
|
'cro-HR', |
3842
|
|
|
], |
3843
|
|
|
'pathData' => [ |
3844
|
|
|
[ |
3845
|
|
|
'always-available' => false, |
3846
|
|
|
'translations' => [ |
3847
|
|
|
'cro-HR' => 'jedan', |
3848
|
|
|
], |
3849
|
|
|
], |
3850
|
|
|
], |
3851
|
|
|
'alwaysAvailable' => false, |
3852
|
|
|
'isHistory' => true, |
3853
|
|
|
'isCustom' => false, |
3854
|
|
|
'forward' => false, |
3855
|
|
|
] |
3856
|
|
|
), |
3857
|
|
|
$urlAlias |
3858
|
|
|
); |
3859
|
|
|
|
3860
|
|
|
$urlAlias = $handler->lookup('dva'); |
3861
|
|
|
$this->assertEquals( |
3862
|
|
|
new UrlAlias( |
3863
|
|
|
[ |
3864
|
|
|
'id' => '0-' . md5('dva'), |
3865
|
|
|
'type' => UrlAlias::LOCATION, |
3866
|
|
|
'destination' => 315, |
3867
|
|
|
'languageCodes' => [ |
3868
|
|
|
'cro-HR', |
3869
|
|
|
], |
3870
|
|
|
'pathData' => [ |
3871
|
|
|
[ |
3872
|
|
|
'always-available' => false, |
3873
|
|
|
'translations' => [ |
3874
|
|
|
'cro-HR' => 'dva', |
3875
|
|
|
], |
3876
|
|
|
], |
3877
|
|
|
], |
3878
|
|
|
'alwaysAvailable' => false, |
3879
|
|
|
'isHistory' => true, |
3880
|
|
|
'isCustom' => false, |
3881
|
|
|
'forward' => false, |
3882
|
|
|
] |
3883
|
|
|
), |
3884
|
|
|
$urlAlias |
3885
|
|
|
); |
3886
|
|
|
|
3887
|
|
|
$urlAlias = $handler->lookup('jedan-new'); |
3888
|
|
|
$this->assertEquals( |
3889
|
|
|
new UrlAlias( |
3890
|
|
|
[ |
3891
|
|
|
'id' => '0-' . md5('jedan-new'), |
3892
|
|
|
'type' => UrlAlias::LOCATION, |
3893
|
|
|
'destination' => 315, |
3894
|
|
|
'languageCodes' => [ |
3895
|
|
|
'cro-HR', |
3896
|
|
|
], |
3897
|
|
|
'pathData' => [ |
3898
|
|
|
[ |
3899
|
|
|
'always-available' => false, |
3900
|
|
|
'translations' => [ |
3901
|
|
|
'cro-HR' => 'jedan-new', |
3902
|
|
|
], |
3903
|
|
|
], |
3904
|
|
|
], |
3905
|
|
|
'alwaysAvailable' => false, |
3906
|
|
|
'isHistory' => false, |
3907
|
|
|
'isCustom' => false, |
3908
|
|
|
'forward' => false, |
3909
|
|
|
] |
3910
|
|
|
), |
3911
|
|
|
$urlAlias |
3912
|
|
|
); |
3913
|
|
|
|
3914
|
|
|
$urlAlias = $handler->lookup('dva-new'); |
3915
|
|
|
$this->assertEquals( |
3916
|
|
|
new UrlAlias( |
3917
|
|
|
[ |
3918
|
|
|
'id' => '0-' . md5('dva-new'), |
3919
|
|
|
'type' => UrlAlias::LOCATION, |
3920
|
|
|
'destination' => 314, |
3921
|
|
|
'languageCodes' => [ |
3922
|
|
|
'cro-HR', |
3923
|
|
|
], |
3924
|
|
|
'pathData' => [ |
3925
|
|
|
[ |
3926
|
|
|
'always-available' => false, |
3927
|
|
|
'translations' => [ |
3928
|
|
|
'cro-HR' => 'dva-new', |
3929
|
|
|
], |
3930
|
|
|
], |
3931
|
|
|
], |
3932
|
|
|
'alwaysAvailable' => false, |
3933
|
|
|
'isHistory' => false, |
3934
|
|
|
'isCustom' => false, |
3935
|
|
|
'forward' => false, |
3936
|
|
|
] |
3937
|
|
|
), |
3938
|
|
|
$urlAlias |
3939
|
|
|
); |
3940
|
|
|
} |
3941
|
|
|
|
3942
|
|
|
/** |
3943
|
|
|
* Test for the locationSwapped() method. |
3944
|
|
|
* |
3945
|
|
|
* @group swap |
3946
|
|
|
*/ |
3947
|
|
View Code Duplication |
public function testLocationSwappedSiblingsSameName() |
3948
|
|
|
{ |
3949
|
|
|
$handler = $this->getHandler(); |
3950
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_swap_siblings_same_name.php'); |
3951
|
|
|
|
3952
|
|
|
$countBeforeReusing = $this->countRows(); |
3953
|
|
|
|
3954
|
|
|
$handler->locationSwapped(314, 2, 315, 2); |
3955
|
|
|
|
3956
|
|
|
$this->assertEquals( |
3957
|
|
|
$countBeforeReusing, |
3958
|
|
|
$this->countRows() |
3959
|
|
|
); |
3960
|
|
|
|
3961
|
|
|
$urlAlias = $handler->lookup('swap'); |
3962
|
|
|
$this->assertEquals( |
3963
|
|
|
new UrlAlias( |
3964
|
|
|
[ |
3965
|
|
|
'id' => '0-' . md5('swap'), |
3966
|
|
|
'type' => UrlAlias::LOCATION, |
3967
|
|
|
'destination' => 314, |
3968
|
|
|
'languageCodes' => [ |
3969
|
|
|
'cro-HR', |
3970
|
|
|
], |
3971
|
|
|
'pathData' => [ |
3972
|
|
|
[ |
3973
|
|
|
'always-available' => false, |
3974
|
|
|
'translations' => [ |
3975
|
|
|
'cro-HR' => 'swap', |
3976
|
|
|
], |
3977
|
|
|
], |
3978
|
|
|
], |
3979
|
|
|
'alwaysAvailable' => false, |
3980
|
|
|
'isHistory' => false, |
3981
|
|
|
'isCustom' => false, |
3982
|
|
|
'forward' => false, |
3983
|
|
|
] |
3984
|
|
|
), |
3985
|
|
|
$urlAlias |
3986
|
|
|
); |
3987
|
|
|
|
3988
|
|
|
$urlAlias = $handler->lookup('swap2'); |
3989
|
|
|
$this->assertEquals( |
3990
|
|
|
new UrlAlias( |
3991
|
|
|
[ |
3992
|
|
|
'id' => '0-' . md5('swap2'), |
3993
|
|
|
'type' => UrlAlias::LOCATION, |
3994
|
|
|
'destination' => 315, |
3995
|
|
|
'languageCodes' => [ |
3996
|
|
|
'cro-HR', |
3997
|
|
|
], |
3998
|
|
|
'pathData' => [ |
3999
|
|
|
[ |
4000
|
|
|
'always-available' => false, |
4001
|
|
|
'translations' => [ |
4002
|
|
|
'cro-HR' => 'swap2', |
4003
|
|
|
], |
4004
|
|
|
], |
4005
|
|
|
], |
4006
|
|
|
'alwaysAvailable' => false, |
4007
|
|
|
'isHistory' => false, |
4008
|
|
|
'isCustom' => false, |
4009
|
|
|
'forward' => false, |
4010
|
|
|
] |
4011
|
|
|
), |
4012
|
|
|
$urlAlias |
4013
|
|
|
); |
4014
|
|
|
} |
4015
|
|
|
|
4016
|
|
|
/** |
4017
|
|
|
* Test for the locationSwapped() method. |
4018
|
|
|
* |
4019
|
|
|
* @group swap |
4020
|
|
|
*/ |
4021
|
|
View Code Duplication |
public function testLocationSwappedSiblingsSameNameReverse() |
4022
|
|
|
{ |
4023
|
|
|
$handler = $this->getHandler(); |
4024
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_swap_siblings_same_name.php'); |
4025
|
|
|
|
4026
|
|
|
$countBeforeReusing = $this->countRows(); |
4027
|
|
|
|
4028
|
|
|
$handler->locationSwapped(315, 2, 314, 2); |
4029
|
|
|
|
4030
|
|
|
$this->assertEquals( |
4031
|
|
|
$countBeforeReusing, |
4032
|
|
|
$this->countRows() |
4033
|
|
|
); |
4034
|
|
|
|
4035
|
|
|
$urlAlias = $handler->lookup('swap'); |
4036
|
|
|
$this->assertEquals( |
4037
|
|
|
new UrlAlias( |
4038
|
|
|
[ |
4039
|
|
|
'id' => '0-' . md5('swap'), |
4040
|
|
|
'type' => UrlAlias::LOCATION, |
4041
|
|
|
'destination' => 314, |
4042
|
|
|
'languageCodes' => [ |
4043
|
|
|
'cro-HR', |
4044
|
|
|
], |
4045
|
|
|
'pathData' => [ |
4046
|
|
|
[ |
4047
|
|
|
'always-available' => false, |
4048
|
|
|
'translations' => [ |
4049
|
|
|
'cro-HR' => 'swap', |
4050
|
|
|
], |
4051
|
|
|
], |
4052
|
|
|
], |
4053
|
|
|
'alwaysAvailable' => false, |
4054
|
|
|
'isHistory' => false, |
4055
|
|
|
'isCustom' => false, |
4056
|
|
|
'forward' => false, |
4057
|
|
|
] |
4058
|
|
|
), |
4059
|
|
|
$urlAlias |
4060
|
|
|
); |
4061
|
|
|
|
4062
|
|
|
$urlAlias = $handler->lookup('swap2'); |
4063
|
|
|
$this->assertEquals( |
4064
|
|
|
new UrlAlias( |
4065
|
|
|
[ |
4066
|
|
|
'id' => '0-' . md5('swap2'), |
4067
|
|
|
'type' => UrlAlias::LOCATION, |
4068
|
|
|
'destination' => 315, |
4069
|
|
|
'languageCodes' => [ |
4070
|
|
|
'cro-HR', |
4071
|
|
|
], |
4072
|
|
|
'pathData' => [ |
4073
|
|
|
[ |
4074
|
|
|
'always-available' => false, |
4075
|
|
|
'translations' => [ |
4076
|
|
|
'cro-HR' => 'swap2', |
4077
|
|
|
], |
4078
|
|
|
], |
4079
|
|
|
], |
4080
|
|
|
'alwaysAvailable' => false, |
4081
|
|
|
'isHistory' => false, |
4082
|
|
|
'isCustom' => false, |
4083
|
|
|
'forward' => false, |
4084
|
|
|
] |
4085
|
|
|
), |
4086
|
|
|
$urlAlias |
4087
|
|
|
); |
4088
|
|
|
} |
4089
|
|
|
|
4090
|
|
|
/** |
4091
|
|
|
* Test for the locationSwapped() method. |
4092
|
|
|
* |
4093
|
|
|
* @group swap |
4094
|
|
|
*/ |
4095
|
|
|
public function testLocationSwappedSiblingsSameNameMultipleLanguages() |
4096
|
|
|
{ |
4097
|
|
|
$handler = $this->getHandler(); |
4098
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_swap_siblings_same_name_multilang.php'); |
4099
|
|
|
|
4100
|
|
|
$countBeforeReusing = $this->countRows(); |
4101
|
|
|
|
4102
|
|
|
$handler->locationSwapped(314, 2, 315, 2); |
4103
|
|
|
|
4104
|
|
|
$this->assertEquals( |
4105
|
|
|
$countBeforeReusing, |
4106
|
|
|
$this->countRows() |
4107
|
|
|
); |
4108
|
|
|
|
4109
|
|
|
$urlAlias = $handler->lookup('swap-hr'); |
4110
|
|
|
$this->assertEquals( |
4111
|
|
|
new UrlAlias( |
4112
|
|
|
[ |
4113
|
|
|
'id' => '0-' . md5('swap-hr'), |
4114
|
|
|
'type' => UrlAlias::LOCATION, |
4115
|
|
|
'destination' => 314, |
4116
|
|
|
'languageCodes' => [ |
4117
|
|
|
'cro-HR', |
4118
|
|
|
], |
4119
|
|
|
'pathData' => [ |
4120
|
|
|
[ |
4121
|
|
|
'always-available' => false, |
4122
|
|
|
'translations' => [ |
4123
|
|
|
'cro-HR' => 'swap-hr', |
4124
|
|
|
'eng-GB' => 'swap-en2', |
4125
|
|
|
], |
4126
|
|
|
], |
4127
|
|
|
], |
4128
|
|
|
'alwaysAvailable' => false, |
4129
|
|
|
'isHistory' => false, |
4130
|
|
|
'isCustom' => false, |
4131
|
|
|
'forward' => false, |
4132
|
|
|
] |
4133
|
|
|
), |
4134
|
|
|
$urlAlias |
4135
|
|
|
); |
4136
|
|
|
|
4137
|
|
|
$urlAlias = $handler->lookup('swap-hr2'); |
4138
|
|
|
$this->assertEquals( |
4139
|
|
|
new UrlAlias( |
4140
|
|
|
[ |
4141
|
|
|
'id' => '0-' . md5('swap-hr2'), |
4142
|
|
|
'type' => UrlAlias::LOCATION, |
4143
|
|
|
'destination' => 315, |
4144
|
|
|
'languageCodes' => [ |
4145
|
|
|
'cro-HR', |
4146
|
|
|
], |
4147
|
|
|
'pathData' => [ |
4148
|
|
|
[ |
4149
|
|
|
'always-available' => false, |
4150
|
|
|
'translations' => [ |
4151
|
|
|
'cro-HR' => 'swap-hr2', |
4152
|
|
|
'eng-GB' => 'swap-en', |
4153
|
|
|
], |
4154
|
|
|
], |
4155
|
|
|
], |
4156
|
|
|
'alwaysAvailable' => false, |
4157
|
|
|
'isHistory' => false, |
4158
|
|
|
'isCustom' => false, |
4159
|
|
|
'forward' => false, |
4160
|
|
|
] |
4161
|
|
|
), |
4162
|
|
|
$urlAlias |
4163
|
|
|
); |
4164
|
|
|
|
4165
|
|
|
$urlAlias = $handler->lookup('swap-en'); |
4166
|
|
|
$this->assertEquals( |
4167
|
|
|
new UrlAlias( |
4168
|
|
|
[ |
4169
|
|
|
'id' => '0-' . md5('swap-en'), |
4170
|
|
|
'type' => UrlAlias::LOCATION, |
4171
|
|
|
'destination' => 315, |
4172
|
|
|
'languageCodes' => [ |
4173
|
|
|
'eng-GB', |
4174
|
|
|
], |
4175
|
|
|
'pathData' => [ |
4176
|
|
|
[ |
4177
|
|
|
'always-available' => false, |
4178
|
|
|
'translations' => [ |
4179
|
|
|
'cro-HR' => 'swap-hr2', |
4180
|
|
|
'eng-GB' => 'swap-en', |
4181
|
|
|
], |
4182
|
|
|
], |
4183
|
|
|
], |
4184
|
|
|
'alwaysAvailable' => false, |
4185
|
|
|
'isHistory' => false, |
4186
|
|
|
'isCustom' => false, |
4187
|
|
|
'forward' => false, |
4188
|
|
|
] |
4189
|
|
|
), |
4190
|
|
|
$urlAlias |
4191
|
|
|
); |
4192
|
|
|
|
4193
|
|
|
$urlAlias = $handler->lookup('swap-en2'); |
4194
|
|
|
$this->assertEquals( |
4195
|
|
|
new UrlAlias( |
4196
|
|
|
[ |
4197
|
|
|
'id' => '0-' . md5('swap-en2'), |
4198
|
|
|
'type' => UrlAlias::LOCATION, |
4199
|
|
|
'destination' => 314, |
4200
|
|
|
'languageCodes' => [ |
4201
|
|
|
'eng-GB', |
4202
|
|
|
], |
4203
|
|
|
'pathData' => [ |
4204
|
|
|
[ |
4205
|
|
|
'always-available' => false, |
4206
|
|
|
'translations' => [ |
4207
|
|
|
'cro-HR' => 'swap-hr', |
4208
|
|
|
'eng-GB' => 'swap-en2', |
4209
|
|
|
], |
4210
|
|
|
], |
4211
|
|
|
], |
4212
|
|
|
'alwaysAvailable' => false, |
4213
|
|
|
'isHistory' => false, |
4214
|
|
|
'isCustom' => false, |
4215
|
|
|
'forward' => false, |
4216
|
|
|
] |
4217
|
|
|
), |
4218
|
|
|
$urlAlias |
4219
|
|
|
); |
4220
|
|
|
} |
4221
|
|
|
|
4222
|
|
|
/** |
4223
|
|
|
* Test for the locationSwapped() method. |
4224
|
|
|
* |
4225
|
|
|
* @group swap |
4226
|
|
|
*/ |
4227
|
|
|
public function testLocationSwappedMultipleLanguagesSimple() |
4228
|
|
|
{ |
4229
|
|
|
$handler = $this->getHandler(); |
4230
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_swap_multilang_simple.php'); |
4231
|
|
|
|
4232
|
|
|
$urlAlias1HRExpected = $handler->lookup('jedan/swap-hr'); |
4233
|
|
|
$urlAlias1ENExpected = $handler->lookup('jedan/swap-en'); |
4234
|
|
|
$urlAlias2HRExpected = $handler->lookup('dva/swap-hr'); |
4235
|
|
|
$urlAlias2ENExpected = $handler->lookup('dva/swap-en'); |
4236
|
|
|
|
4237
|
|
|
$countBeforeReusing = $this->countRows(); |
4238
|
|
|
|
4239
|
|
|
$handler->locationSwapped(316, 314, 317, 315); |
4240
|
|
|
|
4241
|
|
|
$this->assertEquals( |
4242
|
|
|
$countBeforeReusing, |
4243
|
|
|
$this->countRows() |
4244
|
|
|
); |
4245
|
|
|
|
4246
|
|
|
$urlAlias1HR = $handler->lookup('jedan/swap-hr'); |
4247
|
|
|
$urlAlias1EN = $handler->lookup('jedan/swap-en'); |
4248
|
|
|
$urlAlias2HR = $handler->lookup('dva/swap-hr'); |
4249
|
|
|
$urlAlias2EN = $handler->lookup('dva/swap-en'); |
4250
|
|
|
|
4251
|
|
|
$this->assertEquals($urlAlias1HRExpected, $urlAlias1HR); |
4252
|
|
|
$this->assertEquals($urlAlias1ENExpected, $urlAlias1EN); |
4253
|
|
|
$this->assertEquals($urlAlias2HRExpected, $urlAlias2HR); |
4254
|
|
|
$this->assertEquals($urlAlias2ENExpected, $urlAlias2EN); |
4255
|
|
|
} |
4256
|
|
|
|
4257
|
|
|
/** |
4258
|
|
|
* Test for the locationSwapped() method. |
4259
|
|
|
* |
4260
|
|
|
* @group swap |
4261
|
|
|
*/ |
4262
|
|
|
public function testLocationSwappedMultipleLanguagesDifferentLanguagesSimple() |
4263
|
|
|
{ |
4264
|
|
|
$handler = $this->getHandler(); |
4265
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_swap_multilang_diff_simple.php'); |
4266
|
|
|
|
4267
|
|
|
$countBeforeReusing = $this->countRows(); |
4268
|
|
|
|
4269
|
|
|
$handler->locationSwapped(316, 314, 317, 315); |
4270
|
|
|
|
4271
|
|
|
$this->assertEquals( |
4272
|
|
|
$countBeforeReusing + 2, |
4273
|
|
|
$this->countRows() |
4274
|
|
|
); |
4275
|
|
|
|
4276
|
|
|
$urlAlias = $handler->lookup('jedan/swap-hr'); |
4277
|
|
|
$this->assertEquals( |
4278
|
|
|
new UrlAlias( |
4279
|
|
|
[ |
4280
|
|
|
'id' => '2-' . md5('swap-hr'), |
4281
|
|
|
'type' => UrlAlias::LOCATION, |
4282
|
|
|
'destination' => 316, |
4283
|
|
|
'languageCodes' => [ |
4284
|
|
|
'cro-HR', |
4285
|
|
|
], |
4286
|
|
|
'pathData' => [ |
4287
|
|
|
[ |
4288
|
|
|
'always-available' => false, |
4289
|
|
|
'translations' => [ |
4290
|
|
|
'cro-HR' => 'jedan', |
4291
|
|
|
], |
4292
|
|
|
], |
4293
|
|
|
[ |
4294
|
|
|
'always-available' => false, |
4295
|
|
|
'translations' => [ |
4296
|
|
|
'cro-HR' => 'swap-hr', |
4297
|
|
|
'ger-DE' => 'swap-de', |
4298
|
|
|
], |
4299
|
|
|
], |
4300
|
|
|
], |
4301
|
|
|
'alwaysAvailable' => false, |
4302
|
|
|
'isHistory' => false, |
4303
|
|
|
'isCustom' => false, |
4304
|
|
|
'forward' => false, |
4305
|
|
|
] |
4306
|
|
|
), |
4307
|
|
|
$urlAlias |
4308
|
|
|
); |
4309
|
|
|
|
4310
|
|
|
$urlAlias = $handler->lookup('jedan/swap-de'); |
4311
|
|
|
$this->assertEquals( |
4312
|
|
|
new UrlAlias( |
4313
|
|
|
[ |
4314
|
|
|
'id' => '2-' . md5('swap-de'), |
4315
|
|
|
'type' => UrlAlias::LOCATION, |
4316
|
|
|
'destination' => 316, |
4317
|
|
|
'languageCodes' => [ |
4318
|
|
|
'ger-DE', |
4319
|
|
|
], |
4320
|
|
|
'pathData' => [ |
4321
|
|
|
[ |
4322
|
|
|
'always-available' => false, |
4323
|
|
|
'translations' => [ |
4324
|
|
|
'cro-HR' => 'jedan', |
4325
|
|
|
], |
4326
|
|
|
], |
4327
|
|
|
[ |
4328
|
|
|
'always-available' => false, |
4329
|
|
|
'translations' => [ |
4330
|
|
|
'cro-HR' => 'swap-hr', |
4331
|
|
|
'ger-DE' => 'swap-de', |
4332
|
|
|
], |
4333
|
|
|
], |
4334
|
|
|
], |
4335
|
|
|
'alwaysAvailable' => false, |
4336
|
|
|
'isHistory' => false, |
4337
|
|
|
'isCustom' => false, |
4338
|
|
|
'forward' => false, |
4339
|
|
|
] |
4340
|
|
|
), |
4341
|
|
|
$urlAlias |
4342
|
|
|
); |
4343
|
|
|
|
4344
|
|
|
$urlAlias = $handler->lookup('jedan/swap-en'); |
4345
|
|
|
$this->assertEquals( |
4346
|
|
|
new UrlAlias( |
4347
|
|
|
[ |
4348
|
|
|
'id' => '2-' . md5('swap-en'), |
4349
|
|
|
'type' => UrlAlias::LOCATION, |
4350
|
|
|
'destination' => 316, |
4351
|
|
|
'languageCodes' => [ |
4352
|
|
|
'eng-GB', |
4353
|
|
|
], |
4354
|
|
|
'pathData' => [ |
4355
|
|
|
[ |
4356
|
|
|
'always-available' => false, |
4357
|
|
|
'translations' => [ |
4358
|
|
|
'cro-HR' => 'jedan', |
4359
|
|
|
], |
4360
|
|
|
], |
4361
|
|
|
[ |
4362
|
|
|
'always-available' => false, |
4363
|
|
|
'translations' => [ |
4364
|
|
|
'eng-GB' => 'swap-en', |
4365
|
|
|
], |
4366
|
|
|
], |
4367
|
|
|
], |
4368
|
|
|
'alwaysAvailable' => false, |
4369
|
|
|
'isHistory' => true, |
4370
|
|
|
'isCustom' => false, |
4371
|
|
|
'forward' => false, |
4372
|
|
|
] |
4373
|
|
|
), |
4374
|
|
|
$urlAlias |
4375
|
|
|
); |
4376
|
|
|
|
4377
|
|
|
$urlAlias = $handler->lookup('dva/swap-hr'); |
4378
|
|
|
$this->assertEquals( |
4379
|
|
|
new UrlAlias( |
4380
|
|
|
[ |
4381
|
|
|
'id' => '3-' . md5('swap-hr'), |
4382
|
|
|
'type' => UrlAlias::LOCATION, |
4383
|
|
|
'destination' => 317, |
4384
|
|
|
'languageCodes' => [ |
4385
|
|
|
'cro-HR', |
4386
|
|
|
], |
4387
|
|
|
'pathData' => [ |
4388
|
|
|
[ |
4389
|
|
|
'always-available' => false, |
4390
|
|
|
'translations' => [ |
4391
|
|
|
'cro-HR' => 'dva', |
4392
|
|
|
], |
4393
|
|
|
], |
4394
|
|
|
[ |
4395
|
|
|
'always-available' => false, |
4396
|
|
|
'translations' => [ |
4397
|
|
|
'eng-GB' => 'swap-en', |
4398
|
|
|
'cro-HR' => 'swap-hr', |
4399
|
|
|
], |
4400
|
|
|
], |
4401
|
|
|
], |
4402
|
|
|
'alwaysAvailable' => false, |
4403
|
|
|
'isHistory' => false, |
4404
|
|
|
'isCustom' => false, |
4405
|
|
|
'forward' => false, |
4406
|
|
|
] |
4407
|
|
|
), |
4408
|
|
|
$urlAlias |
4409
|
|
|
); |
4410
|
|
|
|
4411
|
|
|
$urlAlias = $handler->lookup('dva/swap-en'); |
4412
|
|
|
$this->assertEquals( |
4413
|
|
|
new UrlAlias( |
4414
|
|
|
[ |
4415
|
|
|
'id' => '3-' . md5('swap-en'), |
4416
|
|
|
'type' => UrlAlias::LOCATION, |
4417
|
|
|
'destination' => 317, |
4418
|
|
|
'languageCodes' => [ |
4419
|
|
|
'eng-GB', |
4420
|
|
|
], |
4421
|
|
|
'pathData' => [ |
4422
|
|
|
[ |
4423
|
|
|
'always-available' => false, |
4424
|
|
|
'translations' => [ |
4425
|
|
|
'cro-HR' => 'dva', |
4426
|
|
|
], |
4427
|
|
|
], |
4428
|
|
|
[ |
4429
|
|
|
'always-available' => false, |
4430
|
|
|
'translations' => [ |
4431
|
|
|
'eng-GB' => 'swap-en', |
4432
|
|
|
'cro-HR' => 'swap-hr', |
4433
|
|
|
], |
4434
|
|
|
], |
4435
|
|
|
], |
4436
|
|
|
'alwaysAvailable' => false, |
4437
|
|
|
'isHistory' => false, |
4438
|
|
|
'isCustom' => false, |
4439
|
|
|
'forward' => false, |
4440
|
|
|
] |
4441
|
|
|
), |
4442
|
|
|
$urlAlias |
4443
|
|
|
); |
4444
|
|
|
|
4445
|
|
|
$urlAlias = $handler->lookup('dva/swap-de'); |
4446
|
|
|
$this->assertEquals( |
4447
|
|
|
new UrlAlias( |
4448
|
|
|
[ |
4449
|
|
|
'id' => '3-' . md5('swap-de'), |
4450
|
|
|
'type' => UrlAlias::LOCATION, |
4451
|
|
|
'destination' => 317, |
4452
|
|
|
'languageCodes' => [ |
4453
|
|
|
'ger-DE', |
4454
|
|
|
], |
4455
|
|
|
'pathData' => [ |
4456
|
|
|
[ |
4457
|
|
|
'always-available' => false, |
4458
|
|
|
'translations' => [ |
4459
|
|
|
'cro-HR' => 'dva', |
4460
|
|
|
], |
4461
|
|
|
], |
4462
|
|
|
[ |
4463
|
|
|
'always-available' => false, |
4464
|
|
|
'translations' => [ |
4465
|
|
|
'ger-DE' => 'swap-de', |
4466
|
|
|
], |
4467
|
|
|
], |
4468
|
|
|
], |
4469
|
|
|
'alwaysAvailable' => false, |
4470
|
|
|
'isHistory' => true, |
4471
|
|
|
'isCustom' => false, |
4472
|
|
|
'forward' => false, |
4473
|
|
|
] |
4474
|
|
|
), |
4475
|
|
|
$urlAlias |
4476
|
|
|
); |
4477
|
|
|
} |
4478
|
|
|
|
4479
|
|
|
/** |
4480
|
|
|
* Test for the locationSwapped() method. |
4481
|
|
|
* |
4482
|
|
|
* @group swap |
4483
|
|
|
*/ |
4484
|
|
|
public function testLocationSwappedMultipleLanguagesDifferentLanguages() |
4485
|
|
|
{ |
4486
|
|
|
$handler = $this->getHandler(); |
4487
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_swap_multilang_diff.php'); |
4488
|
|
|
|
4489
|
|
|
$countBeforeReusing = $this->countRows(); |
4490
|
|
|
|
4491
|
|
|
$handler->locationSwapped(317, 315, 316, 314); |
4492
|
|
|
|
4493
|
|
|
$this->assertEquals( |
4494
|
|
|
$countBeforeReusing + 2, |
4495
|
|
|
$this->countRows() |
4496
|
|
|
); |
4497
|
|
|
|
4498
|
|
|
$urlAlias = $handler->lookup('jedan/swap-this'); |
4499
|
|
|
$this->assertEquals( |
4500
|
|
|
new UrlAlias( |
4501
|
|
|
[ |
4502
|
|
|
'id' => '2-' . md5('swap-this'), |
4503
|
|
|
'type' => UrlAlias::LOCATION, |
4504
|
|
|
'destination' => 316, |
4505
|
|
|
'languageCodes' => [ |
4506
|
|
|
'ger-DE', |
4507
|
|
|
'nor-NO', |
4508
|
|
|
], |
4509
|
|
|
'pathData' => [ |
4510
|
|
|
[ |
4511
|
|
|
'always-available' => false, |
4512
|
|
|
'translations' => [ |
4513
|
|
|
'cro-HR' => 'jedan', |
4514
|
|
|
], |
4515
|
|
|
], |
4516
|
|
|
[ |
4517
|
|
|
'always-available' => false, |
4518
|
|
|
'translations' => [ |
4519
|
|
|
'cro-HR' => 'swap-hr', |
4520
|
|
|
'ger-DE' => 'swap-this', |
4521
|
|
|
'nor-NO' => 'swap-this', |
4522
|
|
|
], |
4523
|
|
|
], |
4524
|
|
|
], |
4525
|
|
|
'alwaysAvailable' => false, |
4526
|
|
|
'isHistory' => false, |
4527
|
|
|
'isCustom' => false, |
4528
|
|
|
'forward' => false, |
4529
|
|
|
] |
4530
|
|
|
), |
4531
|
|
|
$urlAlias |
4532
|
|
|
); |
4533
|
|
|
|
4534
|
|
|
$urlAlias = $handler->lookup('jedan/swap-en'); |
4535
|
|
|
$this->assertEquals( |
4536
|
|
|
new UrlAlias( |
4537
|
|
|
[ |
4538
|
|
|
'id' => '2-' . md5('swap-en'), |
4539
|
|
|
'type' => UrlAlias::LOCATION, |
4540
|
|
|
'destination' => 316, |
4541
|
|
|
'languageCodes' => [ |
4542
|
|
|
'eng-GB', |
4543
|
|
|
], |
4544
|
|
|
'pathData' => [ |
4545
|
|
|
[ |
4546
|
|
|
'always-available' => false, |
4547
|
|
|
'translations' => [ |
4548
|
|
|
'cro-HR' => 'jedan', |
4549
|
|
|
], |
4550
|
|
|
], |
4551
|
|
|
[ |
4552
|
|
|
'always-available' => false, |
4553
|
|
|
'translations' => [ |
4554
|
|
|
'eng-GB' => 'swap-en', |
4555
|
|
|
], |
4556
|
|
|
], |
4557
|
|
|
], |
4558
|
|
|
'alwaysAvailable' => false, |
4559
|
|
|
'isHistory' => true, |
4560
|
|
|
'isCustom' => false, |
4561
|
|
|
'forward' => false, |
4562
|
|
|
] |
4563
|
|
|
), |
4564
|
|
|
$urlAlias |
4565
|
|
|
); |
4566
|
|
|
|
4567
|
|
|
$urlAlias = $handler->lookup('dva/swap-hr'); |
4568
|
|
|
$this->assertEquals( |
4569
|
|
|
new UrlAlias( |
4570
|
|
|
[ |
4571
|
|
|
'id' => '3-' . md5('swap-hr'), |
4572
|
|
|
'type' => UrlAlias::LOCATION, |
4573
|
|
|
'destination' => 317, |
4574
|
|
|
'languageCodes' => [ |
4575
|
|
|
'cro-HR', |
4576
|
|
|
], |
4577
|
|
|
'pathData' => [ |
4578
|
|
|
[ |
4579
|
|
|
'always-available' => false, |
4580
|
|
|
'translations' => [ |
4581
|
|
|
'cro-HR' => 'dva', |
4582
|
|
|
], |
4583
|
|
|
], |
4584
|
|
|
[ |
4585
|
|
|
'always-available' => false, |
4586
|
|
|
'translations' => [ |
4587
|
|
|
'cro-HR' => 'swap-hr', |
4588
|
|
|
], |
4589
|
|
|
], |
4590
|
|
|
], |
4591
|
|
|
'alwaysAvailable' => false, |
4592
|
|
|
'isHistory' => true, |
4593
|
|
|
'isCustom' => false, |
4594
|
|
|
'forward' => false, |
4595
|
|
|
] |
4596
|
|
|
), |
4597
|
|
|
$urlAlias |
4598
|
|
|
); |
4599
|
|
|
|
4600
|
|
|
$urlAlias = $handler->lookup('dva/swap-this'); |
4601
|
|
|
$this->assertEquals( |
4602
|
|
|
new UrlAlias( |
4603
|
|
|
[ |
4604
|
|
|
'id' => '3-' . md5('swap-this'), |
4605
|
|
|
'type' => UrlAlias::LOCATION, |
4606
|
|
|
'destination' => 317, |
4607
|
|
|
'languageCodes' => [ |
4608
|
|
|
'cro-HR', |
4609
|
|
|
'ger-DE', |
4610
|
|
|
], |
4611
|
|
|
'pathData' => [ |
4612
|
|
|
[ |
4613
|
|
|
'always-available' => false, |
4614
|
|
|
'translations' => [ |
4615
|
|
|
'cro-HR' => 'dva', |
4616
|
|
|
], |
4617
|
|
|
], |
4618
|
|
|
[ |
4619
|
|
|
'always-available' => false, |
4620
|
|
|
'translations' => [ |
4621
|
|
|
'cro-HR' => 'swap-this', |
4622
|
|
|
'ger-DE' => 'swap-this', |
4623
|
|
|
'eng-GB' => 'swap-en', |
4624
|
|
|
], |
4625
|
|
|
], |
4626
|
|
|
], |
4627
|
|
|
'alwaysAvailable' => false, |
4628
|
|
|
'isHistory' => false, |
4629
|
|
|
'isCustom' => false, |
4630
|
|
|
'forward' => false, |
4631
|
|
|
] |
4632
|
|
|
), |
4633
|
|
|
$urlAlias |
4634
|
|
|
); |
4635
|
|
|
} |
4636
|
|
|
|
4637
|
|
|
/** |
4638
|
|
|
* Test for the locationSwapped() method. |
4639
|
|
|
* |
4640
|
|
|
* @group swap |
4641
|
|
|
*/ |
4642
|
|
|
public function testLocationSwappedMultipleLanguagesWithCompositeHistory() |
4643
|
|
|
{ |
4644
|
|
|
$handler = $this->getHandler(); |
4645
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_swap_multilang_cleanup_composite.php'); |
4646
|
|
|
|
4647
|
|
|
$countBeforeReusing = $this->countRows(); |
4648
|
|
|
|
4649
|
|
|
$handler->locationSwapped(317, 315, 316, 314); |
4650
|
|
|
|
4651
|
|
|
$this->assertEquals( |
4652
|
|
|
$countBeforeReusing + 4, |
4653
|
|
|
$this->countRows() |
4654
|
|
|
); |
4655
|
|
|
|
4656
|
|
|
$urlAlias = $handler->lookup('jedan/swap-this'); |
4657
|
|
|
$this->assertEquals( |
4658
|
|
|
new UrlAlias( |
4659
|
|
|
[ |
4660
|
|
|
'id' => '2-' . md5('swap-this'), |
4661
|
|
|
'type' => UrlAlias::LOCATION, |
4662
|
|
|
'destination' => 316, |
4663
|
|
|
'languageCodes' => [ |
4664
|
|
|
'cro-HR', |
4665
|
|
|
], |
4666
|
|
|
'pathData' => [ |
4667
|
|
|
[ |
4668
|
|
|
'always-available' => false, |
4669
|
|
|
'translations' => [ |
4670
|
|
|
'cro-HR' => 'jedan', |
4671
|
|
|
], |
4672
|
|
|
], |
4673
|
|
|
[ |
4674
|
|
|
'always-available' => false, |
4675
|
|
|
'translations' => [ |
4676
|
|
|
'cro-HR' => 'swap-this', |
4677
|
|
|
], |
4678
|
|
|
], |
4679
|
|
|
], |
4680
|
|
|
'alwaysAvailable' => false, |
4681
|
|
|
'isHistory' => true, |
4682
|
|
|
'isCustom' => false, |
4683
|
|
|
'forward' => false, |
4684
|
|
|
] |
4685
|
|
|
), |
4686
|
|
|
$urlAlias |
4687
|
|
|
); |
4688
|
|
|
|
4689
|
|
|
$urlAlias = $handler->lookup('jedan/swap-en'); |
4690
|
|
|
$this->assertEquals( |
4691
|
|
|
new UrlAlias( |
4692
|
|
|
[ |
4693
|
|
|
'id' => '2-' . md5('swap-en'), |
4694
|
|
|
'type' => UrlAlias::LOCATION, |
4695
|
|
|
'destination' => 316, |
4696
|
|
|
'languageCodes' => [ |
4697
|
|
|
'eng-GB', |
4698
|
|
|
], |
4699
|
|
|
'pathData' => [ |
4700
|
|
|
[ |
4701
|
|
|
'always-available' => false, |
4702
|
|
|
'translations' => [ |
4703
|
|
|
'cro-HR' => 'jedan', |
4704
|
|
|
], |
4705
|
|
|
], |
4706
|
|
|
[ |
4707
|
|
|
'always-available' => false, |
4708
|
|
|
'translations' => [ |
4709
|
|
|
'eng-GB' => 'swap-en', |
4710
|
|
|
], |
4711
|
|
|
], |
4712
|
|
|
], |
4713
|
|
|
'alwaysAvailable' => false, |
4714
|
|
|
'isHistory' => true, |
4715
|
|
|
'isCustom' => false, |
4716
|
|
|
'forward' => false, |
4717
|
|
|
] |
4718
|
|
|
), |
4719
|
|
|
$urlAlias |
4720
|
|
|
); |
4721
|
|
|
|
4722
|
|
|
$urlAlias = $handler->lookup('jedan/swap-hr'); |
4723
|
|
|
$this->assertEquals( |
4724
|
|
|
new UrlAlias( |
4725
|
|
|
[ |
4726
|
|
|
'id' => '2-' . md5('swap-hr'), |
4727
|
|
|
'type' => UrlAlias::LOCATION, |
4728
|
|
|
'destination' => 316, |
4729
|
|
|
'languageCodes' => [ |
4730
|
|
|
'cro-HR', |
4731
|
|
|
], |
4732
|
|
|
'pathData' => [ |
4733
|
|
|
[ |
4734
|
|
|
'always-available' => false, |
4735
|
|
|
'translations' => [ |
4736
|
|
|
'cro-HR' => 'jedan', |
4737
|
|
|
], |
4738
|
|
|
], |
4739
|
|
|
[ |
4740
|
|
|
'always-available' => false, |
4741
|
|
|
'translations' => [ |
4742
|
|
|
'cro-HR' => 'swap-hr', |
4743
|
|
|
'ger-DE' => 'swap-that', |
4744
|
|
|
'nor-NO' => 'swap-that', |
4745
|
|
|
], |
4746
|
|
|
], |
4747
|
|
|
], |
4748
|
|
|
'alwaysAvailable' => false, |
4749
|
|
|
'isHistory' => false, |
4750
|
|
|
'isCustom' => false, |
4751
|
|
|
'forward' => false, |
4752
|
|
|
] |
4753
|
|
|
), |
4754
|
|
|
$urlAlias |
4755
|
|
|
); |
4756
|
|
|
|
4757
|
|
|
$urlAlias = $handler->lookup('jedan/swap-that'); |
4758
|
|
|
$this->assertEquals( |
4759
|
|
|
new UrlAlias( |
4760
|
|
|
[ |
4761
|
|
|
'id' => '2-' . md5('swap-that'), |
4762
|
|
|
'type' => UrlAlias::LOCATION, |
4763
|
|
|
'destination' => 316, |
4764
|
|
|
'languageCodes' => [ |
4765
|
|
|
'ger-DE', |
4766
|
|
|
'nor-NO', |
4767
|
|
|
], |
4768
|
|
|
'pathData' => [ |
4769
|
|
|
[ |
4770
|
|
|
'always-available' => false, |
4771
|
|
|
'translations' => [ |
4772
|
|
|
'cro-HR' => 'jedan', |
4773
|
|
|
], |
4774
|
|
|
], |
4775
|
|
|
[ |
4776
|
|
|
'always-available' => false, |
4777
|
|
|
'translations' => [ |
4778
|
|
|
'cro-HR' => 'swap-hr', |
4779
|
|
|
'ger-DE' => 'swap-that', |
4780
|
|
|
'nor-NO' => 'swap-that', |
4781
|
|
|
], |
4782
|
|
|
], |
4783
|
|
|
], |
4784
|
|
|
'alwaysAvailable' => false, |
4785
|
|
|
'isHistory' => false, |
4786
|
|
|
'isCustom' => false, |
4787
|
|
|
'forward' => false, |
4788
|
|
|
] |
4789
|
|
|
), |
4790
|
|
|
$urlAlias |
4791
|
|
|
); |
4792
|
|
|
|
4793
|
|
|
$urlAlias = $handler->lookup('dva/swap-hr'); |
4794
|
|
|
$this->assertEquals( |
4795
|
|
|
new UrlAlias( |
4796
|
|
|
[ |
4797
|
|
|
'id' => '3-' . md5('swap-hr'), |
4798
|
|
|
'type' => UrlAlias::LOCATION, |
4799
|
|
|
'destination' => 317, |
4800
|
|
|
'languageCodes' => [ |
4801
|
|
|
'cro-HR', |
4802
|
|
|
], |
4803
|
|
|
'pathData' => [ |
4804
|
|
|
[ |
4805
|
|
|
'always-available' => false, |
4806
|
|
|
'translations' => [ |
4807
|
|
|
'cro-HR' => 'dva', |
4808
|
|
|
], |
4809
|
|
|
], |
4810
|
|
|
[ |
4811
|
|
|
'always-available' => false, |
4812
|
|
|
'translations' => [ |
4813
|
|
|
'cro-HR' => 'swap-hr', |
4814
|
|
|
], |
4815
|
|
|
], |
4816
|
|
|
], |
4817
|
|
|
'alwaysAvailable' => false, |
4818
|
|
|
'isHistory' => true, |
4819
|
|
|
'isCustom' => false, |
4820
|
|
|
'forward' => false, |
4821
|
|
|
] |
4822
|
|
|
), |
4823
|
|
|
$urlAlias |
4824
|
|
|
); |
4825
|
|
|
|
4826
|
|
|
$urlAlias = $handler->lookup('dva/swap-that'); |
4827
|
|
|
$this->assertEquals( |
4828
|
|
|
new UrlAlias( |
4829
|
|
|
[ |
4830
|
|
|
'id' => '3-' . md5('swap-that'), |
4831
|
|
|
'type' => UrlAlias::LOCATION, |
4832
|
|
|
'destination' => 317, |
4833
|
|
|
'languageCodes' => [ |
4834
|
|
|
'ger-DE', |
4835
|
|
|
'nor-NO', |
4836
|
|
|
], |
4837
|
|
|
'pathData' => [ |
4838
|
|
|
[ |
4839
|
|
|
'always-available' => false, |
4840
|
|
|
'translations' => [ |
4841
|
|
|
'cro-HR' => 'dva', |
4842
|
|
|
], |
4843
|
|
|
], |
4844
|
|
|
[ |
4845
|
|
|
'always-available' => false, |
4846
|
|
|
'translations' => [ |
4847
|
|
|
'ger-DE' => 'swap-that', |
4848
|
|
|
'nor-NO' => 'swap-that', |
4849
|
|
|
], |
4850
|
|
|
], |
4851
|
|
|
], |
4852
|
|
|
'alwaysAvailable' => false, |
4853
|
|
|
'isHistory' => true, |
4854
|
|
|
'isCustom' => false, |
4855
|
|
|
'forward' => false, |
4856
|
|
|
] |
4857
|
|
|
), |
4858
|
|
|
$urlAlias |
4859
|
|
|
); |
4860
|
|
|
|
4861
|
|
|
$urlAlias = $handler->lookup('dva/swap-this'); |
4862
|
|
|
$this->assertEquals( |
4863
|
|
|
new UrlAlias( |
4864
|
|
|
[ |
4865
|
|
|
'id' => '3-' . md5('swap-this'), |
4866
|
|
|
'type' => UrlAlias::LOCATION, |
4867
|
|
|
'destination' => 317, |
4868
|
|
|
'languageCodes' => [ |
4869
|
|
|
'cro-HR', |
4870
|
|
|
], |
4871
|
|
|
'pathData' => [ |
4872
|
|
|
[ |
4873
|
|
|
'always-available' => false, |
4874
|
|
|
'translations' => [ |
4875
|
|
|
'cro-HR' => 'dva', |
4876
|
|
|
], |
4877
|
|
|
], |
4878
|
|
|
[ |
4879
|
|
|
'always-available' => false, |
4880
|
|
|
'translations' => [ |
4881
|
|
|
'cro-HR' => 'swap-this', |
4882
|
|
|
'eng-GB' => 'swap-en', |
4883
|
|
|
], |
4884
|
|
|
], |
4885
|
|
|
], |
4886
|
|
|
'alwaysAvailable' => false, |
4887
|
|
|
'isHistory' => false, |
4888
|
|
|
'isCustom' => false, |
4889
|
|
|
'forward' => false, |
4890
|
|
|
] |
4891
|
|
|
), |
4892
|
|
|
$urlAlias |
4893
|
|
|
); |
4894
|
|
|
|
4895
|
|
|
$urlAlias = $handler->lookup('dva/swap-en'); |
4896
|
|
|
$this->assertEquals( |
4897
|
|
|
new UrlAlias( |
4898
|
|
|
[ |
4899
|
|
|
'id' => '3-' . md5('swap-en'), |
4900
|
|
|
'type' => UrlAlias::LOCATION, |
4901
|
|
|
'destination' => 317, |
4902
|
|
|
'languageCodes' => [ |
4903
|
|
|
'eng-GB', |
4904
|
|
|
], |
4905
|
|
|
'pathData' => [ |
4906
|
|
|
[ |
4907
|
|
|
'always-available' => false, |
4908
|
|
|
'translations' => [ |
4909
|
|
|
'cro-HR' => 'dva', |
4910
|
|
|
], |
4911
|
|
|
], |
4912
|
|
|
[ |
4913
|
|
|
'always-available' => false, |
4914
|
|
|
'translations' => [ |
4915
|
|
|
'cro-HR' => 'swap-this', |
4916
|
|
|
'eng-GB' => 'swap-en', |
4917
|
|
|
], |
4918
|
|
|
], |
4919
|
|
|
], |
4920
|
|
|
'alwaysAvailable' => false, |
4921
|
|
|
'isHistory' => false, |
4922
|
|
|
'isCustom' => false, |
4923
|
|
|
'forward' => false, |
4924
|
|
|
] |
4925
|
|
|
), |
4926
|
|
|
$urlAlias |
4927
|
|
|
); |
4928
|
|
|
} |
4929
|
|
|
|
4930
|
|
|
/** |
4931
|
|
|
* Test for the locationSwapped() method. |
4932
|
|
|
* |
4933
|
|
|
* @group swap |
4934
|
|
|
*/ |
4935
|
|
View Code Duplication |
public function testLocationSwappedWithReusingExternalHistory() |
4936
|
|
|
{ |
4937
|
|
|
$handler = $this->getHandler(); |
4938
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_swap_reusing_external_history.php'); |
4939
|
|
|
|
4940
|
|
|
$countBeforeReusing = $this->countRows(); |
4941
|
|
|
|
4942
|
|
|
$handler->locationSwapped(318, 314, 319, 315); |
4943
|
|
|
|
4944
|
|
|
$this->assertEquals( |
4945
|
|
|
$countBeforeReusing, |
4946
|
|
|
$this->countRows() |
4947
|
|
|
); |
4948
|
|
|
|
4949
|
|
|
$urlAlias = $handler->lookup('jedan/swap-that'); |
4950
|
|
|
$this->assertEquals( |
4951
|
|
|
new UrlAlias( |
4952
|
|
|
[ |
4953
|
|
|
'id' => '2-' . md5('swap-that'), |
4954
|
|
|
'type' => UrlAlias::LOCATION, |
4955
|
|
|
'destination' => 318, |
4956
|
|
|
'languageCodes' => [ |
4957
|
|
|
'cro-HR', |
4958
|
|
|
], |
4959
|
|
|
'pathData' => [ |
4960
|
|
|
[ |
4961
|
|
|
'always-available' => false, |
4962
|
|
|
'translations' => [ |
4963
|
|
|
'cro-HR' => 'jedan', |
4964
|
|
|
], |
4965
|
|
|
], |
4966
|
|
|
[ |
4967
|
|
|
'always-available' => false, |
4968
|
|
|
'translations' => [ |
4969
|
|
|
'cro-HR' => 'swap-that', |
4970
|
|
|
], |
4971
|
|
|
], |
4972
|
|
|
], |
4973
|
|
|
'alwaysAvailable' => false, |
4974
|
|
|
'isHistory' => false, |
4975
|
|
|
'isCustom' => false, |
4976
|
|
|
'forward' => false, |
4977
|
|
|
] |
4978
|
|
|
), |
4979
|
|
|
$urlAlias |
4980
|
|
|
); |
4981
|
|
|
|
4982
|
|
|
$urlAlias = $handler->lookup('dva/swap-this'); |
4983
|
|
|
$this->assertEquals( |
4984
|
|
|
new UrlAlias( |
4985
|
|
|
[ |
4986
|
|
|
'id' => '3-' . md5('swap-this'), |
4987
|
|
|
'type' => UrlAlias::LOCATION, |
4988
|
|
|
'destination' => 319, |
4989
|
|
|
'languageCodes' => [ |
4990
|
|
|
'cro-HR', |
4991
|
|
|
], |
4992
|
|
|
'pathData' => [ |
4993
|
|
|
[ |
4994
|
|
|
'always-available' => false, |
4995
|
|
|
'translations' => [ |
4996
|
|
|
'cro-HR' => 'dva', |
4997
|
|
|
], |
4998
|
|
|
], |
4999
|
|
|
[ |
5000
|
|
|
'always-available' => false, |
5001
|
|
|
'translations' => [ |
5002
|
|
|
'cro-HR' => 'swap-this', |
5003
|
|
|
], |
5004
|
|
|
], |
5005
|
|
|
], |
5006
|
|
|
'alwaysAvailable' => false, |
5007
|
|
|
'isHistory' => false, |
5008
|
|
|
'isCustom' => false, |
5009
|
|
|
'forward' => false, |
5010
|
|
|
] |
5011
|
|
|
), |
5012
|
|
|
$urlAlias |
5013
|
|
|
); |
5014
|
|
|
|
5015
|
|
|
$urlAlias = $handler->lookup('dva/swap-that'); |
5016
|
|
|
$this->assertEquals( |
5017
|
|
|
new UrlAlias( |
5018
|
|
|
[ |
5019
|
|
|
'id' => '3-' . md5('swap-that'), |
5020
|
|
|
'type' => UrlAlias::LOCATION, |
5021
|
|
|
'destination' => 319, |
5022
|
|
|
'languageCodes' => [ |
5023
|
|
|
'cro-HR', |
5024
|
|
|
], |
5025
|
|
|
'pathData' => [ |
5026
|
|
|
[ |
5027
|
|
|
'always-available' => false, |
5028
|
|
|
'translations' => [ |
5029
|
|
|
'cro-HR' => 'dva', |
5030
|
|
|
], |
5031
|
|
|
], |
5032
|
|
|
[ |
5033
|
|
|
'always-available' => false, |
5034
|
|
|
'translations' => [ |
5035
|
|
|
'cro-HR' => 'swap-that', |
5036
|
|
|
], |
5037
|
|
|
], |
5038
|
|
|
], |
5039
|
|
|
'alwaysAvailable' => false, |
5040
|
|
|
'isHistory' => true, |
5041
|
|
|
'isCustom' => false, |
5042
|
|
|
'forward' => false, |
5043
|
|
|
] |
5044
|
|
|
), |
5045
|
|
|
$urlAlias |
5046
|
|
|
); |
5047
|
|
|
|
5048
|
|
|
$urlAlias = $handler->lookup('jedan/swap-this'); |
5049
|
|
|
$this->assertEquals( |
5050
|
|
|
new UrlAlias( |
5051
|
|
|
[ |
5052
|
|
|
'id' => '2-' . md5('swap-this'), |
5053
|
|
|
'type' => UrlAlias::LOCATION, |
5054
|
|
|
'destination' => 318, |
5055
|
|
|
'languageCodes' => [ |
5056
|
|
|
'cro-HR', |
5057
|
|
|
], |
5058
|
|
|
'pathData' => [ |
5059
|
|
|
[ |
5060
|
|
|
'always-available' => false, |
5061
|
|
|
'translations' => [ |
5062
|
|
|
'cro-HR' => 'jedan', |
5063
|
|
|
], |
5064
|
|
|
], |
5065
|
|
|
[ |
5066
|
|
|
'always-available' => false, |
5067
|
|
|
'translations' => [ |
5068
|
|
|
'cro-HR' => 'swap-this', |
5069
|
|
|
], |
5070
|
|
|
], |
5071
|
|
|
], |
5072
|
|
|
'alwaysAvailable' => false, |
5073
|
|
|
'isHistory' => true, |
5074
|
|
|
'isCustom' => false, |
5075
|
|
|
'forward' => false, |
5076
|
|
|
] |
5077
|
|
|
), |
5078
|
|
|
$urlAlias |
5079
|
|
|
); |
5080
|
|
|
} |
5081
|
|
|
|
5082
|
|
|
/** |
5083
|
|
|
* Test for the locationSwapped() method. |
5084
|
|
|
* |
5085
|
|
|
* @group swap |
5086
|
|
|
*/ |
5087
|
|
View Code Duplication |
public function testLocationSwappedWithReusingNopEntry() |
5088
|
|
|
{ |
5089
|
|
|
$handler = $this->getHandler(); |
5090
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_swap_reusing_nop.php'); |
5091
|
|
|
|
5092
|
|
|
$countBeforeReusing = $this->countRows(); |
5093
|
|
|
|
5094
|
|
|
$handler->locationSwapped(316, 314, 317, 315); |
5095
|
|
|
|
5096
|
|
|
$this->assertEquals( |
5097
|
|
|
$countBeforeReusing + 1, |
5098
|
|
|
$this->countRows() |
5099
|
|
|
); |
5100
|
|
|
|
5101
|
|
|
$urlAlias = $handler->lookup('jedan/swap-that'); |
5102
|
|
|
$this->assertEquals( |
5103
|
|
|
new UrlAlias( |
5104
|
|
|
[ |
5105
|
|
|
'id' => '2-' . md5('swap-that'), |
5106
|
|
|
'type' => UrlAlias::LOCATION, |
5107
|
|
|
'destination' => 316, |
5108
|
|
|
'languageCodes' => [ |
5109
|
|
|
'cro-HR', |
5110
|
|
|
], |
5111
|
|
|
'pathData' => [ |
5112
|
|
|
[ |
5113
|
|
|
'always-available' => false, |
5114
|
|
|
'translations' => [ |
5115
|
|
|
'cro-HR' => 'jedan', |
5116
|
|
|
], |
5117
|
|
|
], |
5118
|
|
|
[ |
5119
|
|
|
'always-available' => false, |
5120
|
|
|
'translations' => [ |
5121
|
|
|
'cro-HR' => 'swap-that', |
5122
|
|
|
], |
5123
|
|
|
], |
5124
|
|
|
], |
5125
|
|
|
'alwaysAvailable' => false, |
5126
|
|
|
'isHistory' => false, |
5127
|
|
|
'isCustom' => false, |
5128
|
|
|
'forward' => false, |
5129
|
|
|
] |
5130
|
|
|
), |
5131
|
|
|
$urlAlias |
5132
|
|
|
); |
5133
|
|
|
|
5134
|
|
|
$urlAlias = $handler->lookup('dva/swap-this'); |
5135
|
|
|
$this->assertEquals( |
5136
|
|
|
new UrlAlias( |
5137
|
|
|
[ |
5138
|
|
|
'id' => '3-' . md5('swap-this'), |
5139
|
|
|
'type' => UrlAlias::LOCATION, |
5140
|
|
|
'destination' => 317, |
5141
|
|
|
'languageCodes' => [ |
5142
|
|
|
'cro-HR', |
5143
|
|
|
], |
5144
|
|
|
'pathData' => [ |
5145
|
|
|
[ |
5146
|
|
|
'always-available' => false, |
5147
|
|
|
'translations' => [ |
5148
|
|
|
'cro-HR' => 'dva', |
5149
|
|
|
], |
5150
|
|
|
], |
5151
|
|
|
[ |
5152
|
|
|
'always-available' => false, |
5153
|
|
|
'translations' => [ |
5154
|
|
|
'cro-HR' => 'swap-this', |
5155
|
|
|
], |
5156
|
|
|
], |
5157
|
|
|
], |
5158
|
|
|
'alwaysAvailable' => false, |
5159
|
|
|
'isHistory' => false, |
5160
|
|
|
'isCustom' => false, |
5161
|
|
|
'forward' => false, |
5162
|
|
|
] |
5163
|
|
|
), |
5164
|
|
|
$urlAlias |
5165
|
|
|
); |
5166
|
|
|
|
5167
|
|
|
$urlAlias = $handler->lookup('dva/swap-that'); |
5168
|
|
|
$this->assertEquals( |
5169
|
|
|
new UrlAlias( |
5170
|
|
|
[ |
5171
|
|
|
'id' => '3-' . md5('swap-that'), |
5172
|
|
|
'type' => UrlAlias::LOCATION, |
5173
|
|
|
'destination' => 317, |
5174
|
|
|
'languageCodes' => [ |
5175
|
|
|
'cro-HR', |
5176
|
|
|
], |
5177
|
|
|
'pathData' => [ |
5178
|
|
|
[ |
5179
|
|
|
'always-available' => false, |
5180
|
|
|
'translations' => [ |
5181
|
|
|
'cro-HR' => 'dva', |
5182
|
|
|
], |
5183
|
|
|
], |
5184
|
|
|
[ |
5185
|
|
|
'always-available' => false, |
5186
|
|
|
'translations' => [ |
5187
|
|
|
'cro-HR' => 'swap-that', |
5188
|
|
|
], |
5189
|
|
|
], |
5190
|
|
|
], |
5191
|
|
|
'alwaysAvailable' => false, |
5192
|
|
|
'isHistory' => true, |
5193
|
|
|
'isCustom' => false, |
5194
|
|
|
'forward' => false, |
5195
|
|
|
] |
5196
|
|
|
), |
5197
|
|
|
$urlAlias |
5198
|
|
|
); |
5199
|
|
|
|
5200
|
|
|
$urlAlias = $handler->lookup('jedan/swap-this'); |
5201
|
|
|
$this->assertEquals( |
5202
|
|
|
new UrlAlias( |
5203
|
|
|
[ |
5204
|
|
|
'id' => '2-' . md5('swap-this'), |
5205
|
|
|
'type' => UrlAlias::LOCATION, |
5206
|
|
|
'destination' => 316, |
5207
|
|
|
'languageCodes' => [ |
5208
|
|
|
'cro-HR', |
5209
|
|
|
], |
5210
|
|
|
'pathData' => [ |
5211
|
|
|
[ |
5212
|
|
|
'always-available' => false, |
5213
|
|
|
'translations' => [ |
5214
|
|
|
'cro-HR' => 'jedan', |
5215
|
|
|
], |
5216
|
|
|
], |
5217
|
|
|
[ |
5218
|
|
|
'always-available' => false, |
5219
|
|
|
'translations' => [ |
5220
|
|
|
'cro-HR' => 'swap-this', |
5221
|
|
|
], |
5222
|
|
|
], |
5223
|
|
|
], |
5224
|
|
|
'alwaysAvailable' => false, |
5225
|
|
|
'isHistory' => true, |
5226
|
|
|
'isCustom' => false, |
5227
|
|
|
'forward' => false, |
5228
|
|
|
] |
5229
|
|
|
), |
5230
|
|
|
$urlAlias |
5231
|
|
|
); |
5232
|
|
|
} |
5233
|
|
|
|
5234
|
|
|
/** |
5235
|
|
|
* Test for the locationSwapped() method. |
5236
|
|
|
* |
5237
|
|
|
* @depends testLocationSwappedWithReusingNopEntry |
5238
|
|
|
* @group swap |
5239
|
|
|
*/ |
5240
|
|
View Code Duplication |
public function testLocationSwappedWithReusingNopEntryCustomAliasIsDestroyed() |
5241
|
|
|
{ |
5242
|
|
|
$handler = $this->getHandler(); |
5243
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_swap_reusing_nop.php'); |
5244
|
|
|
|
5245
|
|
|
$handler->lookup('jedan/swap-that/search'); |
5246
|
|
|
$handler->locationSwapped(316, 314, 317, 315); |
5247
|
|
|
|
5248
|
|
|
try { |
5249
|
|
|
$handler->lookup('jedan/swap-that/search'); |
5250
|
|
|
$this->fail('Custom alias is not destroyed'); |
5251
|
|
|
} catch (NotFoundException $e) { |
5252
|
|
|
// Custom alias is destroyed by reusing NOP entry with existing autogenerated alias |
5253
|
|
|
// on the same level (that means link and ID are updated to the existing alias ID, |
5254
|
|
|
// so custom alias children entries are no longer properly linked (parent-link)) |
5255
|
|
|
} |
5256
|
|
|
} |
5257
|
|
|
|
5258
|
|
|
/** |
5259
|
|
|
* Test for the locationSwapped() method. |
5260
|
|
|
* |
5261
|
|
|
* @group swap |
5262
|
|
|
* |
5263
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::locationSwapped |
5264
|
|
|
*/ |
5265
|
|
View Code Duplication |
public function testLocationSwappedUpdatesLocationPathIdentificationString() |
5266
|
|
|
{ |
5267
|
|
|
$handler = $this->getHandler(); |
5268
|
|
|
$locationGateway = $this->getLocationGateway(); |
5269
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_swap_path_identification_string.php'); |
5270
|
|
|
|
5271
|
|
|
$countBeforeReusing = $this->countRows(); |
5272
|
|
|
|
5273
|
|
|
$handler->locationSwapped(314, 2, 315, 2); |
5274
|
|
|
|
5275
|
|
|
$this->assertEquals( |
5276
|
|
|
$countBeforeReusing, |
5277
|
|
|
$this->countRows() |
5278
|
|
|
); |
5279
|
|
|
|
5280
|
|
|
$locationData = $locationGateway->getBasicNodeData(314); |
5281
|
|
|
self::assertEquals('dva', $locationData['path_identification_string']); |
5282
|
|
|
|
5283
|
|
|
$locationData = $locationGateway->getBasicNodeData(315); |
5284
|
|
|
self::assertEquals('jedan', $locationData['path_identification_string']); |
5285
|
|
|
} |
5286
|
|
|
|
5287
|
|
|
/** |
5288
|
|
|
* Test for the locationSwapped() method. |
5289
|
|
|
* |
5290
|
|
|
* @group swap |
5291
|
|
|
* |
5292
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::locationSwapped |
5293
|
|
|
*/ |
5294
|
|
View Code Duplication |
public function testLocationSwappedMultipleLanguagesUpdatesLocationPathIdentificationString() |
5295
|
|
|
{ |
5296
|
|
|
$handler = $this->getHandler(); |
5297
|
|
|
$locationGateway = $this->getLocationGateway(); |
5298
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_swap_multilang_path_identification_string.php'); |
5299
|
|
|
|
5300
|
|
|
$countBeforeReusing = $this->countRows(); |
5301
|
|
|
|
5302
|
|
|
$handler->locationSwapped(314, 2, 315, 2); |
5303
|
|
|
|
5304
|
|
|
$this->assertEquals( |
5305
|
|
|
$countBeforeReusing, |
5306
|
|
|
$this->countRows() |
5307
|
|
|
); |
5308
|
|
|
|
5309
|
|
|
$locationData = $locationGateway->getBasicNodeData(314); |
5310
|
|
|
self::assertEquals('zwei', $locationData['path_identification_string']); |
5311
|
|
|
|
5312
|
|
|
$locationData = $locationGateway->getBasicNodeData(315); |
5313
|
|
|
self::assertEquals('jedan', $locationData['path_identification_string']); |
5314
|
|
|
} |
5315
|
|
|
|
5316
|
|
|
/** |
5317
|
|
|
* @return int |
5318
|
|
|
*/ |
5319
|
|
|
protected function countRows() |
5320
|
|
|
{ |
5321
|
|
|
/** @var \eZ\Publish\Core\Persistence\Database\SelectQuery $query */ |
5322
|
|
|
$query = $this->getDatabaseHandler()->createSelectQuery(); |
5323
|
|
|
$query->select( |
5324
|
|
|
$query->expr->count('*') |
5325
|
|
|
)->from( |
5326
|
|
|
$this->getDatabaseHandler()->quoteTable('ezurlalias_ml') |
5327
|
|
|
); |
5328
|
|
|
|
5329
|
|
|
$statement = $query->prepare(); |
5330
|
|
|
$statement->execute(); |
5331
|
|
|
|
5332
|
|
|
return (int)$statement->fetchColumn(); |
5333
|
|
|
} |
5334
|
|
|
|
5335
|
|
|
protected function dump() |
5336
|
|
|
{ |
5337
|
|
|
/** @var \eZ\Publish\Core\Persistence\Database\SelectQuery $query */ |
5338
|
|
|
$query = $this->getDatabaseHandler()->createSelectQuery(); |
5339
|
|
|
$query->select( |
5340
|
|
|
'*' |
5341
|
|
|
)->from( |
5342
|
|
|
$this->getDatabaseHandler()->quoteTable('ezurlalias_ml') |
5343
|
|
|
); |
5344
|
|
|
|
5345
|
|
|
$statement = $query->prepare(); |
5346
|
|
|
$statement->execute(); |
5347
|
|
|
|
5348
|
|
|
var_dump($statement->fetchAll(\PDO::FETCH_ASSOC)); |
|
|
|
|
5349
|
|
|
} |
5350
|
|
|
|
5351
|
|
|
/** |
5352
|
|
|
* @var \eZ\Publish\Core\Persistence\Doctrine\ConnectionHandler |
5353
|
|
|
* |
5354
|
|
|
* @deprecated Start to use DBAL $connection instead. |
5355
|
|
|
*/ |
5356
|
|
|
protected $dbHandler; |
5357
|
|
|
|
5358
|
|
|
/** @var \eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway */ |
5359
|
|
|
protected $locationGateway; |
5360
|
|
|
|
5361
|
|
|
/** @var \eZ\Publish\Core\Persistence\Legacy\Content\Language\Handler */ |
5362
|
|
|
protected $languageHandler; |
5363
|
|
|
|
5364
|
|
|
/** @var \eZ\Publish\Core\Persistence\Legacy\Content\Language\MaskGenerator */ |
5365
|
|
|
protected $languageMaskGenerator; |
5366
|
|
|
|
5367
|
|
|
/** |
5368
|
|
|
* @param array $methods |
5369
|
|
|
* |
5370
|
|
|
* @return \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler|\PHPUnit\Framework\MockObject\MockObject |
5371
|
|
|
*/ |
5372
|
|
|
protected function getPartlyMockedHandler(array $methods) |
5373
|
|
|
{ |
5374
|
|
|
return $this->getMockBuilder(Handler::class) |
5375
|
|
|
->setConstructorArgs( |
5376
|
|
|
[ |
5377
|
|
|
$this->createMock(UrlAliasGateway::class), |
5378
|
|
|
$this->createMock(Mapper::class), |
5379
|
|
|
$this->createMock(LocationGateway::class), |
5380
|
|
|
$this->createMock(LanguageHandler::class), |
5381
|
|
|
$this->createMock(SlugConverter::class), |
5382
|
|
|
$this->createMock(Gateway::class), |
5383
|
|
|
$this->createMock(LanguageMaskGenerator::class), |
5384
|
|
|
$this->createMock(TransactionHandler::class), |
5385
|
|
|
] |
5386
|
|
|
) |
5387
|
|
|
->setMethods($methods) |
5388
|
|
|
->getMock(); |
5389
|
|
|
} |
5390
|
|
|
|
5391
|
|
|
/** |
5392
|
|
|
* @return \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler |
5393
|
|
|
*/ |
5394
|
|
|
protected function getHandler() |
5395
|
|
|
{ |
5396
|
|
|
$languageHandler = $this->getLanguageHandler(); |
5397
|
|
|
$languageMaskGenerator = $this->getLanguageMaskGenerator(); |
5398
|
|
|
$databaseHandler = $this->getDatabaseHandler(); |
5399
|
|
|
$gateway = new DoctrineDatabase( |
5400
|
|
|
$databaseHandler, |
5401
|
|
|
$languageMaskGenerator |
5402
|
|
|
); |
5403
|
|
|
$mapper = new Mapper($languageMaskGenerator); |
5404
|
|
|
$slugConverter = new SlugConverter($this->getProcessor()); |
5405
|
|
|
$contentGateway = new ContentGateway( |
5406
|
|
|
$this->getDatabaseHandler(), |
5407
|
|
|
$this->getDatabaseConnection(), |
5408
|
|
|
new ContentGateway\QueryBuilder($this->getDatabaseHandler()), |
5409
|
|
|
$languageHandler, |
5410
|
|
|
$languageMaskGenerator |
5411
|
|
|
); |
5412
|
|
|
|
5413
|
|
|
return new Handler( |
5414
|
|
|
$gateway, |
5415
|
|
|
$mapper, |
5416
|
|
|
$this->getLocationGateway(), |
5417
|
|
|
$languageHandler, |
5418
|
|
|
$slugConverter, |
5419
|
|
|
$contentGateway, |
5420
|
|
|
$languageMaskGenerator, |
5421
|
|
|
$this->createMock(TransactionHandler::class) |
5422
|
|
|
); |
5423
|
|
|
} |
5424
|
|
|
|
5425
|
|
|
/** |
5426
|
|
|
* @return \eZ\Publish\Core\Persistence\Legacy\Content\Language\Handler |
5427
|
|
|
*/ |
5428
|
|
|
protected function getLanguageHandler() |
5429
|
|
|
{ |
5430
|
|
|
if (!isset($this->languageHandler)) { |
5431
|
|
|
$this->languageHandler = new LanguageHandler( |
5432
|
|
|
new LanguageGateway( |
5433
|
|
|
$this->getDatabaseHandler() |
5434
|
|
|
), |
5435
|
|
|
new LanguageMapper() |
5436
|
|
|
); |
5437
|
|
|
} |
5438
|
|
|
|
5439
|
|
|
return $this->languageHandler; |
5440
|
|
|
} |
5441
|
|
|
|
5442
|
|
|
/** |
5443
|
|
|
* @return \eZ\Publish\Core\Persistence\Legacy\Content\Language\MaskGenerator |
5444
|
|
|
*/ |
5445
|
|
|
protected function getLanguageMaskGenerator() |
5446
|
|
|
{ |
5447
|
|
|
if (!isset($this->languageMaskGenerator)) { |
5448
|
|
|
$this->languageMaskGenerator = new LanguageMaskGenerator( |
5449
|
|
|
$this->getLanguageHandler() |
5450
|
|
|
); |
5451
|
|
|
} |
5452
|
|
|
|
5453
|
|
|
return $this->languageMaskGenerator; |
5454
|
|
|
} |
5455
|
|
|
|
5456
|
|
|
/** |
5457
|
|
|
* @return \eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway |
5458
|
|
|
*/ |
5459
|
|
|
protected function getLocationGateway() |
5460
|
|
|
{ |
5461
|
|
|
if (!isset($this->locationGateway)) { |
5462
|
|
|
$this->locationGateway = new DoctrineDatabaseLocation( |
5463
|
|
|
$this->getDatabaseHandler(), |
5464
|
|
|
$this->getLanguageMaskGenerator() |
5465
|
|
|
); |
5466
|
|
|
} |
5467
|
|
|
|
5468
|
|
|
return $this->locationGateway; |
5469
|
|
|
} |
5470
|
|
|
|
5471
|
|
|
/** |
5472
|
|
|
* @return \eZ\Publish\Core\Persistence\TransformationProcessor |
5473
|
|
|
*/ |
5474
|
|
|
public function getProcessor() |
5475
|
|
|
{ |
5476
|
|
|
return new DefinitionBased( |
5477
|
|
|
new Parser(), |
5478
|
|
|
new PcreCompiler(new Utf8Converter()), |
5479
|
|
|
glob(__DIR__ . '/../../../../Tests/TransformationProcessor/_fixtures/transformations/*.tr') |
5480
|
|
|
); |
5481
|
|
|
} |
5482
|
|
|
|
5483
|
|
|
/** |
5484
|
|
|
* Data provider for tests of archiveUrlAliasesForDeletedTranslations. |
5485
|
|
|
* |
5486
|
|
|
* @see testArchiveUrlAliasesForDeletedTranslations for the description of parameters |
5487
|
|
|
* |
5488
|
|
|
* @return array |
5489
|
|
|
*/ |
5490
|
|
|
public function providerForArchiveUrlAliasesForDeletedTranslations() |
5491
|
|
|
{ |
5492
|
|
|
return [ |
5493
|
|
|
[2, ['eng-GB', 'pol-PL'], 'pol-PL'], |
5494
|
|
|
[3, ['eng-GB', 'pol-PL', 'nor-NO'], 'pol-PL'], |
5495
|
|
|
]; |
5496
|
|
|
} |
5497
|
|
|
|
5498
|
|
|
/** |
5499
|
|
|
* @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::archiveUrlAliasesForDeletedTranslations() |
5500
|
|
|
* |
5501
|
|
|
* @dataProvider providerForArchiveUrlAliasesForDeletedTranslations |
5502
|
|
|
* |
5503
|
|
|
* @param int $locationId |
5504
|
|
|
* @param string[] $expectedLanguages expected language codes before deleting |
5505
|
|
|
* @param string $removeLanguage language code to be deleted |
5506
|
|
|
*/ |
5507
|
|
|
public function testArchiveUrlAliasesForDeletedTranslations( |
5508
|
|
|
$locationId, |
5509
|
|
|
array $expectedLanguages, |
5510
|
|
|
$removeLanguage |
5511
|
|
|
) { |
5512
|
|
|
$handler = $this->getHandler(); |
5513
|
|
|
$this->insertDatabaseFixture(__DIR__ . '/_fixtures/publish_multilingual.php'); |
5514
|
|
|
|
5515
|
|
|
// collect data persisted from fixtures |
5516
|
|
|
$urlAliases = $handler->listURLAliasesForLocation($locationId); |
5517
|
|
|
$collectedLanguages = []; |
5518
|
|
|
$collectedUrls = []; |
5519
|
|
|
foreach ($urlAliases as $urlAlias) { |
5520
|
|
|
// collect languages of all URL aliases |
5521
|
|
|
$collectedLanguages = array_merge($collectedLanguages, $urlAlias->languageCodes); |
5522
|
|
|
$isComposite = count($urlAlias->languageCodes) > 1; |
5523
|
|
|
foreach ($urlAlias->pathData as $pathData) { |
5524
|
|
|
// collect also actual unique URLs to be removed to check them after removal |
5525
|
|
|
if (!empty($pathData['translations'][$removeLanguage])) { |
5526
|
|
|
$url = $pathData['translations'][$removeLanguage]; |
5527
|
|
|
$collectedUrls[$url] = $isComposite; |
5528
|
|
|
} |
5529
|
|
|
} |
5530
|
|
|
} |
5531
|
|
|
// sanity check |
5532
|
|
|
self::assertEquals($expectedLanguages, $collectedLanguages); |
5533
|
|
|
|
5534
|
|
|
// remove language |
5535
|
|
|
$publishedLanguages = array_values(array_diff($collectedLanguages, [$removeLanguage])); |
5536
|
|
|
$handler->archiveUrlAliasesForDeletedTranslations($locationId, 1, $publishedLanguages); |
5537
|
|
|
|
5538
|
|
|
// check reloaded structures |
5539
|
|
|
$urlAliases = $handler->listURLAliasesForLocation($locationId); |
5540
|
|
View Code Duplication |
foreach ($urlAliases as $urlAlias) { |
|
|
|
|
5541
|
|
|
self::assertNotContains($removeLanguage, $urlAlias->languageCodes); |
5542
|
|
|
foreach ($urlAlias->pathData as $pathData) { |
5543
|
|
|
self::assertNotContains($removeLanguage, $pathData['translations']); |
5544
|
|
|
foreach ($pathData['translations'] as $url) { |
5545
|
|
|
$lookupUrlAlias = $handler->lookup($url); |
5546
|
|
|
self::assertNotContains($removeLanguage, $lookupUrlAlias->languageCodes); |
5547
|
|
|
} |
5548
|
|
|
} |
5549
|
|
|
} |
5550
|
|
|
|
5551
|
|
|
// lookup removed URLs to check they're not found |
5552
|
|
View Code Duplication |
foreach ($collectedUrls as $url => $isComposite) { |
|
|
|
|
5553
|
|
|
$urlAlias = $handler->lookup($url); |
5554
|
|
|
if ($isComposite) { |
5555
|
|
|
// check if alias no longer refers to removed Translation |
5556
|
|
|
self::assertNotContains($removeLanguage, $urlAlias->languageCodes); |
5557
|
|
|
foreach ($urlAlias->pathData as $pathData) { |
5558
|
|
|
self::assertNotContains($removeLanguage, $pathData['translations']); |
5559
|
|
|
} |
5560
|
|
|
} else { |
5561
|
|
|
// check if non composite alias for removed translation is historized |
5562
|
|
|
self::assertTrue($urlAlias->isHistory); |
5563
|
|
|
} |
5564
|
|
|
} |
5565
|
|
|
} |
5566
|
|
|
} |
5567
|
|
|
|