Code Duplication    Length = 146-146 lines in 2 locations

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

@@ 2961-3106 (lines=146) @@
2958
     *
2959
     * @group swap
2960
     */
2961
    public function testLocationSwappedSimpleWithHistory()
2962
    {
2963
        $handler = $this->getHandler();
2964
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_swap_simple_history.php');
2965
2966
        $countBeforeReusing = $this->countRows();
2967
2968
        $handler->locationSwapped(316, 314, 317, 315);
2969
2970
        $this->assertEquals(
2971
            $countBeforeReusing,
2972
            $this->countRows()
2973
        );
2974
2975
        $urlAlias = $handler->lookup('jedan/swap');
2976
        $this->assertEquals(
2977
            new UrlAlias(
2978
                array(
2979
                    'id' => '2-' . md5('swap'),
2980
                    'type' => UrlAlias::LOCATION,
2981
                    'destination' => 316,
2982
                    'languageCodes' => array(
2983
                        'cro-HR',
2984
                    ),
2985
                    'pathData' => array(
2986
                        array(
2987
                            'always-available' => false,
2988
                            'translations' => array(
2989
                                'cro-HR' => 'jedan',
2990
                            ),
2991
                        ),
2992
                        array(
2993
                            'always-available' => false,
2994
                            'translations' => array(
2995
                                'cro-HR' => 'swap',
2996
                            ),
2997
                        ),
2998
                    ),
2999
                    'alwaysAvailable' => false,
3000
                    'isHistory' => true,
3001
                    'isCustom' => false,
3002
                    'forward' => false,
3003
                )
3004
            ),
3005
            $urlAlias
3006
        );
3007
3008
        $urlAlias = $handler->lookup('dva/swap');
3009
        $this->assertEquals(
3010
            new UrlAlias(
3011
                array(
3012
                    'id' => '3-' . md5('swap'),
3013
                    'type' => UrlAlias::LOCATION,
3014
                    'destination' => 317,
3015
                    'languageCodes' => array(
3016
                        'cro-HR',
3017
                    ),
3018
                    'pathData' => array(
3019
                        array(
3020
                            'always-available' => false,
3021
                            'translations' => array(
3022
                                'cro-HR' => 'dva',
3023
                            ),
3024
                        ),
3025
                        array(
3026
                            'always-available' => false,
3027
                            'translations' => array(
3028
                                'cro-HR' => 'swap',
3029
                            ),
3030
                        ),
3031
                    ),
3032
                    'alwaysAvailable' => false,
3033
                    'isHistory' => true,
3034
                    'isCustom' => false,
3035
                    'forward' => false,
3036
                )
3037
            ),
3038
            $urlAlias
3039
        );
3040
3041
        $urlAlias = $handler->lookup('jedan/swap-new');
3042
        $this->assertEquals(
3043
            new UrlAlias(
3044
                array(
3045
                    'id' => '2-' . md5('swap-new'),
3046
                    'type' => UrlAlias::LOCATION,
3047
                    'destination' => 316,
3048
                    'languageCodes' => array(
3049
                        'cro-HR',
3050
                    ),
3051
                    'pathData' => array(
3052
                        array(
3053
                            'always-available' => false,
3054
                            'translations' => array(
3055
                                'cro-HR' => 'jedan',
3056
                            ),
3057
                        ),
3058
                        array(
3059
                            'always-available' => false,
3060
                            'translations' => array(
3061
                                'cro-HR' => 'swap-new',
3062
                            ),
3063
                        ),
3064
                    ),
3065
                    'alwaysAvailable' => false,
3066
                    'isHistory' => false,
3067
                    'isCustom' => false,
3068
                    'forward' => false,
3069
                )
3070
            ),
3071
            $urlAlias
3072
        );
3073
3074
        $urlAlias = $handler->lookup('dva/swap-new');
3075
        $this->assertEquals(
3076
            new UrlAlias(
3077
                array(
3078
                    'id' => '3-' . md5('swap-new'),
3079
                    'type' => UrlAlias::LOCATION,
3080
                    'destination' => 317,
3081
                    'languageCodes' => array(
3082
                        'cro-HR',
3083
                    ),
3084
                    'pathData' => array(
3085
                        array(
3086
                            'always-available' => false,
3087
                            'translations' => array(
3088
                                'cro-HR' => 'dva',
3089
                            ),
3090
                        ),
3091
                        array(
3092
                            'always-available' => false,
3093
                            'translations' => array(
3094
                                'cro-HR' => 'swap-new',
3095
                            ),
3096
                        ),
3097
                    ),
3098
                    'alwaysAvailable' => false,
3099
                    'isHistory' => false,
3100
                    'isCustom' => false,
3101
                    'forward' => false,
3102
                )
3103
            ),
3104
            $urlAlias
3105
        );
3106
    }
3107
3108
    /**
3109
     * Test for the locationSwapped() method.
@@ 4331-4476 (lines=146) @@
4328
     *
4329
     * @group swap
4330
     */
4331
    public function testLocationSwappedWithReusingExternalHistory()
4332
    {
4333
        $handler = $this->getHandler();
4334
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_swap_reusing_external_history.php');
4335
4336
        $countBeforeReusing = $this->countRows();
4337
4338
        $handler->locationSwapped(318, 314, 319, 315);
4339
4340
        $this->assertEquals(
4341
            $countBeforeReusing,
4342
            $this->countRows()
4343
        );
4344
4345
        $urlAlias = $handler->lookup('jedan/swap-that');
4346
        $this->assertEquals(
4347
            new UrlAlias(
4348
                array(
4349
                    'id' => '2-' . md5('swap-that'),
4350
                    'type' => UrlAlias::LOCATION,
4351
                    'destination' => 318,
4352
                    'languageCodes' => array(
4353
                        'cro-HR',
4354
                    ),
4355
                    'pathData' => array(
4356
                        array(
4357
                            'always-available' => false,
4358
                            'translations' => array(
4359
                                'cro-HR' => 'jedan',
4360
                            ),
4361
                        ),
4362
                        array(
4363
                            'always-available' => false,
4364
                            'translations' => array(
4365
                                'cro-HR' => 'swap-that',
4366
                            ),
4367
                        ),
4368
                    ),
4369
                    'alwaysAvailable' => false,
4370
                    'isHistory' => false,
4371
                    'isCustom' => false,
4372
                    'forward' => false,
4373
                )
4374
            ),
4375
            $urlAlias
4376
        );
4377
4378
        $urlAlias = $handler->lookup('dva/swap-this');
4379
        $this->assertEquals(
4380
            new UrlAlias(
4381
                array(
4382
                    'id' => '3-' . md5('swap-this'),
4383
                    'type' => UrlAlias::LOCATION,
4384
                    'destination' => 319,
4385
                    'languageCodes' => array(
4386
                        'cro-HR',
4387
                    ),
4388
                    'pathData' => array(
4389
                        array(
4390
                            'always-available' => false,
4391
                            'translations' => array(
4392
                                'cro-HR' => 'dva',
4393
                            ),
4394
                        ),
4395
                        array(
4396
                            'always-available' => false,
4397
                            'translations' => array(
4398
                                'cro-HR' => 'swap-this',
4399
                            ),
4400
                        ),
4401
                    ),
4402
                    'alwaysAvailable' => false,
4403
                    'isHistory' => false,
4404
                    'isCustom' => false,
4405
                    'forward' => false,
4406
                )
4407
            ),
4408
            $urlAlias
4409
        );
4410
4411
        $urlAlias = $handler->lookup('dva/swap-that');
4412
        $this->assertEquals(
4413
            new UrlAlias(
4414
                array(
4415
                    'id' => '3-' . md5('swap-that'),
4416
                    'type' => UrlAlias::LOCATION,
4417
                    'destination' => 319,
4418
                    'languageCodes' => array(
4419
                        'cro-HR',
4420
                    ),
4421
                    'pathData' => array(
4422
                        array(
4423
                            'always-available' => false,
4424
                            'translations' => array(
4425
                                'cro-HR' => 'dva',
4426
                            ),
4427
                        ),
4428
                        array(
4429
                            'always-available' => false,
4430
                            'translations' => array(
4431
                                'cro-HR' => 'swap-that',
4432
                            ),
4433
                        ),
4434
                    ),
4435
                    'alwaysAvailable' => false,
4436
                    'isHistory' => true,
4437
                    'isCustom' => false,
4438
                    'forward' => false,
4439
                )
4440
            ),
4441
            $urlAlias
4442
        );
4443
4444
        $urlAlias = $handler->lookup('jedan/swap-this');
4445
        $this->assertEquals(
4446
            new UrlAlias(
4447
                array(
4448
                    'id' => '2-' . md5('swap-this'),
4449
                    'type' => UrlAlias::LOCATION,
4450
                    'destination' => 318,
4451
                    'languageCodes' => array(
4452
                        'cro-HR',
4453
                    ),
4454
                    'pathData' => array(
4455
                        array(
4456
                            'always-available' => false,
4457
                            'translations' => array(
4458
                                'cro-HR' => 'jedan',
4459
                            ),
4460
                        ),
4461
                        array(
4462
                            'always-available' => false,
4463
                            'translations' => array(
4464
                                'cro-HR' => 'swap-this',
4465
                            ),
4466
                        ),
4467
                    ),
4468
                    'alwaysAvailable' => false,
4469
                    'isHistory' => true,
4470
                    'isCustom' => false,
4471
                    'forward' => false,
4472
                )
4473
            ),
4474
            $urlAlias
4475
        );
4476
    }
4477
4478
    /**
4479
     * Test for the locationSwapped() method.