Code Duplication    Length = 68-68 lines in 4 locations

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

@@ 3529-3596 (lines=68) @@
3526
     *
3527
     * @group swap
3528
     */
3529
    public function testLocationSwappedSiblingsSimple()
3530
    {
3531
        $handler = $this->getHandler();
3532
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_swap_siblings_simple.php');
3533
3534
        $countBeforeReusing = $this->countRows();
3535
3536
        $handler->locationSwapped(314, 2, 315, 2);
3537
3538
        $this->assertEquals(
3539
            $countBeforeReusing,
3540
            $this->countRows()
3541
        );
3542
3543
        $urlAlias = $handler->lookup('jedan');
3544
        $this->assertEquals(
3545
            new UrlAlias(
3546
                [
3547
                    'id' => '0-' . md5('jedan'),
3548
                    'type' => UrlAlias::LOCATION,
3549
                    'destination' => 315,
3550
                    'languageCodes' => [
3551
                        'cro-HR',
3552
                    ],
3553
                    'pathData' => [
3554
                        [
3555
                            'always-available' => false,
3556
                            'translations' => [
3557
                                'cro-HR' => 'jedan',
3558
                            ],
3559
                        ],
3560
                    ],
3561
                    'alwaysAvailable' => false,
3562
                    'isHistory' => false,
3563
                    'isCustom' => false,
3564
                    'forward' => false,
3565
                ]
3566
            ),
3567
            $urlAlias
3568
        );
3569
3570
        $urlAlias = $handler->lookup('dva');
3571
        $this->assertEquals(
3572
            new UrlAlias(
3573
                [
3574
                    'id' => '0-' . md5('dva'),
3575
                    'type' => UrlAlias::LOCATION,
3576
                    'destination' => 314,
3577
                    'languageCodes' => [
3578
                        'cro-HR',
3579
                    ],
3580
                    'pathData' => [
3581
                        [
3582
                            'always-available' => false,
3583
                            'translations' => [
3584
                                'cro-HR' => 'dva',
3585
                            ],
3586
                        ],
3587
                    ],
3588
                    'alwaysAvailable' => false,
3589
                    'isHistory' => false,
3590
                    'isCustom' => false,
3591
                    'forward' => false,
3592
                ]
3593
            ),
3594
            $urlAlias
3595
        );
3596
    }
3597
3598
    /**
3599
     * Test for the locationSwapped() method.
@@ 3603-3670 (lines=68) @@
3600
     *
3601
     * @group swap
3602
     */
3603
    public function testLocationSwappedSiblingsSimpleReverse()
3604
    {
3605
        $handler = $this->getHandler();
3606
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_swap_siblings_simple.php');
3607
3608
        $countBeforeReusing = $this->countRows();
3609
3610
        $handler->locationSwapped(315, 2, 314, 2);
3611
3612
        $this->assertEquals(
3613
            $countBeforeReusing,
3614
            $this->countRows()
3615
        );
3616
3617
        $urlAlias = $handler->lookup('jedan');
3618
        $this->assertEquals(
3619
            new UrlAlias(
3620
                [
3621
                    'id' => '0-' . md5('jedan'),
3622
                    'type' => UrlAlias::LOCATION,
3623
                    'destination' => 315,
3624
                    'languageCodes' => [
3625
                        'cro-HR',
3626
                    ],
3627
                    'pathData' => [
3628
                        [
3629
                            'always-available' => false,
3630
                            'translations' => [
3631
                                'cro-HR' => 'jedan',
3632
                            ],
3633
                        ],
3634
                    ],
3635
                    'alwaysAvailable' => false,
3636
                    'isHistory' => false,
3637
                    'isCustom' => false,
3638
                    'forward' => false,
3639
                ]
3640
            ),
3641
            $urlAlias
3642
        );
3643
3644
        $urlAlias = $handler->lookup('dva');
3645
        $this->assertEquals(
3646
            new UrlAlias(
3647
                [
3648
                    'id' => '0-' . md5('dva'),
3649
                    'type' => UrlAlias::LOCATION,
3650
                    'destination' => 314,
3651
                    'languageCodes' => [
3652
                        'cro-HR',
3653
                    ],
3654
                    'pathData' => [
3655
                        [
3656
                            'always-available' => false,
3657
                            'translations' => [
3658
                                'cro-HR' => 'dva',
3659
                            ],
3660
                        ],
3661
                    ],
3662
                    'alwaysAvailable' => false,
3663
                    'isHistory' => false,
3664
                    'isCustom' => false,
3665
                    'forward' => false,
3666
                ]
3667
            ),
3668
            $urlAlias
3669
        );
3670
    }
3671
3672
    /**
3673
     * Test for the locationSwapped() method.
@@ 3933-4000 (lines=68) @@
3930
     *
3931
     * @group swap
3932
     */
3933
    public function testLocationSwappedSiblingsSameName()
3934
    {
3935
        $handler = $this->getHandler();
3936
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_swap_siblings_same_name.php');
3937
3938
        $countBeforeReusing = $this->countRows();
3939
3940
        $handler->locationSwapped(314, 2, 315, 2);
3941
3942
        $this->assertEquals(
3943
            $countBeforeReusing,
3944
            $this->countRows()
3945
        );
3946
3947
        $urlAlias = $handler->lookup('swap');
3948
        $this->assertEquals(
3949
            new UrlAlias(
3950
                [
3951
                    'id' => '0-' . md5('swap'),
3952
                    'type' => UrlAlias::LOCATION,
3953
                    'destination' => 314,
3954
                    'languageCodes' => [
3955
                        'cro-HR',
3956
                    ],
3957
                    'pathData' => [
3958
                        [
3959
                            'always-available' => false,
3960
                            'translations' => [
3961
                                'cro-HR' => 'swap',
3962
                            ],
3963
                        ],
3964
                    ],
3965
                    'alwaysAvailable' => false,
3966
                    'isHistory' => false,
3967
                    'isCustom' => false,
3968
                    'forward' => false,
3969
                ]
3970
            ),
3971
            $urlAlias
3972
        );
3973
3974
        $urlAlias = $handler->lookup('swap2');
3975
        $this->assertEquals(
3976
            new UrlAlias(
3977
                [
3978
                    'id' => '0-' . md5('swap2'),
3979
                    'type' => UrlAlias::LOCATION,
3980
                    'destination' => 315,
3981
                    'languageCodes' => [
3982
                        'cro-HR',
3983
                    ],
3984
                    'pathData' => [
3985
                        [
3986
                            'always-available' => false,
3987
                            'translations' => [
3988
                                'cro-HR' => 'swap2',
3989
                            ],
3990
                        ],
3991
                    ],
3992
                    'alwaysAvailable' => false,
3993
                    'isHistory' => false,
3994
                    'isCustom' => false,
3995
                    'forward' => false,
3996
                ]
3997
            ),
3998
            $urlAlias
3999
        );
4000
    }
4001
4002
    /**
4003
     * Test for the locationSwapped() method.
@@ 4007-4074 (lines=68) @@
4004
     *
4005
     * @group swap
4006
     */
4007
    public function testLocationSwappedSiblingsSameNameReverse()
4008
    {
4009
        $handler = $this->getHandler();
4010
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_swap_siblings_same_name.php');
4011
4012
        $countBeforeReusing = $this->countRows();
4013
4014
        $handler->locationSwapped(315, 2, 314, 2);
4015
4016
        $this->assertEquals(
4017
            $countBeforeReusing,
4018
            $this->countRows()
4019
        );
4020
4021
        $urlAlias = $handler->lookup('swap');
4022
        $this->assertEquals(
4023
            new UrlAlias(
4024
                [
4025
                    'id' => '0-' . md5('swap'),
4026
                    'type' => UrlAlias::LOCATION,
4027
                    'destination' => 314,
4028
                    'languageCodes' => [
4029
                        'cro-HR',
4030
                    ],
4031
                    'pathData' => [
4032
                        [
4033
                            'always-available' => false,
4034
                            'translations' => [
4035
                                'cro-HR' => 'swap',
4036
                            ],
4037
                        ],
4038
                    ],
4039
                    'alwaysAvailable' => false,
4040
                    'isHistory' => false,
4041
                    'isCustom' => false,
4042
                    'forward' => false,
4043
                ]
4044
            ),
4045
            $urlAlias
4046
        );
4047
4048
        $urlAlias = $handler->lookup('swap2');
4049
        $this->assertEquals(
4050
            new UrlAlias(
4051
                [
4052
                    'id' => '0-' . md5('swap2'),
4053
                    'type' => UrlAlias::LOCATION,
4054
                    'destination' => 315,
4055
                    'languageCodes' => [
4056
                        'cro-HR',
4057
                    ],
4058
                    'pathData' => [
4059
                        [
4060
                            'always-available' => false,
4061
                            'translations' => [
4062
                                'cro-HR' => 'swap2',
4063
                            ],
4064
                        ],
4065
                    ],
4066
                    'alwaysAvailable' => false,
4067
                    'isHistory' => false,
4068
                    'isCustom' => false,
4069
                    'forward' => false,
4070
                ]
4071
            ),
4072
            $urlAlias
4073
        );
4074
    }
4075
4076
    /**
4077
     * Test for the locationSwapped() method.