Code Duplication    Length = 38-39 lines in 2 locations

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

@@ 3567-3605 (lines=39) @@
3564
     *
3565
     * @see \eZ\Publish\API\Repository\SearchService::findLocations()
3566
     */
3567
    public function testFindMainLocation()
3568
    {
3569
        $plainSiteLocationId = 56;
3570
        $designLocationId = 58;
3571
        $partnersContentId = 59;
3572
        $repository = $this->getRepository();
3573
        $locationService = $repository->getLocationService();
3574
        $contentService = $repository->getContentService();
3575
3576
        // Add secondary Location for "Partners" user group, under "Design" page
3577
        $locationService->createLocation(
3578
            $contentService->loadContentInfo($partnersContentId),
3579
            $locationService->newLocationCreateStruct($designLocationId)
3580
        );
3581
3582
        $this->refreshSearch($repository);
3583
3584
        $query = new LocationQuery(
3585
            [
3586
                'filter' => new Criterion\LogicalAnd(
3587
                    [
3588
                        new Criterion\ParentLocationId($designLocationId),
3589
                        new Criterion\Location\IsMainLocation(
3590
                            Criterion\Location\IsMainLocation::MAIN
3591
                        ),
3592
                    ]
3593
                ),
3594
                'offset' => 0,
3595
                'limit' => 10,
3596
                'sortClauses' => [],
3597
            ]
3598
        );
3599
3600
        $searchService = $repository->getSearchService();
3601
        $result = $searchService->findLocations($query);
3602
3603
        $this->assertEquals(1, $result->totalCount);
3604
        $this->assertEquals($plainSiteLocationId, $result->searchHits[0]->valueObject->id);
3605
    }
3606
3607
    /**
3608
     * Test for the findLocations() method.
@@ 3612-3649 (lines=38) @@
3609
     *
3610
     * @see \eZ\Publish\API\Repository\SearchService::findLocations()
3611
     */
3612
    public function testFindNonMainLocation()
3613
    {
3614
        $designLocationId = 58;
3615
        $partnersContentId = 59;
3616
        $repository = $this->getRepository();
3617
        $locationService = $repository->getLocationService();
3618
        $contentService = $repository->getContentService();
3619
3620
        // Add secondary Location for "Partners" user group, under "Design" page
3621
        $newLocation = $locationService->createLocation(
3622
            $contentService->loadContentInfo($partnersContentId),
3623
            $locationService->newLocationCreateStruct($designLocationId)
3624
        );
3625
3626
        $this->refreshSearch($repository);
3627
3628
        $query = new LocationQuery(
3629
            [
3630
                'filter' => new Criterion\LogicalAnd(
3631
                    [
3632
                        new Criterion\ParentLocationId($designLocationId),
3633
                        new Criterion\Location\IsMainLocation(
3634
                            Criterion\Location\IsMainLocation::NOT_MAIN
3635
                        ),
3636
                    ]
3637
                ),
3638
                'offset' => 0,
3639
                'limit' => 10,
3640
                'sortClauses' => [],
3641
            ]
3642
        );
3643
3644
        $searchService = $repository->getSearchService();
3645
        $result = $searchService->findLocations($query);
3646
3647
        $this->assertEquals(1, $result->totalCount);
3648
        $this->assertEquals($newLocation->id, $result->searchHits[0]->valueObject->id);
3649
    }
3650
3651
    /**
3652
     * Test for the findLocations() method.