Code Duplication    Length = 37-37 lines in 2 locations

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

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