Code Duplication    Length = 146-146 lines in 2 locations

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

@@ 3167-3312 (lines=146) @@
3164
     *
3165
     * @group swap
3166
     */
3167
    public function testLocationSwappedSimpleWithHistory()
3168
    {
3169
        $handler = $this->getHandler();
3170
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_swap_simple_history.php');
3171
3172
        $countBeforeReusing = $this->countRows();
3173
3174
        $handler->locationSwapped(316, 314, 317, 315);
3175
3176
        $this->assertEquals(
3177
            $countBeforeReusing,
3178
            $this->countRows()
3179
        );
3180
3181
        $urlAlias = $handler->lookup('jedan/swap');
3182
        $this->assertEquals(
3183
            new UrlAlias(
3184
                array(
3185
                    'id' => '2-' . md5('swap'),
3186
                    'type' => UrlAlias::LOCATION,
3187
                    'destination' => 316,
3188
                    'languageCodes' => array(
3189
                        'cro-HR',
3190
                    ),
3191
                    'pathData' => array(
3192
                        array(
3193
                            'always-available' => false,
3194
                            'translations' => array(
3195
                                'cro-HR' => 'jedan',
3196
                            ),
3197
                        ),
3198
                        array(
3199
                            'always-available' => false,
3200
                            'translations' => array(
3201
                                'cro-HR' => 'swap',
3202
                            ),
3203
                        ),
3204
                    ),
3205
                    'alwaysAvailable' => false,
3206
                    'isHistory' => true,
3207
                    'isCustom' => false,
3208
                    'forward' => false,
3209
                )
3210
            ),
3211
            $urlAlias
3212
        );
3213
3214
        $urlAlias = $handler->lookup('dva/swap');
3215
        $this->assertEquals(
3216
            new UrlAlias(
3217
                array(
3218
                    'id' => '3-' . md5('swap'),
3219
                    'type' => UrlAlias::LOCATION,
3220
                    'destination' => 317,
3221
                    'languageCodes' => array(
3222
                        'cro-HR',
3223
                    ),
3224
                    'pathData' => array(
3225
                        array(
3226
                            'always-available' => false,
3227
                            'translations' => array(
3228
                                'cro-HR' => 'dva',
3229
                            ),
3230
                        ),
3231
                        array(
3232
                            'always-available' => false,
3233
                            'translations' => array(
3234
                                'cro-HR' => 'swap',
3235
                            ),
3236
                        ),
3237
                    ),
3238
                    'alwaysAvailable' => false,
3239
                    'isHistory' => true,
3240
                    'isCustom' => false,
3241
                    'forward' => false,
3242
                )
3243
            ),
3244
            $urlAlias
3245
        );
3246
3247
        $urlAlias = $handler->lookup('jedan/swap-new');
3248
        $this->assertEquals(
3249
            new UrlAlias(
3250
                array(
3251
                    'id' => '2-' . md5('swap-new'),
3252
                    'type' => UrlAlias::LOCATION,
3253
                    'destination' => 316,
3254
                    'languageCodes' => array(
3255
                        'cro-HR',
3256
                    ),
3257
                    'pathData' => array(
3258
                        array(
3259
                            'always-available' => false,
3260
                            'translations' => array(
3261
                                'cro-HR' => 'jedan',
3262
                            ),
3263
                        ),
3264
                        array(
3265
                            'always-available' => false,
3266
                            'translations' => array(
3267
                                'cro-HR' => 'swap-new',
3268
                            ),
3269
                        ),
3270
                    ),
3271
                    'alwaysAvailable' => false,
3272
                    'isHistory' => false,
3273
                    'isCustom' => false,
3274
                    'forward' => false,
3275
                )
3276
            ),
3277
            $urlAlias
3278
        );
3279
3280
        $urlAlias = $handler->lookup('dva/swap-new');
3281
        $this->assertEquals(
3282
            new UrlAlias(
3283
                array(
3284
                    'id' => '3-' . md5('swap-new'),
3285
                    'type' => UrlAlias::LOCATION,
3286
                    'destination' => 317,
3287
                    'languageCodes' => array(
3288
                        'cro-HR',
3289
                    ),
3290
                    'pathData' => array(
3291
                        array(
3292
                            'always-available' => false,
3293
                            'translations' => array(
3294
                                'cro-HR' => 'dva',
3295
                            ),
3296
                        ),
3297
                        array(
3298
                            'always-available' => false,
3299
                            'translations' => array(
3300
                                'cro-HR' => 'swap-new',
3301
                            ),
3302
                        ),
3303
                    ),
3304
                    'alwaysAvailable' => false,
3305
                    'isHistory' => false,
3306
                    'isCustom' => false,
3307
                    'forward' => false,
3308
                )
3309
            ),
3310
            $urlAlias
3311
        );
3312
    }
3313
3314
    /**
3315
     * Test for the locationSwapped() method.
@@ 4537-4682 (lines=146) @@
4534
     *
4535
     * @group swap
4536
     */
4537
    public function testLocationSwappedWithReusingExternalHistory()
4538
    {
4539
        $handler = $this->getHandler();
4540
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_swap_reusing_external_history.php');
4541
4542
        $countBeforeReusing = $this->countRows();
4543
4544
        $handler->locationSwapped(318, 314, 319, 315);
4545
4546
        $this->assertEquals(
4547
            $countBeforeReusing,
4548
            $this->countRows()
4549
        );
4550
4551
        $urlAlias = $handler->lookup('jedan/swap-that');
4552
        $this->assertEquals(
4553
            new UrlAlias(
4554
                array(
4555
                    'id' => '2-' . md5('swap-that'),
4556
                    'type' => UrlAlias::LOCATION,
4557
                    'destination' => 318,
4558
                    'languageCodes' => array(
4559
                        'cro-HR',
4560
                    ),
4561
                    'pathData' => array(
4562
                        array(
4563
                            'always-available' => false,
4564
                            'translations' => array(
4565
                                'cro-HR' => 'jedan',
4566
                            ),
4567
                        ),
4568
                        array(
4569
                            'always-available' => false,
4570
                            'translations' => array(
4571
                                'cro-HR' => 'swap-that',
4572
                            ),
4573
                        ),
4574
                    ),
4575
                    'alwaysAvailable' => false,
4576
                    'isHistory' => false,
4577
                    'isCustom' => false,
4578
                    'forward' => false,
4579
                )
4580
            ),
4581
            $urlAlias
4582
        );
4583
4584
        $urlAlias = $handler->lookup('dva/swap-this');
4585
        $this->assertEquals(
4586
            new UrlAlias(
4587
                array(
4588
                    'id' => '3-' . md5('swap-this'),
4589
                    'type' => UrlAlias::LOCATION,
4590
                    'destination' => 319,
4591
                    'languageCodes' => array(
4592
                        'cro-HR',
4593
                    ),
4594
                    'pathData' => array(
4595
                        array(
4596
                            'always-available' => false,
4597
                            'translations' => array(
4598
                                'cro-HR' => 'dva',
4599
                            ),
4600
                        ),
4601
                        array(
4602
                            'always-available' => false,
4603
                            'translations' => array(
4604
                                'cro-HR' => 'swap-this',
4605
                            ),
4606
                        ),
4607
                    ),
4608
                    'alwaysAvailable' => false,
4609
                    'isHistory' => false,
4610
                    'isCustom' => false,
4611
                    'forward' => false,
4612
                )
4613
            ),
4614
            $urlAlias
4615
        );
4616
4617
        $urlAlias = $handler->lookup('dva/swap-that');
4618
        $this->assertEquals(
4619
            new UrlAlias(
4620
                array(
4621
                    'id' => '3-' . md5('swap-that'),
4622
                    'type' => UrlAlias::LOCATION,
4623
                    'destination' => 319,
4624
                    'languageCodes' => array(
4625
                        'cro-HR',
4626
                    ),
4627
                    'pathData' => array(
4628
                        array(
4629
                            'always-available' => false,
4630
                            'translations' => array(
4631
                                'cro-HR' => 'dva',
4632
                            ),
4633
                        ),
4634
                        array(
4635
                            'always-available' => false,
4636
                            'translations' => array(
4637
                                'cro-HR' => 'swap-that',
4638
                            ),
4639
                        ),
4640
                    ),
4641
                    'alwaysAvailable' => false,
4642
                    'isHistory' => true,
4643
                    'isCustom' => false,
4644
                    'forward' => false,
4645
                )
4646
            ),
4647
            $urlAlias
4648
        );
4649
4650
        $urlAlias = $handler->lookup('jedan/swap-this');
4651
        $this->assertEquals(
4652
            new UrlAlias(
4653
                array(
4654
                    'id' => '2-' . md5('swap-this'),
4655
                    'type' => UrlAlias::LOCATION,
4656
                    'destination' => 318,
4657
                    'languageCodes' => array(
4658
                        'cro-HR',
4659
                    ),
4660
                    'pathData' => array(
4661
                        array(
4662
                            'always-available' => false,
4663
                            'translations' => array(
4664
                                'cro-HR' => 'jedan',
4665
                            ),
4666
                        ),
4667
                        array(
4668
                            'always-available' => false,
4669
                            'translations' => array(
4670
                                'cro-HR' => 'swap-this',
4671
                            ),
4672
                        ),
4673
                    ),
4674
                    'alwaysAvailable' => false,
4675
                    'isHistory' => true,
4676
                    'isCustom' => false,
4677
                    'forward' => false,
4678
                )
4679
            ),
4680
            $urlAlias
4681
        );
4682
    }
4683
4684
    /**
4685
     * @return int