Code Duplication    Length = 37-37 lines in 2 locations

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

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