Code Duplication    Length = 31-34 lines in 4 locations

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

@@ 1069-1102 (lines=34) @@
1066
     * @depends testLookupLocationUrlAlias
1067
     * @group publish
1068
     */
1069
    public function testPublishUrlAliasForLocation()
1070
    {
1071
        $handler = $this->getHandler();
1072
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/publish_base.php');
1073
1074
        $handler->publishUrlAliasForLocation(314, 2, 'simple', 'eng-GB', true);
1075
        $publishedUrlAlias = $handler->lookup('simple');
1076
1077
        self::assertEquals(4, $this->countRows());
1078
        self::assertEquals(
1079
            new UrlAlias(
1080
                [
1081
                    'id' => '0-' . md5('simple'),
1082
                    'type' => UrlAlias::LOCATION,
1083
                    'destination' => 314,
1084
                    'languageCodes' => ['eng-GB'],
1085
                    'pathData' => [
1086
                        [
1087
                            'always-available' => true,
1088
                            'translations' => [
1089
                                'eng-GB' => 'simple',
1090
                                'cro-HR' => 'path314',
1091
                            ],
1092
                        ],
1093
                    ],
1094
                    'alwaysAvailable' => true,
1095
                    'isHistory' => false,
1096
                    'isCustom' => false,
1097
                    'forward' => false,
1098
                ]
1099
            ),
1100
            $publishedUrlAlias
1101
        );
1102
    }
1103
1104
    /**
1105
     * Test for the publishUrlAliasForLocation() method.
@@ 1139-1172 (lines=34) @@
1136
     * @depends testPublishUrlAliasForLocation
1137
     * @group publish
1138
     */
1139
    public function testPublishUrlAliasCreatesUniqueAlias()
1140
    {
1141
        $handler = $this->getHandler();
1142
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/publish_base.php');
1143
1144
        $handler->publishUrlAliasForLocation(314, 2, 'simple', 'eng-GB', true);
1145
        $handler->publishUrlAliasForLocation(315, 2, 'simple', 'eng-GB', true);
1146
        self::assertEquals(5, $this->countRows());
1147
1148
        $urlAlias = $handler->lookup('simple2');
1149
        self::assertEquals(
1150
            new UrlAlias(
1151
                [
1152
                    'id' => '0-' . md5('simple2'),
1153
                    'type' => UrlAlias::LOCATION,
1154
                    'destination' => 315,
1155
                    'languageCodes' => ['eng-GB'],
1156
                    'pathData' => [
1157
                        [
1158
                            'always-available' => true,
1159
                            'translations' => [
1160
                                'eng-GB' => 'simple2',
1161
                            ],
1162
                        ],
1163
                    ],
1164
                    'alwaysAvailable' => true,
1165
                    'isHistory' => false,
1166
                    'isCustom' => false,
1167
                    'forward' => false,
1168
                ]
1169
            ),
1170
            $urlAlias
1171
        );
1172
    }
1173
1174
    /**
1175
     * @return array
@@ 2599-2629 (lines=31) @@
2596
     *
2597
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::locationMoved
2598
     */
2599
    public function testLocationMovedHistorize()
2600
    {
2601
        $handler = $this->getHandler();
2602
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_move.php');
2603
2604
        $handler->publishUrlAliasForLocation(4, 3, 'move-this', 'eng-GB', false);
2605
        $handler->locationMoved(4, 2, 3);
2606
2607
        $urlAlias = $handler->lookup('move-this');
2608
        self::assertEquals(
2609
            new UrlAlias(
2610
                [
2611
                    'id' => '0-' . md5('move-this'),
2612
                    'type' => UrlAlias::LOCATION,
2613
                    'destination' => '4',
2614
                    'languageCodes' => ['eng-GB'],
2615
                    'pathData' => [
2616
                        [
2617
                            'always-available' => false,
2618
                            'translations' => ['eng-GB' => 'move-this'],
2619
                        ],
2620
                    ],
2621
                    'alwaysAvailable' => false,
2622
                    'isHistory' => true,
2623
                    'isCustom' => false,
2624
                    'forward' => false,
2625
                ]
2626
            ),
2627
            $urlAlias
2628
        );
2629
    }
2630
2631
    /**
2632
     * Test for the locationMoved() method.
@@ 2636-2666 (lines=31) @@
2633
     *
2634
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::locationMoved
2635
     */
2636
    public function testLocationMovedHistory()
2637
    {
2638
        $handler = $this->getHandler();
2639
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_move.php');
2640
2641
        $handler->publishUrlAliasForLocation(4, 3, 'move-this', 'eng-GB', false);
2642
        $handler->locationMoved(4, 2, 3);
2643
2644
        $urlAlias = $handler->lookup('move-this-history');
2645
        self::assertEquals(
2646
            new UrlAlias(
2647
                [
2648
                    'id' => '0-' . md5('move-this-history'),
2649
                    'type' => UrlAlias::LOCATION,
2650
                    'destination' => '4',
2651
                    'languageCodes' => ['eng-GB'],
2652
                    'pathData' => [
2653
                        [
2654
                            'always-available' => false,
2655
                            'translations' => ['eng-GB' => 'move-this-history'],
2656
                        ],
2657
                    ],
2658
                    'alwaysAvailable' => false,
2659
                    'isHistory' => true,
2660
                    'isCustom' => false,
2661
                    'forward' => false,
2662
                ]
2663
            ),
2664
            $urlAlias
2665
        );
2666
    }
2667
2668
    /**
2669
     * Test for the locationMoved() method.