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