Code Duplication    Length = 68-68 lines in 4 locations

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

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