Code Duplication    Length = 38-39 lines in 2 locations

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

@@ 3603-3641 (lines=39) @@
3600
     *
3601
     * @see \eZ\Publish\API\Repository\SearchService::findLocations()
3602
     */
3603
    public function testFindMainLocation()
3604
    {
3605
        $plainSiteLocationId = 56;
3606
        $designLocationId = 58;
3607
        $partnersContentId = 59;
3608
        $repository = $this->getRepository();
3609
        $locationService = $repository->getLocationService();
3610
        $contentService = $repository->getContentService();
3611
3612
        // Add secondary Location for "Partners" user group, under "Design" page
3613
        $locationService->createLocation(
3614
            $contentService->loadContentInfo($partnersContentId),
3615
            $locationService->newLocationCreateStruct($designLocationId)
3616
        );
3617
3618
        $this->refreshSearch($repository);
3619
3620
        $query = new LocationQuery(
3621
            [
3622
                'filter' => new Criterion\LogicalAnd(
3623
                    [
3624
                        new Criterion\ParentLocationId($designLocationId),
3625
                        new Criterion\Location\IsMainLocation(
3626
                            Criterion\Location\IsMainLocation::MAIN
3627
                        ),
3628
                    ]
3629
                ),
3630
                'offset' => 0,
3631
                'limit' => 10,
3632
                'sortClauses' => [],
3633
            ]
3634
        );
3635
3636
        $searchService = $repository->getSearchService();
3637
        $result = $searchService->findLocations($query);
3638
3639
        $this->assertEquals(1, $result->totalCount);
3640
        $this->assertEquals($plainSiteLocationId, $result->searchHits[0]->valueObject->id);
3641
    }
3642
3643
    /**
3644
     * Test for the findLocations() method.
@@ 3648-3685 (lines=38) @@
3645
     *
3646
     * @see \eZ\Publish\API\Repository\SearchService::findLocations()
3647
     */
3648
    public function testFindNonMainLocation()
3649
    {
3650
        $designLocationId = 58;
3651
        $partnersContentId = 59;
3652
        $repository = $this->getRepository();
3653
        $locationService = $repository->getLocationService();
3654
        $contentService = $repository->getContentService();
3655
3656
        // Add secondary Location for "Partners" user group, under "Design" page
3657
        $newLocation = $locationService->createLocation(
3658
            $contentService->loadContentInfo($partnersContentId),
3659
            $locationService->newLocationCreateStruct($designLocationId)
3660
        );
3661
3662
        $this->refreshSearch($repository);
3663
3664
        $query = new LocationQuery(
3665
            [
3666
                'filter' => new Criterion\LogicalAnd(
3667
                    [
3668
                        new Criterion\ParentLocationId($designLocationId),
3669
                        new Criterion\Location\IsMainLocation(
3670
                            Criterion\Location\IsMainLocation::NOT_MAIN
3671
                        ),
3672
                    ]
3673
                ),
3674
                'offset' => 0,
3675
                'limit' => 10,
3676
                'sortClauses' => [],
3677
            ]
3678
        );
3679
3680
        $searchService = $repository->getSearchService();
3681
        $result = $searchService->findLocations($query);
3682
3683
        $this->assertEquals(1, $result->totalCount);
3684
        $this->assertEquals($newLocation->id, $result->searchHits[0]->valueObject->id);
3685
    }
3686
3687
    /**
3688
     * Test for the findLocations() method.