Code Duplication    Length = 37-37 lines in 2 locations

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

@@ 3685-3721 (lines=37) @@
3682
     *
3683
     * @see \eZ\Publish\API\Repository\SearchService::findLocations()
3684
     */
3685
    public function testSortMainLocationAscending()
3686
    {
3687
        $plainSiteLocationId = 56;
3688
        $designLocationId = 58;
3689
        $partnersContentId = 59;
3690
        $repository = $this->getRepository();
3691
        $locationService = $repository->getLocationService();
3692
        $contentService = $repository->getContentService();
3693
3694
        // Add secondary Location for "Partners" user group, under "Design" page
3695
        $newLocation = $locationService->createLocation(
3696
            $contentService->loadContentInfo($partnersContentId),
3697
            $locationService->newLocationCreateStruct($designLocationId)
3698
        );
3699
3700
        $this->refreshSearch($repository);
3701
3702
        $query = new LocationQuery(
3703
            [
3704
                'filter' => new Criterion\ParentLocationId($designLocationId),
3705
                'offset' => 0,
3706
                'limit' => 10,
3707
                'sortClauses' => [
3708
                    new SortClause\Location\IsMainLocation(
3709
                        LocationQuery::SORT_ASC
3710
                    ),
3711
                ],
3712
            ]
3713
        );
3714
3715
        $searchService = $repository->getSearchService();
3716
        $result = $searchService->findLocations($query);
3717
3718
        $this->assertEquals(2, $result->totalCount);
3719
        $this->assertEquals($newLocation->id, $result->searchHits[0]->valueObject->id);
3720
        $this->assertEquals($plainSiteLocationId, $result->searchHits[1]->valueObject->id);
3721
    }
3722
3723
    /**
3724
     * Test for the findLocations() method.
@@ 3728-3764 (lines=37) @@
3725
     *
3726
     * @see \eZ\Publish\API\Repository\SearchService::findLocations()
3727
     */
3728
    public function testSortMainLocationDescending()
3729
    {
3730
        $plainSiteLocationId = 56;
3731
        $designLocationId = 58;
3732
        $partnersContentId = 59;
3733
        $repository = $this->getRepository();
3734
        $locationService = $repository->getLocationService();
3735
        $contentService = $repository->getContentService();
3736
3737
        // Add secondary Location for "Partners" user group, under "Design" page
3738
        $newLocation = $locationService->createLocation(
3739
            $contentService->loadContentInfo($partnersContentId),
3740
            $locationService->newLocationCreateStruct($designLocationId)
3741
        );
3742
3743
        $this->refreshSearch($repository);
3744
3745
        $query = new LocationQuery(
3746
            [
3747
                'filter' => new Criterion\ParentLocationId($designLocationId),
3748
                'offset' => 0,
3749
                'limit' => 10,
3750
                'sortClauses' => [
3751
                    new SortClause\Location\IsMainLocation(
3752
                        LocationQuery::SORT_DESC
3753
                    ),
3754
                ],
3755
            ]
3756
        );
3757
3758
        $searchService = $repository->getSearchService();
3759
        $result = $searchService->findLocations($query);
3760
3761
        $this->assertEquals(2, $result->totalCount);
3762
        $this->assertEquals($plainSiteLocationId, $result->searchHits[0]->valueObject->id);
3763
        $this->assertEquals($newLocation->id, $result->searchHits[1]->valueObject->id);
3764
    }
3765
3766
    /**
3767
     * Test for the findLocations() method.