Code Duplication    Length = 122-122 lines in 2 locations

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

@@ 3367-3488 (lines=122) @@
3364
     *
3365
     * @group swap
3366
     */
3367
    public function testLocationSwappedSiblingsSimpleWithHistory()
3368
    {
3369
        $handler = $this->getHandler();
3370
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_swap_siblings_simple_history.php');
3371
3372
        $countBeforeReusing = $this->countRows();
3373
3374
        $handler->locationSwapped(314, 2, 315, 2);
3375
3376
        $this->assertEquals(
3377
            $countBeforeReusing,
3378
            $this->countRows()
3379
        );
3380
3381
        $urlAlias = $handler->lookup('jedan');
3382
        $this->assertEquals(
3383
            new UrlAlias(
3384
                array(
3385
                    'id' => '0-' . md5('jedan'),
3386
                    'type' => UrlAlias::LOCATION,
3387
                    'destination' => 314,
3388
                    'languageCodes' => array(
3389
                        'cro-HR',
3390
                    ),
3391
                    'pathData' => array(
3392
                        array(
3393
                            'always-available' => false,
3394
                            'translations' => array(
3395
                                'cro-HR' => 'jedan',
3396
                            ),
3397
                        ),
3398
                    ),
3399
                    'alwaysAvailable' => false,
3400
                    'isHistory' => true,
3401
                    'isCustom' => false,
3402
                    'forward' => false,
3403
                )
3404
            ),
3405
            $urlAlias
3406
        );
3407
3408
        $urlAlias = $handler->lookup('dva');
3409
        $this->assertEquals(
3410
            new UrlAlias(
3411
                array(
3412
                    'id' => '0-' . md5('dva'),
3413
                    'type' => UrlAlias::LOCATION,
3414
                    'destination' => 315,
3415
                    'languageCodes' => array(
3416
                        'cro-HR',
3417
                    ),
3418
                    'pathData' => array(
3419
                        array(
3420
                            'always-available' => false,
3421
                            'translations' => array(
3422
                                'cro-HR' => 'dva',
3423
                            ),
3424
                        ),
3425
                    ),
3426
                    'alwaysAvailable' => false,
3427
                    'isHistory' => true,
3428
                    'isCustom' => false,
3429
                    'forward' => false,
3430
                )
3431
            ),
3432
            $urlAlias
3433
        );
3434
3435
        $urlAlias = $handler->lookup('jedan-new');
3436
        $this->assertEquals(
3437
            new UrlAlias(
3438
                array(
3439
                    'id' => '0-' . md5('jedan-new'),
3440
                    'type' => UrlAlias::LOCATION,
3441
                    'destination' => 315,
3442
                    'languageCodes' => array(
3443
                        'cro-HR',
3444
                    ),
3445
                    'pathData' => array(
3446
                        array(
3447
                            'always-available' => false,
3448
                            'translations' => array(
3449
                                'cro-HR' => 'jedan-new',
3450
                            ),
3451
                        ),
3452
                    ),
3453
                    'alwaysAvailable' => false,
3454
                    'isHistory' => false,
3455
                    'isCustom' => false,
3456
                    'forward' => false,
3457
                )
3458
            ),
3459
            $urlAlias
3460
        );
3461
3462
        $urlAlias = $handler->lookup('dva-new');
3463
        $this->assertEquals(
3464
            new UrlAlias(
3465
                array(
3466
                    'id' => '0-' . md5('dva-new'),
3467
                    'type' => UrlAlias::LOCATION,
3468
                    'destination' => 314,
3469
                    'languageCodes' => array(
3470
                        'cro-HR',
3471
                    ),
3472
                    'pathData' => array(
3473
                        array(
3474
                            'always-available' => false,
3475
                            'translations' => array(
3476
                                'cro-HR' => 'dva-new',
3477
                            ),
3478
                        ),
3479
                    ),
3480
                    'alwaysAvailable' => false,
3481
                    'isHistory' => false,
3482
                    'isCustom' => false,
3483
                    'forward' => false,
3484
                )
3485
            ),
3486
            $urlAlias
3487
        );
3488
    }
3489
3490
    /**
3491
     * Test for the locationSwapped() method.
@@ 3495-3616 (lines=122) @@
3492
     *
3493
     * @group swap
3494
     */
3495
    public function testLocationSwappedSiblingsSimpleWithHistoryReverse()
3496
    {
3497
        $handler = $this->getHandler();
3498
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_swap_siblings_simple_history.php');
3499
3500
        $countBeforeReusing = $this->countRows();
3501
3502
        $handler->locationSwapped(315, 2, 314, 2);
3503
3504
        $this->assertEquals(
3505
            $countBeforeReusing,
3506
            $this->countRows()
3507
        );
3508
3509
        $urlAlias = $handler->lookup('jedan');
3510
        $this->assertEquals(
3511
            new UrlAlias(
3512
                array(
3513
                    'id' => '0-' . md5('jedan'),
3514
                    'type' => UrlAlias::LOCATION,
3515
                    'destination' => 314,
3516
                    'languageCodes' => array(
3517
                        'cro-HR',
3518
                    ),
3519
                    'pathData' => array(
3520
                        array(
3521
                            'always-available' => false,
3522
                            'translations' => array(
3523
                                'cro-HR' => 'jedan',
3524
                            ),
3525
                        ),
3526
                    ),
3527
                    'alwaysAvailable' => false,
3528
                    'isHistory' => true,
3529
                    'isCustom' => false,
3530
                    'forward' => false,
3531
                )
3532
            ),
3533
            $urlAlias
3534
        );
3535
3536
        $urlAlias = $handler->lookup('dva');
3537
        $this->assertEquals(
3538
            new UrlAlias(
3539
                array(
3540
                    'id' => '0-' . md5('dva'),
3541
                    'type' => UrlAlias::LOCATION,
3542
                    'destination' => 315,
3543
                    'languageCodes' => array(
3544
                        'cro-HR',
3545
                    ),
3546
                    'pathData' => array(
3547
                        array(
3548
                            'always-available' => false,
3549
                            'translations' => array(
3550
                                'cro-HR' => 'dva',
3551
                            ),
3552
                        ),
3553
                    ),
3554
                    'alwaysAvailable' => false,
3555
                    'isHistory' => true,
3556
                    'isCustom' => false,
3557
                    'forward' => false,
3558
                )
3559
            ),
3560
            $urlAlias
3561
        );
3562
3563
        $urlAlias = $handler->lookup('jedan-new');
3564
        $this->assertEquals(
3565
            new UrlAlias(
3566
                array(
3567
                    'id' => '0-' . md5('jedan-new'),
3568
                    'type' => UrlAlias::LOCATION,
3569
                    'destination' => 315,
3570
                    'languageCodes' => array(
3571
                        'cro-HR',
3572
                    ),
3573
                    'pathData' => array(
3574
                        array(
3575
                            'always-available' => false,
3576
                            'translations' => array(
3577
                                'cro-HR' => 'jedan-new',
3578
                            ),
3579
                        ),
3580
                    ),
3581
                    'alwaysAvailable' => false,
3582
                    'isHistory' => false,
3583
                    'isCustom' => false,
3584
                    'forward' => false,
3585
                )
3586
            ),
3587
            $urlAlias
3588
        );
3589
3590
        $urlAlias = $handler->lookup('dva-new');
3591
        $this->assertEquals(
3592
            new UrlAlias(
3593
                array(
3594
                    'id' => '0-' . md5('dva-new'),
3595
                    'type' => UrlAlias::LOCATION,
3596
                    'destination' => 314,
3597
                    'languageCodes' => array(
3598
                        'cro-HR',
3599
                    ),
3600
                    'pathData' => array(
3601
                        array(
3602
                            'always-available' => false,
3603
                            'translations' => array(
3604
                                'cro-HR' => 'dva-new',
3605
                            ),
3606
                        ),
3607
                    ),
3608
                    'alwaysAvailable' => false,
3609
                    'isHistory' => false,
3610
                    'isCustom' => false,
3611
                    'forward' => false,
3612
                )
3613
            ),
3614
            $urlAlias
3615
        );
3616
    }
3617
3618
    /**
3619
     * Test for the locationSwapped() method.