Code Duplication    Length = 38-39 lines in 2 locations

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

@@ 3667-3705 (lines=39) @@
3664
     *
3665
     * @see \eZ\Publish\API\Repository\SearchService::findLocations()
3666
     */
3667
    public function testFindMainLocation()
3668
    {
3669
        $plainSiteLocationId = 56;
3670
        $designLocationId = 58;
3671
        $partnersContentId = 59;
3672
        $repository = $this->getRepository();
3673
        $locationService = $repository->getLocationService();
3674
        $contentService = $repository->getContentService();
3675
3676
        // Add secondary Location for "Partners" user group, under "Design" page
3677
        $locationService->createLocation(
3678
            $contentService->loadContentInfo($partnersContentId),
3679
            $locationService->newLocationCreateStruct($designLocationId)
3680
        );
3681
3682
        $this->refreshSearch($repository);
3683
3684
        $query = new LocationQuery(
3685
            array(
3686
                'filter' => new Criterion\LogicalAnd(
3687
                    array(
3688
                        new Criterion\ParentLocationId($designLocationId),
3689
                        new Criterion\Location\IsMainLocation(
3690
                            Criterion\Location\IsMainLocation::MAIN
3691
                        ),
3692
                    )
3693
                ),
3694
                'offset' => 0,
3695
                'limit' => 10,
3696
                'sortClauses' => array(),
3697
            )
3698
        );
3699
3700
        $searchService = $repository->getSearchService();
3701
        $result = $searchService->findLocations($query);
3702
3703
        $this->assertEquals(1, $result->totalCount);
3704
        $this->assertEquals($plainSiteLocationId, $result->searchHits[0]->valueObject->id);
3705
    }
3706
3707
    /**
3708
     * Test for the findLocations() method.
@@ 3712-3749 (lines=38) @@
3709
     *
3710
     * @see \eZ\Publish\API\Repository\SearchService::findLocations()
3711
     */
3712
    public function testFindNonMainLocation()
3713
    {
3714
        $designLocationId = 58;
3715
        $partnersContentId = 59;
3716
        $repository = $this->getRepository();
3717
        $locationService = $repository->getLocationService();
3718
        $contentService = $repository->getContentService();
3719
3720
        // Add secondary Location for "Partners" user group, under "Design" page
3721
        $newLocation = $locationService->createLocation(
3722
            $contentService->loadContentInfo($partnersContentId),
3723
            $locationService->newLocationCreateStruct($designLocationId)
3724
        );
3725
3726
        $this->refreshSearch($repository);
3727
3728
        $query = new LocationQuery(
3729
            array(
3730
                'filter' => new Criterion\LogicalAnd(
3731
                    array(
3732
                        new Criterion\ParentLocationId($designLocationId),
3733
                        new Criterion\Location\IsMainLocation(
3734
                            Criterion\Location\IsMainLocation::NOT_MAIN
3735
                        ),
3736
                    )
3737
                ),
3738
                'offset' => 0,
3739
                'limit' => 10,
3740
                'sortClauses' => array(),
3741
            )
3742
        );
3743
3744
        $searchService = $repository->getSearchService();
3745
        $result = $searchService->findLocations($query);
3746
3747
        $this->assertEquals(1, $result->totalCount);
3748
        $this->assertEquals($newLocation->id, $result->searchHits[0]->valueObject->id);
3749
    }
3750
3751
    /**
3752
     * Test for the findLocations() method.