Code Duplication    Length = 122-122 lines in 2 locations

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

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