Code Duplication    Length = 68-68 lines in 4 locations

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

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