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