Code Duplication    Length = 31-34 lines in 4 locations

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

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