Code Duplication    Length = 37-37 lines in 2 locations

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

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