Code Duplication    Length = 38-39 lines in 2 locations

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

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