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
     * @return array
@@ 2531-2561 (lines=31) @@
2528
     *
2529
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::locationMoved
2530
     */
2531
    public function testLocationMovedHistorize()
2532
    {
2533
        $handler = $this->getHandler();
2534
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_move.php');
2535
2536
        $handler->publishUrlAliasForLocation(4, 3, 'move-this', 'eng-GB', false);
2537
        $handler->locationMoved(4, 2, 3);
2538
2539
        $urlAlias = $handler->lookup('move-this');
2540
        self::assertEquals(
2541
            new UrlAlias(
2542
                array(
2543
                    'id' => '0-' . md5('move-this'),
2544
                    'type' => UrlAlias::LOCATION,
2545
                    'destination' => '4',
2546
                    'languageCodes' => array('eng-GB'),
2547
                    'pathData' => array(
2548
                        array(
2549
                            'always-available' => false,
2550
                            'translations' => array('eng-GB' => 'move-this'),
2551
                        ),
2552
                    ),
2553
                    'alwaysAvailable' => false,
2554
                    'isHistory' => true,
2555
                    'isCustom' => false,
2556
                    'forward' => false,
2557
                )
2558
            ),
2559
            $urlAlias
2560
        );
2561
    }
2562
2563
    /**
2564
     * Test for the locationMoved() method.
@@ 2568-2598 (lines=31) @@
2565
     *
2566
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::locationMoved
2567
     */
2568
    public function testLocationMovedHistory()
2569
    {
2570
        $handler = $this->getHandler();
2571
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_move.php');
2572
2573
        $handler->publishUrlAliasForLocation(4, 3, 'move-this', 'eng-GB', false);
2574
        $handler->locationMoved(4, 2, 3);
2575
2576
        $urlAlias = $handler->lookup('move-this-history');
2577
        self::assertEquals(
2578
            new UrlAlias(
2579
                array(
2580
                    'id' => '0-' . md5('move-this-history'),
2581
                    'type' => UrlAlias::LOCATION,
2582
                    'destination' => '4',
2583
                    'languageCodes' => array('eng-GB'),
2584
                    'pathData' => array(
2585
                        array(
2586
                            'always-available' => false,
2587
                            'translations' => array('eng-GB' => 'move-this-history'),
2588
                        ),
2589
                    ),
2590
                    'alwaysAvailable' => false,
2591
                    'isHistory' => true,
2592
                    'isCustom' => false,
2593
                    'forward' => false,
2594
                )
2595
            ),
2596
            $urlAlias
2597
        );
2598
    }
2599
2600
    /**
2601
     * Test for the locationMoved() method.