Code Duplication    Length = 146-146 lines in 2 locations

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

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