Code Duplication    Length = 38-39 lines in 2 locations

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

@@ 3784-3822 (lines=39) @@
3781
     *
3782
     * @see \eZ\Publish\API\Repository\SearchService::findLocations()
3783
     */
3784
    public function testFindMainLocation()
3785
    {
3786
        $plainSiteLocationId = 56;
3787
        $designLocationId = 58;
3788
        $partnersContentId = 59;
3789
        $repository = $this->getRepository();
3790
        $locationService = $repository->getLocationService();
3791
        $contentService = $repository->getContentService();
3792
3793
        // Add secondary Location for "Partners" user group, under "Design" page
3794
        $locationService->createLocation(
3795
            $contentService->loadContentInfo($partnersContentId),
3796
            $locationService->newLocationCreateStruct($designLocationId)
3797
        );
3798
3799
        $this->refreshSearch($repository);
3800
3801
        $query = new LocationQuery(
3802
            array(
3803
                'filter' => new Criterion\LogicalAnd(
3804
                    array(
3805
                        new Criterion\ParentLocationId($designLocationId),
3806
                        new Criterion\Location\IsMainLocation(
3807
                            Criterion\Location\IsMainLocation::MAIN
3808
                        ),
3809
                    )
3810
                ),
3811
                'offset' => 0,
3812
                'limit' => 10,
3813
                'sortClauses' => array(),
3814
            )
3815
        );
3816
3817
        $searchService = $repository->getSearchService();
3818
        $result = $searchService->findLocations($query);
3819
3820
        $this->assertEquals(1, $result->totalCount);
3821
        $this->assertEquals($plainSiteLocationId, $result->searchHits[0]->valueObject->id);
3822
    }
3823
3824
    /**
3825
     * Test for the findLocations() method.
@@ 3829-3866 (lines=38) @@
3826
     *
3827
     * @see \eZ\Publish\API\Repository\SearchService::findLocations()
3828
     */
3829
    public function testFindNonMainLocation()
3830
    {
3831
        $designLocationId = 58;
3832
        $partnersContentId = 59;
3833
        $repository = $this->getRepository();
3834
        $locationService = $repository->getLocationService();
3835
        $contentService = $repository->getContentService();
3836
3837
        // Add secondary Location for "Partners" user group, under "Design" page
3838
        $newLocation = $locationService->createLocation(
3839
            $contentService->loadContentInfo($partnersContentId),
3840
            $locationService->newLocationCreateStruct($designLocationId)
3841
        );
3842
3843
        $this->refreshSearch($repository);
3844
3845
        $query = new LocationQuery(
3846
            array(
3847
                'filter' => new Criterion\LogicalAnd(
3848
                    array(
3849
                        new Criterion\ParentLocationId($designLocationId),
3850
                        new Criterion\Location\IsMainLocation(
3851
                            Criterion\Location\IsMainLocation::NOT_MAIN
3852
                        ),
3853
                    )
3854
                ),
3855
                'offset' => 0,
3856
                'limit' => 10,
3857
                'sortClauses' => array(),
3858
            )
3859
        );
3860
3861
        $searchService = $repository->getSearchService();
3862
        $result = $searchService->findLocations($query);
3863
3864
        $this->assertEquals(1, $result->totalCount);
3865
        $this->assertEquals($newLocation->id, $result->searchHits[0]->valueObject->id);
3866
    }
3867
3868
    /**
3869
     * Test for the findLocations() method.