Code Duplication    Length = 122-122 lines in 2 locations

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

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