Code Duplication    Length = 68-68 lines in 4 locations

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

@@ 3475-3542 (lines=68) @@
3472
     *
3473
     * @group swap
3474
     */
3475
    public function testLocationSwappedSiblingsSimple()
3476
    {
3477
        $handler = $this->getHandler();
3478
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_swap_siblings_simple.php');
3479
3480
        $countBeforeReusing = $this->countRows();
3481
3482
        $handler->locationSwapped(314, 2, 315, 2);
3483
3484
        $this->assertEquals(
3485
            $countBeforeReusing,
3486
            $this->countRows()
3487
        );
3488
3489
        $urlAlias = $handler->lookup('jedan');
3490
        $this->assertEquals(
3491
            new UrlAlias(
3492
                [
3493
                    'id' => '0-' . md5('jedan'),
3494
                    'type' => UrlAlias::LOCATION,
3495
                    'destination' => 315,
3496
                    'languageCodes' => [
3497
                        'cro-HR',
3498
                    ],
3499
                    'pathData' => [
3500
                        [
3501
                            'always-available' => false,
3502
                            'translations' => [
3503
                                'cro-HR' => 'jedan',
3504
                            ],
3505
                        ],
3506
                    ],
3507
                    'alwaysAvailable' => false,
3508
                    'isHistory' => false,
3509
                    'isCustom' => false,
3510
                    'forward' => false,
3511
                ]
3512
            ),
3513
            $urlAlias
3514
        );
3515
3516
        $urlAlias = $handler->lookup('dva');
3517
        $this->assertEquals(
3518
            new UrlAlias(
3519
                [
3520
                    'id' => '0-' . md5('dva'),
3521
                    'type' => UrlAlias::LOCATION,
3522
                    'destination' => 314,
3523
                    'languageCodes' => [
3524
                        'cro-HR',
3525
                    ],
3526
                    'pathData' => [
3527
                        [
3528
                            'always-available' => false,
3529
                            'translations' => [
3530
                                'cro-HR' => 'dva',
3531
                            ],
3532
                        ],
3533
                    ],
3534
                    'alwaysAvailable' => false,
3535
                    'isHistory' => false,
3536
                    'isCustom' => false,
3537
                    'forward' => false,
3538
                ]
3539
            ),
3540
            $urlAlias
3541
        );
3542
    }
3543
3544
    /**
3545
     * Test for the locationSwapped() method.
@@ 3549-3616 (lines=68) @@
3546
     *
3547
     * @group swap
3548
     */
3549
    public function testLocationSwappedSiblingsSimpleReverse()
3550
    {
3551
        $handler = $this->getHandler();
3552
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_swap_siblings_simple.php');
3553
3554
        $countBeforeReusing = $this->countRows();
3555
3556
        $handler->locationSwapped(315, 2, 314, 2);
3557
3558
        $this->assertEquals(
3559
            $countBeforeReusing,
3560
            $this->countRows()
3561
        );
3562
3563
        $urlAlias = $handler->lookup('jedan');
3564
        $this->assertEquals(
3565
            new UrlAlias(
3566
                [
3567
                    'id' => '0-' . md5('jedan'),
3568
                    'type' => UrlAlias::LOCATION,
3569
                    'destination' => 315,
3570
                    'languageCodes' => [
3571
                        'cro-HR',
3572
                    ],
3573
                    'pathData' => [
3574
                        [
3575
                            'always-available' => false,
3576
                            'translations' => [
3577
                                'cro-HR' => 'jedan',
3578
                            ],
3579
                        ],
3580
                    ],
3581
                    'alwaysAvailable' => false,
3582
                    'isHistory' => false,
3583
                    'isCustom' => false,
3584
                    'forward' => false,
3585
                ]
3586
            ),
3587
            $urlAlias
3588
        );
3589
3590
        $urlAlias = $handler->lookup('dva');
3591
        $this->assertEquals(
3592
            new UrlAlias(
3593
                [
3594
                    'id' => '0-' . md5('dva'),
3595
                    'type' => UrlAlias::LOCATION,
3596
                    'destination' => 314,
3597
                    'languageCodes' => [
3598
                        'cro-HR',
3599
                    ],
3600
                    'pathData' => [
3601
                        [
3602
                            'always-available' => false,
3603
                            'translations' => [
3604
                                'cro-HR' => 'dva',
3605
                            ],
3606
                        ],
3607
                    ],
3608
                    'alwaysAvailable' => false,
3609
                    'isHistory' => false,
3610
                    'isCustom' => false,
3611
                    'forward' => false,
3612
                ]
3613
            ),
3614
            $urlAlias
3615
        );
3616
    }
3617
3618
    /**
3619
     * Test for the locationSwapped() method.
@@ 3879-3946 (lines=68) @@
3876
     *
3877
     * @group swap
3878
     */
3879
    public function testLocationSwappedSiblingsSameName()
3880
    {
3881
        $handler = $this->getHandler();
3882
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_swap_siblings_same_name.php');
3883
3884
        $countBeforeReusing = $this->countRows();
3885
3886
        $handler->locationSwapped(314, 2, 315, 2);
3887
3888
        $this->assertEquals(
3889
            $countBeforeReusing,
3890
            $this->countRows()
3891
        );
3892
3893
        $urlAlias = $handler->lookup('swap');
3894
        $this->assertEquals(
3895
            new UrlAlias(
3896
                [
3897
                    'id' => '0-' . md5('swap'),
3898
                    'type' => UrlAlias::LOCATION,
3899
                    'destination' => 314,
3900
                    'languageCodes' => [
3901
                        'cro-HR',
3902
                    ],
3903
                    'pathData' => [
3904
                        [
3905
                            'always-available' => false,
3906
                            'translations' => [
3907
                                'cro-HR' => 'swap',
3908
                            ],
3909
                        ],
3910
                    ],
3911
                    'alwaysAvailable' => false,
3912
                    'isHistory' => false,
3913
                    'isCustom' => false,
3914
                    'forward' => false,
3915
                ]
3916
            ),
3917
            $urlAlias
3918
        );
3919
3920
        $urlAlias = $handler->lookup('swap2');
3921
        $this->assertEquals(
3922
            new UrlAlias(
3923
                [
3924
                    'id' => '0-' . md5('swap2'),
3925
                    'type' => UrlAlias::LOCATION,
3926
                    'destination' => 315,
3927
                    'languageCodes' => [
3928
                        'cro-HR',
3929
                    ],
3930
                    'pathData' => [
3931
                        [
3932
                            'always-available' => false,
3933
                            'translations' => [
3934
                                'cro-HR' => 'swap2',
3935
                            ],
3936
                        ],
3937
                    ],
3938
                    'alwaysAvailable' => false,
3939
                    'isHistory' => false,
3940
                    'isCustom' => false,
3941
                    'forward' => false,
3942
                ]
3943
            ),
3944
            $urlAlias
3945
        );
3946
    }
3947
3948
    /**
3949
     * Test for the locationSwapped() method.
@@ 3953-4020 (lines=68) @@
3950
     *
3951
     * @group swap
3952
     */
3953
    public function testLocationSwappedSiblingsSameNameReverse()
3954
    {
3955
        $handler = $this->getHandler();
3956
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_swap_siblings_same_name.php');
3957
3958
        $countBeforeReusing = $this->countRows();
3959
3960
        $handler->locationSwapped(315, 2, 314, 2);
3961
3962
        $this->assertEquals(
3963
            $countBeforeReusing,
3964
            $this->countRows()
3965
        );
3966
3967
        $urlAlias = $handler->lookup('swap');
3968
        $this->assertEquals(
3969
            new UrlAlias(
3970
                [
3971
                    'id' => '0-' . md5('swap'),
3972
                    'type' => UrlAlias::LOCATION,
3973
                    'destination' => 314,
3974
                    'languageCodes' => [
3975
                        'cro-HR',
3976
                    ],
3977
                    'pathData' => [
3978
                        [
3979
                            'always-available' => false,
3980
                            'translations' => [
3981
                                'cro-HR' => 'swap',
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('swap2');
3995
        $this->assertEquals(
3996
            new UrlAlias(
3997
                [
3998
                    'id' => '0-' . md5('swap2'),
3999
                    'type' => UrlAlias::LOCATION,
4000
                    'destination' => 315,
4001
                    'languageCodes' => [
4002
                        'cro-HR',
4003
                    ],
4004
                    'pathData' => [
4005
                        [
4006
                            'always-available' => false,
4007
                            'translations' => [
4008
                                'cro-HR' => 'swap2',
4009
                            ],
4010
                        ],
4011
                    ],
4012
                    'alwaysAvailable' => false,
4013
                    'isHistory' => false,
4014
                    'isCustom' => false,
4015
                    'forward' => false,
4016
                ]
4017
            ),
4018
            $urlAlias
4019
        );
4020
    }
4021
4022
    /**
4023
     * Test for the locationSwapped() method.