Code Duplication    Length = 122-122 lines in 2 locations

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

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