Code Duplication    Length = 31-34 lines in 4 locations

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

@@ 1073-1106 (lines=34) @@
1070
     * @depends testLookupLocationUrlAlias
1071
     * @group publish
1072
     */
1073
    public function testPublishUrlAliasForLocation()
1074
    {
1075
        $handler = $this->getHandler();
1076
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/publish_base.php');
1077
1078
        $handler->publishUrlAliasForLocation(314, 2, 'simple', 'eng-GB', true);
1079
        $publishedUrlAlias = $handler->lookup('simple');
1080
1081
        self::assertEquals(4, $this->countRows());
1082
        self::assertEquals(
1083
            new UrlAlias(
1084
                [
1085
                    'id' => '0-' . md5('simple'),
1086
                    'type' => UrlAlias::LOCATION,
1087
                    'destination' => 314,
1088
                    'languageCodes' => ['eng-GB'],
1089
                    'pathData' => [
1090
                        [
1091
                            'always-available' => true,
1092
                            'translations' => [
1093
                                'eng-GB' => 'simple',
1094
                                'cro-HR' => 'path314',
1095
                            ],
1096
                        ],
1097
                    ],
1098
                    'alwaysAvailable' => true,
1099
                    'isHistory' => false,
1100
                    'isCustom' => false,
1101
                    'forward' => false,
1102
                ]
1103
            ),
1104
            $publishedUrlAlias
1105
        );
1106
    }
1107
1108
    /**
1109
     * Test for the publishUrlAliasForLocation() method.
@@ 1143-1176 (lines=34) @@
1140
     * @depends testPublishUrlAliasForLocation
1141
     * @group publish
1142
     */
1143
    public function testPublishUrlAliasCreatesUniqueAlias()
1144
    {
1145
        $handler = $this->getHandler();
1146
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/publish_base.php');
1147
1148
        $handler->publishUrlAliasForLocation(314, 2, 'simple', 'eng-GB', true);
1149
        $handler->publishUrlAliasForLocation(315, 2, 'simple', 'eng-GB', true);
1150
        self::assertEquals(5, $this->countRows());
1151
1152
        $urlAlias = $handler->lookup('simple2');
1153
        self::assertEquals(
1154
            new UrlAlias(
1155
                [
1156
                    'id' => '0-' . md5('simple2'),
1157
                    'type' => UrlAlias::LOCATION,
1158
                    'destination' => 315,
1159
                    'languageCodes' => ['eng-GB'],
1160
                    'pathData' => [
1161
                        [
1162
                            'always-available' => true,
1163
                            'translations' => [
1164
                                'eng-GB' => 'simple2',
1165
                            ],
1166
                        ],
1167
                    ],
1168
                    'alwaysAvailable' => true,
1169
                    'isHistory' => false,
1170
                    'isCustom' => false,
1171
                    'forward' => false,
1172
                ]
1173
            ),
1174
            $urlAlias
1175
        );
1176
    }
1177
1178
    /**
1179
     * @return array
@@ 2575-2605 (lines=31) @@
2572
     *
2573
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::locationMoved
2574
     */
2575
    public function testLocationMovedHistorize()
2576
    {
2577
        $handler = $this->getHandler();
2578
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_move.php');
2579
2580
        $handler->publishUrlAliasForLocation(4, 3, 'move-this', 'eng-GB', false);
2581
        $handler->locationMoved(4, 2, 3);
2582
2583
        $urlAlias = $handler->lookup('move-this');
2584
        self::assertEquals(
2585
            new UrlAlias(
2586
                [
2587
                    'id' => '0-' . md5('move-this'),
2588
                    'type' => UrlAlias::LOCATION,
2589
                    'destination' => '4',
2590
                    'languageCodes' => ['eng-GB'],
2591
                    'pathData' => [
2592
                        [
2593
                            'always-available' => false,
2594
                            'translations' => ['eng-GB' => 'move-this'],
2595
                        ],
2596
                    ],
2597
                    'alwaysAvailable' => false,
2598
                    'isHistory' => true,
2599
                    'isCustom' => false,
2600
                    'forward' => false,
2601
                ]
2602
            ),
2603
            $urlAlias
2604
        );
2605
    }
2606
2607
    /**
2608
     * Test for the locationMoved() method.
@@ 2612-2642 (lines=31) @@
2609
     *
2610
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::locationMoved
2611
     */
2612
    public function testLocationMovedHistory()
2613
    {
2614
        $handler = $this->getHandler();
2615
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_move.php');
2616
2617
        $handler->publishUrlAliasForLocation(4, 3, 'move-this', 'eng-GB', false);
2618
        $handler->locationMoved(4, 2, 3);
2619
2620
        $urlAlias = $handler->lookup('move-this-history');
2621
        self::assertEquals(
2622
            new UrlAlias(
2623
                [
2624
                    'id' => '0-' . md5('move-this-history'),
2625
                    'type' => UrlAlias::LOCATION,
2626
                    'destination' => '4',
2627
                    'languageCodes' => ['eng-GB'],
2628
                    'pathData' => [
2629
                        [
2630
                            'always-available' => false,
2631
                            'translations' => ['eng-GB' => 'move-this-history'],
2632
                        ],
2633
                    ],
2634
                    'alwaysAvailable' => false,
2635
                    'isHistory' => true,
2636
                    'isCustom' => false,
2637
                    'forward' => false,
2638
                ]
2639
            ),
2640
            $urlAlias
2641
        );
2642
    }
2643
2644
    /**
2645
     * Test for the locationMoved() method.