Code Duplication    Length = 38-39 lines in 2 locations

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

@@ 3540-3578 (lines=39) @@
3537
     *
3538
     * @see \eZ\Publish\API\Repository\SearchService::findLocations()
3539
     */
3540
    public function testFindMainLocation()
3541
    {
3542
        $plainSiteLocationId = 56;
3543
        $designLocationId = 58;
3544
        $partnersContentId = 59;
3545
        $repository = $this->getRepository();
3546
        $locationService = $repository->getLocationService();
3547
        $contentService = $repository->getContentService();
3548
3549
        // Add secondary Location for "Partners" user group, under "Design" page
3550
        $locationService->createLocation(
3551
            $contentService->loadContentInfo($partnersContentId),
3552
            $locationService->newLocationCreateStruct($designLocationId)
3553
        );
3554
3555
        $this->refreshSearch($repository);
3556
3557
        $query = new LocationQuery(
3558
            array(
3559
                'filter' => new Criterion\LogicalAnd(
3560
                    array(
3561
                        new Criterion\ParentLocationId($designLocationId),
3562
                        new Criterion\Location\IsMainLocation(
3563
                            Criterion\Location\IsMainLocation::MAIN
3564
                        ),
3565
                    )
3566
                ),
3567
                'offset' => 0,
3568
                'limit' => 10,
3569
                'sortClauses' => array(),
3570
            )
3571
        );
3572
3573
        $searchService = $repository->getSearchService();
3574
        $result = $searchService->findLocations($query);
3575
3576
        $this->assertEquals(1, $result->totalCount);
3577
        $this->assertEquals($plainSiteLocationId, $result->searchHits[0]->valueObject->id);
3578
    }
3579
3580
    /**
3581
     * Test for the findLocations() method.
@@ 3585-3622 (lines=38) @@
3582
     *
3583
     * @see \eZ\Publish\API\Repository\SearchService::findLocations()
3584
     */
3585
    public function testFindNonMainLocation()
3586
    {
3587
        $designLocationId = 58;
3588
        $partnersContentId = 59;
3589
        $repository = $this->getRepository();
3590
        $locationService = $repository->getLocationService();
3591
        $contentService = $repository->getContentService();
3592
3593
        // Add secondary Location for "Partners" user group, under "Design" page
3594
        $newLocation = $locationService->createLocation(
3595
            $contentService->loadContentInfo($partnersContentId),
3596
            $locationService->newLocationCreateStruct($designLocationId)
3597
        );
3598
3599
        $this->refreshSearch($repository);
3600
3601
        $query = new LocationQuery(
3602
            array(
3603
                'filter' => new Criterion\LogicalAnd(
3604
                    array(
3605
                        new Criterion\ParentLocationId($designLocationId),
3606
                        new Criterion\Location\IsMainLocation(
3607
                            Criterion\Location\IsMainLocation::NOT_MAIN
3608
                        ),
3609
                    )
3610
                ),
3611
                'offset' => 0,
3612
                'limit' => 10,
3613
                'sortClauses' => array(),
3614
            )
3615
        );
3616
3617
        $searchService = $repository->getSearchService();
3618
        $result = $searchService->findLocations($query);
3619
3620
        $this->assertEquals(1, $result->totalCount);
3621
        $this->assertEquals($newLocation->id, $result->searchHits[0]->valueObject->id);
3622
    }
3623
3624
    /**
3625
     * Test for the findLocations() method.