Code Duplication    Length = 145-149 lines in 2 locations

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

@@ 3627-3771 (lines=145) @@
3624
     *
3625
     * @group swap
3626
     */
3627
    public function testLocationSwappedSiblingsSimpleWithHistory()
3628
    {
3629
        $handler = $this->getHandler();
3630
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_swap_siblings_simple_history.php');
3631
3632
        $countBeforeReusing = $this->countRows();
3633
3634
        $handler->locationSwapped(314, 2, 315, 2);
3635
3636
        $this->assertEquals(
3637
            $countBeforeReusing + 1,
3638
            $this->countRows()
3639
        );
3640
3641
        $urlAlias = $handler->lookup('jedan');
3642
        $this->assertEquals(
3643
            new UrlAlias(
3644
                array(
3645
                    'id' => '0-' . md5('jedan'),
3646
                    'type' => UrlAlias::LOCATION,
3647
                    'destination' => 314,
3648
                    'languageCodes' => array(
3649
                        'cro-HR',
3650
                    ),
3651
                    'pathData' => array(
3652
                        array(
3653
                            'always-available' => false,
3654
                            'translations' => array(
3655
                                'cro-HR' => 'jedan',
3656
                            ),
3657
                        ),
3658
                    ),
3659
                    'alwaysAvailable' => false,
3660
                    'isHistory' => true,
3661
                    'isCustom' => false,
3662
                    'forward' => false,
3663
                )
3664
            ),
3665
            $urlAlias
3666
        );
3667
3668
        $urlAlias = $handler->lookup('dva');
3669
        $this->assertEquals(
3670
            new UrlAlias(
3671
                array(
3672
                    'id' => '0-' . md5('dva'),
3673
                    'type' => UrlAlias::LOCATION,
3674
                    'destination' => 315,
3675
                    'languageCodes' => array(
3676
                        'cro-HR',
3677
                    ),
3678
                    'pathData' => array(
3679
                        array(
3680
                            'always-available' => false,
3681
                            'translations' => array(
3682
                                'cro-HR' => 'dva',
3683
                            ),
3684
                        ),
3685
                    ),
3686
                    'alwaysAvailable' => false,
3687
                    'isHistory' => true,
3688
                    'isCustom' => false,
3689
                    'forward' => false,
3690
                )
3691
            ),
3692
            $urlAlias
3693
        );
3694
3695
        $urlAlias = $handler->lookup('jedan-new');
3696
        $this->assertEquals(
3697
            new UrlAlias(
3698
                array(
3699
                    'id' => '0-' . md5('jedan-new'),
3700
                    'type' => UrlAlias::LOCATION,
3701
                    'destination' => 315,
3702
                    'languageCodes' => array(
3703
                        'cro-HR',
3704
                    ),
3705
                    'pathData' => array(
3706
                        array(
3707
                            'always-available' => false,
3708
                            'translations' => array(
3709
                                'cro-HR' => 'jedan-new',
3710
                            ),
3711
                        ),
3712
                    ),
3713
                    'alwaysAvailable' => false,
3714
                    'isHistory' => false,
3715
                    'isCustom' => false,
3716
                    'forward' => false,
3717
                )
3718
            ),
3719
            $urlAlias
3720
        );
3721
3722
        $urlAlias = $handler->lookup('dva-new');
3723
        $this->assertEquals(
3724
            new UrlAlias(
3725
                array(
3726
                    'id' => '0-' . md5('dva-new'),
3727
                    'type' => UrlAlias::LOCATION,
3728
                    'destination' => 315,
3729
                    'languageCodes' => array(
3730
                        'cro-HR',
3731
                    ),
3732
                    'pathData' => array(
3733
                        array(
3734
                            'always-available' => false,
3735
                            'translations' => array(
3736
                                'cro-HR' => 'dva-new',
3737
                            ),
3738
                        ),
3739
                    ),
3740
                    'alwaysAvailable' => false,
3741
                    'isHistory' => true,
3742
                    'isCustom' => false,
3743
                    'forward' => false,
3744
                )
3745
            ),
3746
            $urlAlias
3747
        );
3748
3749
        $urlAlias = $handler->lookup('dva-new2');
3750
        $this->assertEquals(
3751
            new UrlAlias(
3752
                array(
3753
                    'id' => '0-' . md5('dva-new2'),
3754
                    'type' => UrlAlias::LOCATION,
3755
                    'destination' => 314,
3756
                    'languageCodes' => array('cro-HR'),
3757
                    'pathData' => array(
3758
                        array(
3759
                            'always-available' => false,
3760
                            'translations' => array('cro-HR' => 'dva-new2'),
3761
                        ),
3762
                    ),
3763
                    'alwaysAvailable' => false,
3764
                    'isHistory' => false,
3765
                    'isCustom' => false,
3766
                    'forward' => false,
3767
                )
3768
            ),
3769
            $urlAlias
3770
        );
3771
    }
3772
3773
    /**
3774
     * Test for the locationSwapped() method.
@@ 3778-3926 (lines=149) @@
3775
     *
3776
     * @group swap
3777
     */
3778
    public function testLocationSwappedSiblingsSimpleWithHistoryReverse()
3779
    {
3780
        $handler = $this->getHandler();
3781
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_swap_siblings_simple_history.php');
3782
3783
        $countBeforeReusing = $this->countRows();
3784
3785
        $handler->locationSwapped(315, 2, 314, 2);
3786
3787
        $this->assertEquals(
3788
            $countBeforeReusing + 1,
3789
            $this->countRows()
3790
        );
3791
3792
        $urlAlias = $handler->lookup('jedan');
3793
        $this->assertEquals(
3794
            new UrlAlias(
3795
                array(
3796
                    'id' => '0-' . md5('jedan'),
3797
                    'type' => UrlAlias::LOCATION,
3798
                    'destination' => 314,
3799
                    'languageCodes' => array(
3800
                        'cro-HR',
3801
                    ),
3802
                    'pathData' => array(
3803
                        array(
3804
                            'always-available' => false,
3805
                            'translations' => array(
3806
                                'cro-HR' => 'jedan',
3807
                            ),
3808
                        ),
3809
                    ),
3810
                    'alwaysAvailable' => false,
3811
                    'isHistory' => true,
3812
                    'isCustom' => false,
3813
                    'forward' => false,
3814
                )
3815
            ),
3816
            $urlAlias
3817
        );
3818
3819
        $urlAlias = $handler->lookup('dva');
3820
        $this->assertEquals(
3821
            new UrlAlias(
3822
                array(
3823
                    'id' => '0-' . md5('dva'),
3824
                    'type' => UrlAlias::LOCATION,
3825
                    'destination' => 315,
3826
                    'languageCodes' => array(
3827
                        'cro-HR',
3828
                    ),
3829
                    'pathData' => array(
3830
                        array(
3831
                            'always-available' => false,
3832
                            'translations' => array(
3833
                                'cro-HR' => 'dva',
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('jedan-new');
3847
        $this->assertEquals(
3848
            new UrlAlias(
3849
                array(
3850
                    'id' => '0-' . md5('jedan-new'),
3851
                    'type' => UrlAlias::LOCATION,
3852
                    'destination' => 314,
3853
                    'languageCodes' => array(
3854
                        'cro-HR',
3855
                    ),
3856
                    'pathData' => array(
3857
                        array(
3858
                            'always-available' => false,
3859
                            'translations' => array(
3860
                                'cro-HR' => 'jedan-new',
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('dva-new');
3874
        $this->assertEquals(
3875
            new UrlAlias(
3876
                array(
3877
                    'id' => '0-' . md5('dva-new'),
3878
                    'type' => UrlAlias::LOCATION,
3879
                    'destination' => 314,
3880
                    'languageCodes' => array(
3881
                        'cro-HR',
3882
                    ),
3883
                    'pathData' => array(
3884
                        array(
3885
                            'always-available' => false,
3886
                            'translations' => array(
3887
                                'cro-HR' => 'dva-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('jedan-new2');
3901
        $this->assertEquals(
3902
            new UrlAlias(
3903
                array(
3904
                    'id' => '0-' . md5('jedan-new2'),
3905
                    'type' => UrlAlias::LOCATION,
3906
                    'destination' => 315,
3907
                    'languageCodes' => array(
3908
                        'cro-HR',
3909
                    ),
3910
                    'pathData' => array(
3911
                        array(
3912
                            'always-available' => false,
3913
                            'translations' => array(
3914
                                'cro-HR' => 'jedan-new2',
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.