Code Duplication    Length = 38-39 lines in 2 locations

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

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