Code Duplication    Length = 146-146 lines in 3 locations

eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/UrlAliasHandlerTest.php 3 locations

@@ 3278-3423 (lines=146) @@
3275
     *
3276
     * @group swap
3277
     */
3278
    public function testLocationSwappedSimpleWithHistory()
3279
    {
3280
        $handler = $this->getHandler();
3281
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_swap_simple_history.php');
3282
3283
        $countBeforeReusing = $this->countRows();
3284
3285
        $handler->locationSwapped(316, 314, 317, 315);
3286
3287
        $this->assertEquals(
3288
            $countBeforeReusing,
3289
            $this->countRows()
3290
        );
3291
3292
        $urlAlias = $handler->lookup('jedan/swap');
3293
        $this->assertEquals(
3294
            new UrlAlias(
3295
                [
3296
                    'id' => '2-' . md5('swap'),
3297
                    'type' => UrlAlias::LOCATION,
3298
                    'destination' => 316,
3299
                    'languageCodes' => [
3300
                        'cro-HR',
3301
                    ],
3302
                    'pathData' => [
3303
                        [
3304
                            'always-available' => false,
3305
                            'translations' => [
3306
                                'cro-HR' => 'jedan',
3307
                            ],
3308
                        ],
3309
                        [
3310
                            'always-available' => false,
3311
                            'translations' => [
3312
                                'cro-HR' => 'swap',
3313
                            ],
3314
                        ],
3315
                    ],
3316
                    'alwaysAvailable' => false,
3317
                    'isHistory' => true,
3318
                    'isCustom' => false,
3319
                    'forward' => false,
3320
                ]
3321
            ),
3322
            $urlAlias
3323
        );
3324
3325
        $urlAlias = $handler->lookup('dva/swap');
3326
        $this->assertEquals(
3327
            new UrlAlias(
3328
                [
3329
                    'id' => '3-' . md5('swap'),
3330
                    'type' => UrlAlias::LOCATION,
3331
                    'destination' => 317,
3332
                    'languageCodes' => [
3333
                        'cro-HR',
3334
                    ],
3335
                    'pathData' => [
3336
                        [
3337
                            'always-available' => false,
3338
                            'translations' => [
3339
                                'cro-HR' => 'dva',
3340
                            ],
3341
                        ],
3342
                        [
3343
                            'always-available' => false,
3344
                            'translations' => [
3345
                                'cro-HR' => 'swap',
3346
                            ],
3347
                        ],
3348
                    ],
3349
                    'alwaysAvailable' => false,
3350
                    'isHistory' => true,
3351
                    'isCustom' => false,
3352
                    'forward' => false,
3353
                ]
3354
            ),
3355
            $urlAlias
3356
        );
3357
3358
        $urlAlias = $handler->lookup('jedan/swap-new');
3359
        $this->assertEquals(
3360
            new UrlAlias(
3361
                [
3362
                    'id' => '2-' . md5('swap-new'),
3363
                    'type' => UrlAlias::LOCATION,
3364
                    'destination' => 316,
3365
                    'languageCodes' => [
3366
                        'cro-HR',
3367
                    ],
3368
                    'pathData' => [
3369
                        [
3370
                            'always-available' => false,
3371
                            'translations' => [
3372
                                'cro-HR' => 'jedan',
3373
                            ],
3374
                        ],
3375
                        [
3376
                            'always-available' => false,
3377
                            'translations' => [
3378
                                'cro-HR' => 'swap-new',
3379
                            ],
3380
                        ],
3381
                    ],
3382
                    'alwaysAvailable' => false,
3383
                    'isHistory' => false,
3384
                    'isCustom' => false,
3385
                    'forward' => false,
3386
                ]
3387
            ),
3388
            $urlAlias
3389
        );
3390
3391
        $urlAlias = $handler->lookup('dva/swap-new');
3392
        $this->assertEquals(
3393
            new UrlAlias(
3394
                [
3395
                    'id' => '3-' . md5('swap-new'),
3396
                    'type' => UrlAlias::LOCATION,
3397
                    'destination' => 317,
3398
                    'languageCodes' => [
3399
                        'cro-HR',
3400
                    ],
3401
                    'pathData' => [
3402
                        [
3403
                            'always-available' => false,
3404
                            'translations' => [
3405
                                'cro-HR' => 'dva',
3406
                            ],
3407
                        ],
3408
                        [
3409
                            'always-available' => false,
3410
                            'translations' => [
3411
                                'cro-HR' => 'swap-new',
3412
                            ],
3413
                        ],
3414
                    ],
3415
                    'alwaysAvailable' => false,
3416
                    'isHistory' => false,
3417
                    'isCustom' => false,
3418
                    'forward' => false,
3419
                ]
3420
            ),
3421
            $urlAlias
3422
        );
3423
    }
3424
3425
    /**
3426
     * Test for the locationSwapped() method.
@@ 4928-5073 (lines=146) @@
4925
     *
4926
     * @group swap
4927
     */
4928
    public function testLocationSwappedWithReusingExternalHistory()
4929
    {
4930
        $handler = $this->getHandler();
4931
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_swap_reusing_external_history.php');
4932
4933
        $countBeforeReusing = $this->countRows();
4934
4935
        $handler->locationSwapped(318, 314, 319, 315);
4936
4937
        $this->assertEquals(
4938
            $countBeforeReusing,
4939
            $this->countRows()
4940
        );
4941
4942
        $urlAlias = $handler->lookup('jedan/swap-that');
4943
        $this->assertEquals(
4944
            new UrlAlias(
4945
                [
4946
                    'id' => '2-' . md5('swap-that'),
4947
                    'type' => UrlAlias::LOCATION,
4948
                    'destination' => 318,
4949
                    'languageCodes' => [
4950
                        'cro-HR',
4951
                    ],
4952
                    'pathData' => [
4953
                        [
4954
                            'always-available' => false,
4955
                            'translations' => [
4956
                                'cro-HR' => 'jedan',
4957
                            ],
4958
                        ],
4959
                        [
4960
                            'always-available' => false,
4961
                            'translations' => [
4962
                                'cro-HR' => 'swap-that',
4963
                            ],
4964
                        ],
4965
                    ],
4966
                    'alwaysAvailable' => false,
4967
                    'isHistory' => false,
4968
                    'isCustom' => false,
4969
                    'forward' => false,
4970
                ]
4971
            ),
4972
            $urlAlias
4973
        );
4974
4975
        $urlAlias = $handler->lookup('dva/swap-this');
4976
        $this->assertEquals(
4977
            new UrlAlias(
4978
                [
4979
                    'id' => '3-' . md5('swap-this'),
4980
                    'type' => UrlAlias::LOCATION,
4981
                    'destination' => 319,
4982
                    'languageCodes' => [
4983
                        'cro-HR',
4984
                    ],
4985
                    'pathData' => [
4986
                        [
4987
                            'always-available' => false,
4988
                            'translations' => [
4989
                                'cro-HR' => 'dva',
4990
                            ],
4991
                        ],
4992
                        [
4993
                            'always-available' => false,
4994
                            'translations' => [
4995
                                'cro-HR' => 'swap-this',
4996
                            ],
4997
                        ],
4998
                    ],
4999
                    'alwaysAvailable' => false,
5000
                    'isHistory' => false,
5001
                    'isCustom' => false,
5002
                    'forward' => false,
5003
                ]
5004
            ),
5005
            $urlAlias
5006
        );
5007
5008
        $urlAlias = $handler->lookup('dva/swap-that');
5009
        $this->assertEquals(
5010
            new UrlAlias(
5011
                [
5012
                    'id' => '3-' . md5('swap-that'),
5013
                    'type' => UrlAlias::LOCATION,
5014
                    'destination' => 319,
5015
                    'languageCodes' => [
5016
                        'cro-HR',
5017
                    ],
5018
                    'pathData' => [
5019
                        [
5020
                            'always-available' => false,
5021
                            'translations' => [
5022
                                'cro-HR' => 'dva',
5023
                            ],
5024
                        ],
5025
                        [
5026
                            'always-available' => false,
5027
                            'translations' => [
5028
                                'cro-HR' => 'swap-that',
5029
                            ],
5030
                        ],
5031
                    ],
5032
                    'alwaysAvailable' => false,
5033
                    'isHistory' => true,
5034
                    'isCustom' => false,
5035
                    'forward' => false,
5036
                ]
5037
            ),
5038
            $urlAlias
5039
        );
5040
5041
        $urlAlias = $handler->lookup('jedan/swap-this');
5042
        $this->assertEquals(
5043
            new UrlAlias(
5044
                [
5045
                    'id' => '2-' . md5('swap-this'),
5046
                    'type' => UrlAlias::LOCATION,
5047
                    'destination' => 318,
5048
                    'languageCodes' => [
5049
                        'cro-HR',
5050
                    ],
5051
                    'pathData' => [
5052
                        [
5053
                            'always-available' => false,
5054
                            'translations' => [
5055
                                'cro-HR' => 'jedan',
5056
                            ],
5057
                        ],
5058
                        [
5059
                            'always-available' => false,
5060
                            'translations' => [
5061
                                'cro-HR' => 'swap-this',
5062
                            ],
5063
                        ],
5064
                    ],
5065
                    'alwaysAvailable' => false,
5066
                    'isHistory' => true,
5067
                    'isCustom' => false,
5068
                    'forward' => false,
5069
                ]
5070
            ),
5071
            $urlAlias
5072
        );
5073
    }
5074
5075
    /**
5076
     * Test for the locationSwapped() method.
@@ 5080-5225 (lines=146) @@
5077
     *
5078
     * @group swap
5079
     */
5080
    public function testLocationSwappedWithReusingNopEntry()
5081
    {
5082
        $handler = $this->getHandler();
5083
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_swap_reusing_nop.php');
5084
5085
        $countBeforeReusing = $this->countRows();
5086
5087
        $handler->locationSwapped(316, 314, 317, 315);
5088
5089
        $this->assertEquals(
5090
            $countBeforeReusing + 1,
5091
            $this->countRows()
5092
        );
5093
5094
        $urlAlias = $handler->lookup('jedan/swap-that');
5095
        $this->assertEquals(
5096
            new UrlAlias(
5097
                [
5098
                    'id' => '2-' . md5('swap-that'),
5099
                    'type' => UrlAlias::LOCATION,
5100
                    'destination' => 316,
5101
                    'languageCodes' => [
5102
                        'cro-HR',
5103
                    ],
5104
                    'pathData' => [
5105
                        [
5106
                            'always-available' => false,
5107
                            'translations' => [
5108
                                'cro-HR' => 'jedan',
5109
                            ],
5110
                        ],
5111
                        [
5112
                            'always-available' => false,
5113
                            'translations' => [
5114
                                'cro-HR' => 'swap-that',
5115
                            ],
5116
                        ],
5117
                    ],
5118
                    'alwaysAvailable' => false,
5119
                    'isHistory' => false,
5120
                    'isCustom' => false,
5121
                    'forward' => false,
5122
                ]
5123
            ),
5124
            $urlAlias
5125
        );
5126
5127
        $urlAlias = $handler->lookup('dva/swap-this');
5128
        $this->assertEquals(
5129
            new UrlAlias(
5130
                [
5131
                    'id' => '3-' . md5('swap-this'),
5132
                    'type' => UrlAlias::LOCATION,
5133
                    'destination' => 317,
5134
                    'languageCodes' => [
5135
                        'cro-HR',
5136
                    ],
5137
                    'pathData' => [
5138
                        [
5139
                            'always-available' => false,
5140
                            'translations' => [
5141
                                'cro-HR' => 'dva',
5142
                            ],
5143
                        ],
5144
                        [
5145
                            'always-available' => false,
5146
                            'translations' => [
5147
                                'cro-HR' => 'swap-this',
5148
                            ],
5149
                        ],
5150
                    ],
5151
                    'alwaysAvailable' => false,
5152
                    'isHistory' => false,
5153
                    'isCustom' => false,
5154
                    'forward' => false,
5155
                ]
5156
            ),
5157
            $urlAlias
5158
        );
5159
5160
        $urlAlias = $handler->lookup('dva/swap-that');
5161
        $this->assertEquals(
5162
            new UrlAlias(
5163
                [
5164
                    'id' => '3-' . md5('swap-that'),
5165
                    'type' => UrlAlias::LOCATION,
5166
                    'destination' => 317,
5167
                    'languageCodes' => [
5168
                        'cro-HR',
5169
                    ],
5170
                    'pathData' => [
5171
                        [
5172
                            'always-available' => false,
5173
                            'translations' => [
5174
                                'cro-HR' => 'dva',
5175
                            ],
5176
                        ],
5177
                        [
5178
                            'always-available' => false,
5179
                            'translations' => [
5180
                                'cro-HR' => 'swap-that',
5181
                            ],
5182
                        ],
5183
                    ],
5184
                    'alwaysAvailable' => false,
5185
                    'isHistory' => true,
5186
                    'isCustom' => false,
5187
                    'forward' => false,
5188
                ]
5189
            ),
5190
            $urlAlias
5191
        );
5192
5193
        $urlAlias = $handler->lookup('jedan/swap-this');
5194
        $this->assertEquals(
5195
            new UrlAlias(
5196
                [
5197
                    'id' => '2-' . md5('swap-this'),
5198
                    'type' => UrlAlias::LOCATION,
5199
                    'destination' => 316,
5200
                    'languageCodes' => [
5201
                        'cro-HR',
5202
                    ],
5203
                    'pathData' => [
5204
                        [
5205
                            'always-available' => false,
5206
                            'translations' => [
5207
                                'cro-HR' => 'jedan',
5208
                            ],
5209
                        ],
5210
                        [
5211
                            'always-available' => false,
5212
                            'translations' => [
5213
                                'cro-HR' => 'swap-this',
5214
                            ],
5215
                        ],
5216
                    ],
5217
                    'alwaysAvailable' => false,
5218
                    'isHistory' => true,
5219
                    'isCustom' => false,
5220
                    'forward' => false,
5221
                ]
5222
            ),
5223
            $urlAlias
5224
        );
5225
    }
5226
5227
    /**
5228
     * Test for the locationSwapped() method.