Code Duplication    Length = 38-39 lines in 2 locations

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

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