Code Duplication    Length = 38-39 lines in 2 locations

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

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