Code Duplication    Length = 68-68 lines in 4 locations

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

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