Code Duplication    Length = 122-122 lines in 2 locations

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

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