Code Duplication    Length = 31-34 lines in 4 locations

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

@@ 1070-1103 (lines=34) @@
1067
     * @depends testLookupLocationUrlAlias
1068
     * @group publish
1069
     */
1070
    public function testPublishUrlAliasForLocation()
1071
    {
1072
        $handler = $this->getHandler();
1073
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/publish_base.php');
1074
1075
        $handler->publishUrlAliasForLocation(314, 2, 'simple', 'eng-GB', true);
1076
        $publishedUrlAlias = $handler->lookup('simple');
1077
1078
        self::assertEquals(4, $this->countRows());
1079
        self::assertEquals(
1080
            new UrlAlias(
1081
                array(
1082
                    'id' => '0-' . md5('simple'),
1083
                    'type' => UrlAlias::LOCATION,
1084
                    'destination' => 314,
1085
                    'languageCodes' => array('eng-GB'),
1086
                    'pathData' => array(
1087
                        array(
1088
                            'always-available' => true,
1089
                            'translations' => array(
1090
                                'eng-GB' => 'simple',
1091
                                'cro-HR' => 'path314',
1092
                            ),
1093
                        ),
1094
                    ),
1095
                    'alwaysAvailable' => true,
1096
                    'isHistory' => false,
1097
                    'isCustom' => false,
1098
                    'forward' => false,
1099
                )
1100
            ),
1101
            $publishedUrlAlias
1102
        );
1103
    }
1104
1105
    /**
1106
     * Test for the publishUrlAliasForLocation() method.
@@ 1140-1173 (lines=34) @@
1137
     * @depends testPublishUrlAliasForLocation
1138
     * @group publish
1139
     */
1140
    public function testPublishUrlAliasCreatesUniqueAlias()
1141
    {
1142
        $handler = $this->getHandler();
1143
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/publish_base.php');
1144
1145
        $handler->publishUrlAliasForLocation(314, 2, 'simple', 'eng-GB', true);
1146
        $handler->publishUrlAliasForLocation(315, 2, 'simple', 'eng-GB', true);
1147
        self::assertEquals(5, $this->countRows());
1148
1149
        $urlAlias = $handler->lookup('simple2');
1150
        self::assertEquals(
1151
            new UrlAlias(
1152
                array(
1153
                    'id' => '0-' . md5('simple2'),
1154
                    'type' => UrlAlias::LOCATION,
1155
                    'destination' => 315,
1156
                    'languageCodes' => array('eng-GB'),
1157
                    'pathData' => array(
1158
                        array(
1159
                            'always-available' => true,
1160
                            'translations' => array(
1161
                                'eng-GB' => 'simple2',
1162
                            ),
1163
                        ),
1164
                    ),
1165
                    'alwaysAvailable' => true,
1166
                    'isHistory' => false,
1167
                    'isCustom' => false,
1168
                    'forward' => false,
1169
                )
1170
            ),
1171
            $urlAlias
1172
        );
1173
    }
1174
1175
    /**
1176
     * @return array
@@ 2533-2563 (lines=31) @@
2530
     *
2531
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::locationMoved
2532
     */
2533
    public function testLocationMovedHistorize()
2534
    {
2535
        $handler = $this->getHandler();
2536
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_move.php');
2537
2538
        $handler->publishUrlAliasForLocation(4, 3, 'move-this', 'eng-GB', false);
2539
        $handler->locationMoved(4, 2, 3);
2540
2541
        $urlAlias = $handler->lookup('move-this');
2542
        self::assertEquals(
2543
            new UrlAlias(
2544
                array(
2545
                    'id' => '0-' . md5('move-this'),
2546
                    'type' => UrlAlias::LOCATION,
2547
                    'destination' => '4',
2548
                    'languageCodes' => array('eng-GB'),
2549
                    'pathData' => array(
2550
                        array(
2551
                            'always-available' => false,
2552
                            'translations' => array('eng-GB' => 'move-this'),
2553
                        ),
2554
                    ),
2555
                    'alwaysAvailable' => false,
2556
                    'isHistory' => true,
2557
                    'isCustom' => false,
2558
                    'forward' => false,
2559
                )
2560
            ),
2561
            $urlAlias
2562
        );
2563
    }
2564
2565
    /**
2566
     * Test for the locationMoved() method.
@@ 2570-2600 (lines=31) @@
2567
     *
2568
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::locationMoved
2569
     */
2570
    public function testLocationMovedHistory()
2571
    {
2572
        $handler = $this->getHandler();
2573
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_move.php');
2574
2575
        $handler->publishUrlAliasForLocation(4, 3, 'move-this', 'eng-GB', false);
2576
        $handler->locationMoved(4, 2, 3);
2577
2578
        $urlAlias = $handler->lookup('move-this-history');
2579
        self::assertEquals(
2580
            new UrlAlias(
2581
                array(
2582
                    'id' => '0-' . md5('move-this-history'),
2583
                    'type' => UrlAlias::LOCATION,
2584
                    'destination' => '4',
2585
                    'languageCodes' => array('eng-GB'),
2586
                    'pathData' => array(
2587
                        array(
2588
                            'always-available' => false,
2589
                            'translations' => array('eng-GB' => 'move-this-history'),
2590
                        ),
2591
                    ),
2592
                    'alwaysAvailable' => false,
2593
                    'isHistory' => true,
2594
                    'isCustom' => false,
2595
                    'forward' => false,
2596
                )
2597
            ),
2598
            $urlAlias
2599
        );
2600
    }
2601
2602
    /**
2603
     * Test for the locationMoved() method.