Code Duplication    Length = 122-122 lines in 2 locations

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

@@ 3677-3798 (lines=122) @@
3674
     *
3675
     * @group swap
3676
     */
3677
    public function testLocationSwappedSiblingsSimpleWithHistory()
3678
    {
3679
        $handler = $this->getHandler();
3680
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_swap_siblings_simple_history.php');
3681
3682
        $countBeforeReusing = $this->countRows();
3683
3684
        $handler->locationSwapped(314, 2, 315, 2);
3685
3686
        $this->assertEquals(
3687
            $countBeforeReusing,
3688
            $this->countRows()
3689
        );
3690
3691
        $urlAlias = $handler->lookup('jedan');
3692
        $this->assertEquals(
3693
            new UrlAlias(
3694
                [
3695
                    'id' => '0-' . md5('jedan'),
3696
                    'type' => UrlAlias::LOCATION,
3697
                    'destination' => 314,
3698
                    'languageCodes' => [
3699
                        'cro-HR',
3700
                    ],
3701
                    'pathData' => [
3702
                        [
3703
                            'always-available' => false,
3704
                            'translations' => [
3705
                                'cro-HR' => 'jedan',
3706
                            ],
3707
                        ],
3708
                    ],
3709
                    'alwaysAvailable' => false,
3710
                    'isHistory' => true,
3711
                    'isCustom' => false,
3712
                    'forward' => false,
3713
                ]
3714
            ),
3715
            $urlAlias
3716
        );
3717
3718
        $urlAlias = $handler->lookup('dva');
3719
        $this->assertEquals(
3720
            new UrlAlias(
3721
                [
3722
                    'id' => '0-' . md5('dva'),
3723
                    'type' => UrlAlias::LOCATION,
3724
                    'destination' => 315,
3725
                    'languageCodes' => [
3726
                        'cro-HR',
3727
                    ],
3728
                    'pathData' => [
3729
                        [
3730
                            'always-available' => false,
3731
                            'translations' => [
3732
                                'cro-HR' => 'dva',
3733
                            ],
3734
                        ],
3735
                    ],
3736
                    'alwaysAvailable' => false,
3737
                    'isHistory' => true,
3738
                    'isCustom' => false,
3739
                    'forward' => false,
3740
                ]
3741
            ),
3742
            $urlAlias
3743
        );
3744
3745
        $urlAlias = $handler->lookup('jedan-new');
3746
        $this->assertEquals(
3747
            new UrlAlias(
3748
                [
3749
                    'id' => '0-' . md5('jedan-new'),
3750
                    'type' => UrlAlias::LOCATION,
3751
                    'destination' => 315,
3752
                    'languageCodes' => [
3753
                        'cro-HR',
3754
                    ],
3755
                    'pathData' => [
3756
                        [
3757
                            'always-available' => false,
3758
                            'translations' => [
3759
                                'cro-HR' => 'jedan-new',
3760
                            ],
3761
                        ],
3762
                    ],
3763
                    'alwaysAvailable' => false,
3764
                    'isHistory' => false,
3765
                    'isCustom' => false,
3766
                    'forward' => false,
3767
                ]
3768
            ),
3769
            $urlAlias
3770
        );
3771
3772
        $urlAlias = $handler->lookup('dva-new');
3773
        $this->assertEquals(
3774
            new UrlAlias(
3775
                [
3776
                    'id' => '0-' . md5('dva-new'),
3777
                    'type' => UrlAlias::LOCATION,
3778
                    'destination' => 314,
3779
                    'languageCodes' => [
3780
                        'cro-HR',
3781
                    ],
3782
                    'pathData' => [
3783
                        [
3784
                            'always-available' => false,
3785
                            'translations' => [
3786
                                'cro-HR' => 'dva-new',
3787
                            ],
3788
                        ],
3789
                    ],
3790
                    'alwaysAvailable' => false,
3791
                    'isHistory' => false,
3792
                    'isCustom' => false,
3793
                    'forward' => false,
3794
                ]
3795
            ),
3796
            $urlAlias
3797
        );
3798
    }
3799
3800
    /**
3801
     * Test for the locationSwapped() method.
@@ 3805-3926 (lines=122) @@
3802
     *
3803
     * @group swap
3804
     */
3805
    public function testLocationSwappedSiblingsSimpleWithHistoryReverse()
3806
    {
3807
        $handler = $this->getHandler();
3808
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_swap_siblings_simple_history.php');
3809
3810
        $countBeforeReusing = $this->countRows();
3811
3812
        $handler->locationSwapped(315, 2, 314, 2);
3813
3814
        $this->assertEquals(
3815
            $countBeforeReusing,
3816
            $this->countRows()
3817
        );
3818
3819
        $urlAlias = $handler->lookup('jedan');
3820
        $this->assertEquals(
3821
            new UrlAlias(
3822
                [
3823
                    'id' => '0-' . md5('jedan'),
3824
                    'type' => UrlAlias::LOCATION,
3825
                    'destination' => 314,
3826
                    'languageCodes' => [
3827
                        'cro-HR',
3828
                    ],
3829
                    'pathData' => [
3830
                        [
3831
                            'always-available' => false,
3832
                            'translations' => [
3833
                                'cro-HR' => 'jedan',
3834
                            ],
3835
                        ],
3836
                    ],
3837
                    'alwaysAvailable' => false,
3838
                    'isHistory' => true,
3839
                    'isCustom' => false,
3840
                    'forward' => false,
3841
                ]
3842
            ),
3843
            $urlAlias
3844
        );
3845
3846
        $urlAlias = $handler->lookup('dva');
3847
        $this->assertEquals(
3848
            new UrlAlias(
3849
                [
3850
                    'id' => '0-' . md5('dva'),
3851
                    'type' => UrlAlias::LOCATION,
3852
                    'destination' => 315,
3853
                    'languageCodes' => [
3854
                        'cro-HR',
3855
                    ],
3856
                    'pathData' => [
3857
                        [
3858
                            'always-available' => false,
3859
                            'translations' => [
3860
                                'cro-HR' => 'dva',
3861
                            ],
3862
                        ],
3863
                    ],
3864
                    'alwaysAvailable' => false,
3865
                    'isHistory' => true,
3866
                    'isCustom' => false,
3867
                    'forward' => false,
3868
                ]
3869
            ),
3870
            $urlAlias
3871
        );
3872
3873
        $urlAlias = $handler->lookup('jedan-new');
3874
        $this->assertEquals(
3875
            new UrlAlias(
3876
                [
3877
                    'id' => '0-' . md5('jedan-new'),
3878
                    'type' => UrlAlias::LOCATION,
3879
                    'destination' => 315,
3880
                    'languageCodes' => [
3881
                        'cro-HR',
3882
                    ],
3883
                    'pathData' => [
3884
                        [
3885
                            'always-available' => false,
3886
                            'translations' => [
3887
                                'cro-HR' => 'jedan-new',
3888
                            ],
3889
                        ],
3890
                    ],
3891
                    'alwaysAvailable' => false,
3892
                    'isHistory' => false,
3893
                    'isCustom' => false,
3894
                    'forward' => false,
3895
                ]
3896
            ),
3897
            $urlAlias
3898
        );
3899
3900
        $urlAlias = $handler->lookup('dva-new');
3901
        $this->assertEquals(
3902
            new UrlAlias(
3903
                [
3904
                    'id' => '0-' . md5('dva-new'),
3905
                    'type' => UrlAlias::LOCATION,
3906
                    'destination' => 314,
3907
                    'languageCodes' => [
3908
                        'cro-HR',
3909
                    ],
3910
                    'pathData' => [
3911
                        [
3912
                            'always-available' => false,
3913
                            'translations' => [
3914
                                'cro-HR' => 'dva-new',
3915
                            ],
3916
                        ],
3917
                    ],
3918
                    'alwaysAvailable' => false,
3919
                    'isHistory' => false,
3920
                    'isCustom' => false,
3921
                    'forward' => false,
3922
                ]
3923
            ),
3924
            $urlAlias
3925
        );
3926
    }
3927
3928
    /**
3929
     * Test for the locationSwapped() method.