Code Duplication    Length = 68-68 lines in 4 locations

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

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