Code Duplication    Length = 37-37 lines in 2 locations

eZ/Publish/API/Repository/Tests/SearchServiceTest.php 2 locations

@@ 3520-3556 (lines=37) @@
3517
     *
3518
     * @see \eZ\Publish\API\Repository\SearchService::findLocations()
3519
     */
3520
    public function testSortMainLocationAscending()
3521
    {
3522
        $plainSiteLocationId = 56;
3523
        $designLocationId = 58;
3524
        $partnersContentId = 59;
3525
        $repository = $this->getRepository();
3526
        $locationService = $repository->getLocationService();
3527
        $contentService = $repository->getContentService();
3528
3529
        // Add secondary Location for "Partners" user group, under "Design" page
3530
        $newLocation = $locationService->createLocation(
3531
            $contentService->loadContentInfo($partnersContentId),
3532
            $locationService->newLocationCreateStruct($designLocationId)
3533
        );
3534
3535
        $this->refreshSearch($repository);
3536
3537
        $query = new LocationQuery(
3538
            [
3539
                'filter' => new Criterion\ParentLocationId($designLocationId),
3540
                'offset' => 0,
3541
                'limit' => 10,
3542
                'sortClauses' => [
3543
                    new SortClause\Location\IsMainLocation(
3544
                        LocationQuery::SORT_ASC
3545
                    ),
3546
                ],
3547
            ]
3548
        );
3549
3550
        $searchService = $repository->getSearchService();
3551
        $result = $searchService->findLocations($query);
3552
3553
        $this->assertEquals(2, $result->totalCount);
3554
        $this->assertEquals($newLocation->id, $result->searchHits[0]->valueObject->id);
3555
        $this->assertEquals($plainSiteLocationId, $result->searchHits[1]->valueObject->id);
3556
    }
3557
3558
    /**
3559
     * Test for the findLocations() method.
@@ 3563-3599 (lines=37) @@
3560
     *
3561
     * @see \eZ\Publish\API\Repository\SearchService::findLocations()
3562
     */
3563
    public function testSortMainLocationDescending()
3564
    {
3565
        $plainSiteLocationId = 56;
3566
        $designLocationId = 58;
3567
        $partnersContentId = 59;
3568
        $repository = $this->getRepository();
3569
        $locationService = $repository->getLocationService();
3570
        $contentService = $repository->getContentService();
3571
3572
        // Add secondary Location for "Partners" user group, under "Design" page
3573
        $newLocation = $locationService->createLocation(
3574
            $contentService->loadContentInfo($partnersContentId),
3575
            $locationService->newLocationCreateStruct($designLocationId)
3576
        );
3577
3578
        $this->refreshSearch($repository);
3579
3580
        $query = new LocationQuery(
3581
            [
3582
                'filter' => new Criterion\ParentLocationId($designLocationId),
3583
                'offset' => 0,
3584
                'limit' => 10,
3585
                'sortClauses' => [
3586
                    new SortClause\Location\IsMainLocation(
3587
                        LocationQuery::SORT_DESC
3588
                    ),
3589
                ],
3590
            ]
3591
        );
3592
3593
        $searchService = $repository->getSearchService();
3594
        $result = $searchService->findLocations($query);
3595
3596
        $this->assertEquals(2, $result->totalCount);
3597
        $this->assertEquals($plainSiteLocationId, $result->searchHits[0]->valueObject->id);
3598
        $this->assertEquals($newLocation->id, $result->searchHits[1]->valueObject->id);
3599
    }
3600
3601
    /**
3602
     * Test for the findLocations() method.