Code Duplication    Length = 68-68 lines in 4 locations

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

@@ 3478-3545 (lines=68) @@
3475
     *
3476
     * @group swap
3477
     */
3478
    public function testLocationSwappedSiblingsSimple()
3479
    {
3480
        $handler = $this->getHandler();
3481
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_swap_siblings_simple.php');
3482
3483
        $countBeforeReusing = $this->countRows();
3484
3485
        $handler->locationSwapped(314, 2, 315, 2);
3486
3487
        $this->assertEquals(
3488
            $countBeforeReusing,
3489
            $this->countRows()
3490
        );
3491
3492
        $urlAlias = $handler->lookup('jedan');
3493
        $this->assertEquals(
3494
            new UrlAlias(
3495
                [
3496
                    'id' => '0-' . md5('jedan'),
3497
                    'type' => UrlAlias::LOCATION,
3498
                    'destination' => 315,
3499
                    'languageCodes' => [
3500
                        'cro-HR',
3501
                    ],
3502
                    'pathData' => [
3503
                        [
3504
                            'always-available' => false,
3505
                            'translations' => [
3506
                                'cro-HR' => 'jedan',
3507
                            ],
3508
                        ],
3509
                    ],
3510
                    'alwaysAvailable' => false,
3511
                    'isHistory' => false,
3512
                    'isCustom' => false,
3513
                    'forward' => false,
3514
                ]
3515
            ),
3516
            $urlAlias
3517
        );
3518
3519
        $urlAlias = $handler->lookup('dva');
3520
        $this->assertEquals(
3521
            new UrlAlias(
3522
                [
3523
                    'id' => '0-' . md5('dva'),
3524
                    'type' => UrlAlias::LOCATION,
3525
                    'destination' => 314,
3526
                    'languageCodes' => [
3527
                        'cro-HR',
3528
                    ],
3529
                    'pathData' => [
3530
                        [
3531
                            'always-available' => false,
3532
                            'translations' => [
3533
                                'cro-HR' => 'dva',
3534
                            ],
3535
                        ],
3536
                    ],
3537
                    'alwaysAvailable' => false,
3538
                    'isHistory' => false,
3539
                    'isCustom' => false,
3540
                    'forward' => false,
3541
                ]
3542
            ),
3543
            $urlAlias
3544
        );
3545
    }
3546
3547
    /**
3548
     * Test for the locationSwapped() method.
@@ 3552-3619 (lines=68) @@
3549
     *
3550
     * @group swap
3551
     */
3552
    public function testLocationSwappedSiblingsSimpleReverse()
3553
    {
3554
        $handler = $this->getHandler();
3555
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_swap_siblings_simple.php');
3556
3557
        $countBeforeReusing = $this->countRows();
3558
3559
        $handler->locationSwapped(315, 2, 314, 2);
3560
3561
        $this->assertEquals(
3562
            $countBeforeReusing,
3563
            $this->countRows()
3564
        );
3565
3566
        $urlAlias = $handler->lookup('jedan');
3567
        $this->assertEquals(
3568
            new UrlAlias(
3569
                [
3570
                    'id' => '0-' . md5('jedan'),
3571
                    'type' => UrlAlias::LOCATION,
3572
                    'destination' => 315,
3573
                    'languageCodes' => [
3574
                        'cro-HR',
3575
                    ],
3576
                    'pathData' => [
3577
                        [
3578
                            'always-available' => false,
3579
                            'translations' => [
3580
                                'cro-HR' => 'jedan',
3581
                            ],
3582
                        ],
3583
                    ],
3584
                    'alwaysAvailable' => false,
3585
                    'isHistory' => false,
3586
                    'isCustom' => false,
3587
                    'forward' => false,
3588
                ]
3589
            ),
3590
            $urlAlias
3591
        );
3592
3593
        $urlAlias = $handler->lookup('dva');
3594
        $this->assertEquals(
3595
            new UrlAlias(
3596
                [
3597
                    'id' => '0-' . md5('dva'),
3598
                    'type' => UrlAlias::LOCATION,
3599
                    'destination' => 314,
3600
                    'languageCodes' => [
3601
                        'cro-HR',
3602
                    ],
3603
                    'pathData' => [
3604
                        [
3605
                            'always-available' => false,
3606
                            'translations' => [
3607
                                'cro-HR' => 'dva',
3608
                            ],
3609
                        ],
3610
                    ],
3611
                    'alwaysAvailable' => false,
3612
                    'isHistory' => false,
3613
                    'isCustom' => false,
3614
                    'forward' => false,
3615
                ]
3616
            ),
3617
            $urlAlias
3618
        );
3619
    }
3620
3621
    /**
3622
     * Test for the locationSwapped() method.
@@ 3882-3949 (lines=68) @@
3879
     *
3880
     * @group swap
3881
     */
3882
    public function testLocationSwappedSiblingsSameName()
3883
    {
3884
        $handler = $this->getHandler();
3885
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_swap_siblings_same_name.php');
3886
3887
        $countBeforeReusing = $this->countRows();
3888
3889
        $handler->locationSwapped(314, 2, 315, 2);
3890
3891
        $this->assertEquals(
3892
            $countBeforeReusing,
3893
            $this->countRows()
3894
        );
3895
3896
        $urlAlias = $handler->lookup('swap');
3897
        $this->assertEquals(
3898
            new UrlAlias(
3899
                [
3900
                    'id' => '0-' . md5('swap'),
3901
                    'type' => UrlAlias::LOCATION,
3902
                    'destination' => 314,
3903
                    'languageCodes' => [
3904
                        'cro-HR',
3905
                    ],
3906
                    'pathData' => [
3907
                        [
3908
                            'always-available' => false,
3909
                            'translations' => [
3910
                                'cro-HR' => 'swap',
3911
                            ],
3912
                        ],
3913
                    ],
3914
                    'alwaysAvailable' => false,
3915
                    'isHistory' => false,
3916
                    'isCustom' => false,
3917
                    'forward' => false,
3918
                ]
3919
            ),
3920
            $urlAlias
3921
        );
3922
3923
        $urlAlias = $handler->lookup('swap2');
3924
        $this->assertEquals(
3925
            new UrlAlias(
3926
                [
3927
                    'id' => '0-' . md5('swap2'),
3928
                    'type' => UrlAlias::LOCATION,
3929
                    'destination' => 315,
3930
                    'languageCodes' => [
3931
                        'cro-HR',
3932
                    ],
3933
                    'pathData' => [
3934
                        [
3935
                            'always-available' => false,
3936
                            'translations' => [
3937
                                'cro-HR' => 'swap2',
3938
                            ],
3939
                        ],
3940
                    ],
3941
                    'alwaysAvailable' => false,
3942
                    'isHistory' => false,
3943
                    'isCustom' => false,
3944
                    'forward' => false,
3945
                ]
3946
            ),
3947
            $urlAlias
3948
        );
3949
    }
3950
3951
    /**
3952
     * Test for the locationSwapped() method.
@@ 3956-4023 (lines=68) @@
3953
     *
3954
     * @group swap
3955
     */
3956
    public function testLocationSwappedSiblingsSameNameReverse()
3957
    {
3958
        $handler = $this->getHandler();
3959
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_swap_siblings_same_name.php');
3960
3961
        $countBeforeReusing = $this->countRows();
3962
3963
        $handler->locationSwapped(315, 2, 314, 2);
3964
3965
        $this->assertEquals(
3966
            $countBeforeReusing,
3967
            $this->countRows()
3968
        );
3969
3970
        $urlAlias = $handler->lookup('swap');
3971
        $this->assertEquals(
3972
            new UrlAlias(
3973
                [
3974
                    'id' => '0-' . md5('swap'),
3975
                    'type' => UrlAlias::LOCATION,
3976
                    'destination' => 314,
3977
                    'languageCodes' => [
3978
                        'cro-HR',
3979
                    ],
3980
                    'pathData' => [
3981
                        [
3982
                            'always-available' => false,
3983
                            'translations' => [
3984
                                'cro-HR' => 'swap',
3985
                            ],
3986
                        ],
3987
                    ],
3988
                    'alwaysAvailable' => false,
3989
                    'isHistory' => false,
3990
                    'isCustom' => false,
3991
                    'forward' => false,
3992
                ]
3993
            ),
3994
            $urlAlias
3995
        );
3996
3997
        $urlAlias = $handler->lookup('swap2');
3998
        $this->assertEquals(
3999
            new UrlAlias(
4000
                [
4001
                    'id' => '0-' . md5('swap2'),
4002
                    'type' => UrlAlias::LOCATION,
4003
                    'destination' => 315,
4004
                    'languageCodes' => [
4005
                        'cro-HR',
4006
                    ],
4007
                    'pathData' => [
4008
                        [
4009
                            'always-available' => false,
4010
                            'translations' => [
4011
                                'cro-HR' => 'swap2',
4012
                            ],
4013
                        ],
4014
                    ],
4015
                    'alwaysAvailable' => false,
4016
                    'isHistory' => false,
4017
                    'isCustom' => false,
4018
                    'forward' => false,
4019
                ]
4020
            ),
4021
            $urlAlias
4022
        );
4023
    }
4024
4025
    /**
4026
     * Test for the locationSwapped() method.