Code Duplication    Length = 37-37 lines in 2 locations

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

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