Code Duplication    Length = 37-37 lines in 2 locations

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

@@ 3754-3790 (lines=37) @@
3751
     *
3752
     * @see \eZ\Publish\API\Repository\SearchService::findLocations()
3753
     */
3754
    public function testSortMainLocationAscending()
3755
    {
3756
        $plainSiteLocationId = 56;
3757
        $designLocationId = 58;
3758
        $partnersContentId = 59;
3759
        $repository = $this->getRepository();
3760
        $locationService = $repository->getLocationService();
3761
        $contentService = $repository->getContentService();
3762
3763
        // Add secondary Location for "Partners" user group, under "Design" page
3764
        $newLocation = $locationService->createLocation(
3765
            $contentService->loadContentInfo($partnersContentId),
3766
            $locationService->newLocationCreateStruct($designLocationId)
3767
        );
3768
3769
        $this->refreshSearch($repository);
3770
3771
        $query = new LocationQuery(
3772
            array(
3773
                'filter' => new Criterion\ParentLocationId($designLocationId),
3774
                'offset' => 0,
3775
                'limit' => 10,
3776
                'sortClauses' => array(
3777
                    new SortClause\Location\IsMainLocation(
3778
                        LocationQuery::SORT_ASC
3779
                    ),
3780
                ),
3781
            )
3782
        );
3783
3784
        $searchService = $repository->getSearchService();
3785
        $result = $searchService->findLocations($query);
3786
3787
        $this->assertEquals(2, $result->totalCount);
3788
        $this->assertEquals($newLocation->id, $result->searchHits[0]->valueObject->id);
3789
        $this->assertEquals($plainSiteLocationId, $result->searchHits[1]->valueObject->id);
3790
    }
3791
3792
    /**
3793
     * Test for the findLocations() method.
@@ 3797-3833 (lines=37) @@
3794
     *
3795
     * @see \eZ\Publish\API\Repository\SearchService::findLocations()
3796
     */
3797
    public function testSortMainLocationDescending()
3798
    {
3799
        $plainSiteLocationId = 56;
3800
        $designLocationId = 58;
3801
        $partnersContentId = 59;
3802
        $repository = $this->getRepository();
3803
        $locationService = $repository->getLocationService();
3804
        $contentService = $repository->getContentService();
3805
3806
        // Add secondary Location for "Partners" user group, under "Design" page
3807
        $newLocation = $locationService->createLocation(
3808
            $contentService->loadContentInfo($partnersContentId),
3809
            $locationService->newLocationCreateStruct($designLocationId)
3810
        );
3811
3812
        $this->refreshSearch($repository);
3813
3814
        $query = new LocationQuery(
3815
            array(
3816
                'filter' => new Criterion\ParentLocationId($designLocationId),
3817
                'offset' => 0,
3818
                'limit' => 10,
3819
                'sortClauses' => array(
3820
                    new SortClause\Location\IsMainLocation(
3821
                        LocationQuery::SORT_DESC
3822
                    ),
3823
                ),
3824
            )
3825
        );
3826
3827
        $searchService = $repository->getSearchService();
3828
        $result = $searchService->findLocations($query);
3829
3830
        $this->assertEquals(2, $result->totalCount);
3831
        $this->assertEquals($plainSiteLocationId, $result->searchHits[0]->valueObject->id);
3832
        $this->assertEquals($newLocation->id, $result->searchHits[1]->valueObject->id);
3833
    }
3834
3835
    /**
3836
     * Test for the findLocations() method.