Code Duplication    Length = 95-95 lines in 2 locations

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

@@ 3425-3519 (lines=95) @@
3422
     *
3423
     * @group swap
3424
     */
3425
    public function testLocationSwappedSiblingsSimple()
3426
    {
3427
        $handler = $this->getHandler();
3428
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_swap_siblings_simple.php');
3429
3430
        $countBeforeReusing = $this->countRows();
3431
3432
        $handler->locationSwapped(314, 2, 315, 2);
3433
3434
        $this->assertEquals(
3435
            $countBeforeReusing + 1,
3436
            $this->countRows()
3437
        );
3438
3439
        $urlAlias = $handler->lookup('jedan');
3440
        $this->assertEquals(
3441
            new UrlAlias(
3442
                array(
3443
                    'id' => '0-' . md5('jedan'),
3444
                    'type' => UrlAlias::LOCATION,
3445
                    'destination' => 315,
3446
                    'languageCodes' => array(
3447
                        'cro-HR',
3448
                    ),
3449
                    'pathData' => array(
3450
                        array(
3451
                            'always-available' => false,
3452
                            'translations' => array(
3453
                                'cro-HR' => 'jedan',
3454
                            ),
3455
                        ),
3456
                    ),
3457
                    'alwaysAvailable' => false,
3458
                    'isHistory' => false,
3459
                    'isCustom' => false,
3460
                    'forward' => false,
3461
                )
3462
            ),
3463
            $urlAlias
3464
        );
3465
3466
        $urlAlias = $handler->lookup('dva');
3467
        $this->assertEquals(
3468
            new UrlAlias(
3469
                array(
3470
                    'id' => '0-' . md5('dva'),
3471
                    'type' => UrlAlias::LOCATION,
3472
                    'destination' => 315,
3473
                    'languageCodes' => array(
3474
                        'cro-HR',
3475
                    ),
3476
                    'pathData' => array(
3477
                        array(
3478
                            'always-available' => false,
3479
                            'translations' => array(
3480
                                'cro-HR' => 'dva',
3481
                            ),
3482
                        ),
3483
                    ),
3484
                    'alwaysAvailable' => false,
3485
                    'isHistory' => true,
3486
                    'isCustom' => false,
3487
                    'forward' => false,
3488
                )
3489
            ),
3490
            $urlAlias
3491
        );
3492
3493
        $urlAlias = $handler->lookup('dva2');
3494
        $this->assertEquals(
3495
            new UrlAlias(
3496
                array(
3497
                    'id' => '0-' . md5('dva2'),
3498
                    'type' => UrlAlias::LOCATION,
3499
                    'destination' => 314,
3500
                    'languageCodes' => array(
3501
                        'cro-HR',
3502
                    ),
3503
                    'pathData' => array(
3504
                        array(
3505
                            'always-available' => false,
3506
                            'translations' => array(
3507
                                'cro-HR' => 'dva2',
3508
                            ),
3509
                        ),
3510
                    ),
3511
                    'alwaysAvailable' => false,
3512
                    'isHistory' => false,
3513
                    'isCustom' => false,
3514
                    'forward' => false,
3515
                )
3516
            ),
3517
            $urlAlias
3518
        );
3519
    }
3520
3521
    /**
3522
     * Test for the locationSwapped() method.
@@ 3526-3620 (lines=95) @@
3523
     *
3524
     * @group swap
3525
     */
3526
    public function testLocationSwappedSiblingsSimpleReverse()
3527
    {
3528
        $handler = $this->getHandler();
3529
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_swap_siblings_simple.php');
3530
3531
        $countBeforeReusing = $this->countRows();
3532
3533
        $handler->locationSwapped(315, 2, 314, 2);
3534
3535
        $this->assertEquals(
3536
            $countBeforeReusing + 1,
3537
            $this->countRows()
3538
        );
3539
3540
        $urlAlias = $handler->lookup('jedan');
3541
        $this->assertEquals(
3542
            new UrlAlias(
3543
                array(
3544
                    'id' => '0-' . md5('jedan'),
3545
                    'type' => UrlAlias::LOCATION,
3546
                    'destination' => 314,
3547
                    'languageCodes' => array(
3548
                        'cro-HR',
3549
                    ),
3550
                    'pathData' => array(
3551
                        array(
3552
                            'always-available' => false,
3553
                            'translations' => array(
3554
                                'cro-HR' => 'jedan',
3555
                            ),
3556
                        ),
3557
                    ),
3558
                    'alwaysAvailable' => false,
3559
                    'isHistory' => true,
3560
                    'isCustom' => false,
3561
                    'forward' => false,
3562
                )
3563
            ),
3564
            $urlAlias
3565
        );
3566
3567
        $urlAlias = $handler->lookup('dva');
3568
        $this->assertEquals(
3569
            new UrlAlias(
3570
                array(
3571
                    'id' => '0-' . md5('dva'),
3572
                    'type' => UrlAlias::LOCATION,
3573
                    'destination' => 314,
3574
                    'languageCodes' => array(
3575
                        'cro-HR',
3576
                    ),
3577
                    'pathData' => array(
3578
                        array(
3579
                            'always-available' => false,
3580
                            'translations' => array(
3581
                                'cro-HR' => 'dva',
3582
                            ),
3583
                        ),
3584
                    ),
3585
                    'alwaysAvailable' => false,
3586
                    'isHistory' => false,
3587
                    'isCustom' => false,
3588
                    'forward' => false,
3589
                )
3590
            ),
3591
            $urlAlias
3592
        );
3593
3594
        $urlAlias = $handler->lookup('jedan2');
3595
        $this->assertEquals(
3596
            new UrlAlias(
3597
                array(
3598
                    'id' => '0-' . md5('jedan2'),
3599
                    'type' => UrlAlias::LOCATION,
3600
                    'destination' => 315,
3601
                    'languageCodes' => array(
3602
                        'cro-HR',
3603
                    ),
3604
                    'pathData' => array(
3605
                        array(
3606
                            'always-available' => false,
3607
                            'translations' => array(
3608
                                'cro-HR' => 'jedan2',
3609
                            ),
3610
                        ),
3611
                    ),
3612
                    'alwaysAvailable' => false,
3613
                    'isHistory' => false,
3614
                    'isCustom' => false,
3615
                    'forward' => false,
3616
                )
3617
            ),
3618
            $urlAlias
3619
        );
3620
    }
3621
3622
    /**
3623
     * Test for the locationSwapped() method.