Code Duplication    Length = 31-34 lines in 4 locations

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

@@ 1050-1083 (lines=34) @@
1047
     * @depends testLookupLocationUrlAlias
1048
     * @group publish
1049
     */
1050
    public function testPublishUrlAliasForLocation()
1051
    {
1052
        $handler = $this->getHandler();
1053
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/publish_base.php');
1054
1055
        $handler->publishUrlAliasForLocation(314, 2, 'simple', 'eng-GB', true);
1056
        $publishedUrlAlias = $handler->lookup('simple');
1057
1058
        self::assertEquals(4, $this->countRows());
1059
        self::assertEquals(
1060
            new UrlAlias(
1061
                array(
1062
                    'id' => '0-' . md5('simple'),
1063
                    'type' => UrlAlias::LOCATION,
1064
                    'destination' => 314,
1065
                    'languageCodes' => array('eng-GB'),
1066
                    'pathData' => array(
1067
                        array(
1068
                            'always-available' => true,
1069
                            'translations' => array(
1070
                                'eng-GB' => 'simple',
1071
                                'cro-HR' => 'path314',
1072
                            ),
1073
                        ),
1074
                    ),
1075
                    'alwaysAvailable' => true,
1076
                    'isHistory' => false,
1077
                    'isCustom' => false,
1078
                    'forward' => false,
1079
                )
1080
            ),
1081
            $publishedUrlAlias
1082
        );
1083
    }
1084
1085
    /**
1086
     * Test for the publishUrlAliasForLocation() method.
@@ 1120-1153 (lines=34) @@
1117
     * @depends testPublishUrlAliasForLocation
1118
     * @group publish
1119
     */
1120
    public function testPublishUrlAliasCreatesUniqueAlias()
1121
    {
1122
        $handler = $this->getHandler();
1123
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/publish_base.php');
1124
1125
        $handler->publishUrlAliasForLocation(314, 2, 'simple', 'eng-GB', true);
1126
        $handler->publishUrlAliasForLocation(315, 2, 'simple', 'eng-GB', true);
1127
        self::assertEquals(5, $this->countRows());
1128
1129
        $urlAlias = $handler->lookup('simple2');
1130
        self::assertEquals(
1131
            new UrlAlias(
1132
                array(
1133
                    'id' => '0-' . md5('simple2'),
1134
                    'type' => UrlAlias::LOCATION,
1135
                    'destination' => 315,
1136
                    'languageCodes' => array('eng-GB'),
1137
                    'pathData' => array(
1138
                        array(
1139
                            'always-available' => true,
1140
                            'translations' => array(
1141
                                'eng-GB' => 'simple2',
1142
                            ),
1143
                        ),
1144
                    ),
1145
                    'alwaysAvailable' => true,
1146
                    'isHistory' => false,
1147
                    'isCustom' => false,
1148
                    'forward' => false,
1149
                )
1150
            ),
1151
            $urlAlias
1152
        );
1153
    }
1154
1155
    /**
1156
     * @return array
@@ 2513-2543 (lines=31) @@
2510
     *
2511
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::locationMoved
2512
     */
2513
    public function testLocationMovedHistorize()
2514
    {
2515
        $handler = $this->getHandler();
2516
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_move.php');
2517
2518
        $handler->publishUrlAliasForLocation(4, 3, 'move-this', 'eng-GB', false);
2519
        $handler->locationMoved(4, 2, 3);
2520
2521
        $urlAlias = $handler->lookup('move-this');
2522
        self::assertEquals(
2523
            new UrlAlias(
2524
                array(
2525
                    'id' => '0-' . md5('move-this'),
2526
                    'type' => UrlAlias::LOCATION,
2527
                    'destination' => '4',
2528
                    'languageCodes' => array('eng-GB'),
2529
                    'pathData' => array(
2530
                        array(
2531
                            'always-available' => false,
2532
                            'translations' => array('eng-GB' => 'move-this'),
2533
                        ),
2534
                    ),
2535
                    'alwaysAvailable' => false,
2536
                    'isHistory' => true,
2537
                    'isCustom' => false,
2538
                    'forward' => false,
2539
                )
2540
            ),
2541
            $urlAlias
2542
        );
2543
    }
2544
2545
    /**
2546
     * Test for the locationMoved() method.
@@ 2550-2580 (lines=31) @@
2547
     *
2548
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::locationMoved
2549
     */
2550
    public function testLocationMovedHistory()
2551
    {
2552
        $handler = $this->getHandler();
2553
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_move.php');
2554
2555
        $handler->publishUrlAliasForLocation(4, 3, 'move-this', 'eng-GB', false);
2556
        $handler->locationMoved(4, 2, 3);
2557
2558
        $urlAlias = $handler->lookup('move-this-history');
2559
        self::assertEquals(
2560
            new UrlAlias(
2561
                array(
2562
                    'id' => '0-' . md5('move-this-history'),
2563
                    'type' => UrlAlias::LOCATION,
2564
                    'destination' => '4',
2565
                    'languageCodes' => array('eng-GB'),
2566
                    'pathData' => array(
2567
                        array(
2568
                            'always-available' => false,
2569
                            'translations' => array('eng-GB' => 'move-this-history'),
2570
                        ),
2571
                    ),
2572
                    'alwaysAvailable' => false,
2573
                    'isHistory' => true,
2574
                    'isCustom' => false,
2575
                    'forward' => false,
2576
                )
2577
            ),
2578
            $urlAlias
2579
        );
2580
    }
2581
2582
    /**
2583
     * Test for the locationMoved() method.