Code Duplication    Length = 38-39 lines in 2 locations

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

@@ 3430-3468 (lines=39) @@
3427
     *
3428
     * @see \eZ\Publish\API\Repository\SearchService::findLocations()
3429
     */
3430
    public function testFindMainLocation()
3431
    {
3432
        $plainSiteLocationId = 56;
3433
        $designLocationId = 58;
3434
        $partnersContentId = 59;
3435
        $repository = $this->getRepository();
3436
        $locationService = $repository->getLocationService();
3437
        $contentService = $repository->getContentService();
3438
3439
        // Add secondary Location for "Partners" user group, under "Design" page
3440
        $locationService->createLocation(
3441
            $contentService->loadContentInfo($partnersContentId),
3442
            $locationService->newLocationCreateStruct($designLocationId)
3443
        );
3444
3445
        $this->refreshSearch($repository);
3446
3447
        $query = new LocationQuery(
3448
            [
3449
                'filter' => new Criterion\LogicalAnd(
3450
                    [
3451
                        new Criterion\ParentLocationId($designLocationId),
3452
                        new Criterion\Location\IsMainLocation(
3453
                            Criterion\Location\IsMainLocation::MAIN
3454
                        ),
3455
                    ]
3456
                ),
3457
                'offset' => 0,
3458
                'limit' => 10,
3459
                'sortClauses' => [],
3460
            ]
3461
        );
3462
3463
        $searchService = $repository->getSearchService();
3464
        $result = $searchService->findLocations($query);
3465
3466
        $this->assertEquals(1, $result->totalCount);
3467
        $this->assertEquals($plainSiteLocationId, $result->searchHits[0]->valueObject->id);
3468
    }
3469
3470
    /**
3471
     * Test for the findLocations() method.
@@ 3475-3512 (lines=38) @@
3472
     *
3473
     * @see \eZ\Publish\API\Repository\SearchService::findLocations()
3474
     */
3475
    public function testFindNonMainLocation()
3476
    {
3477
        $designLocationId = 58;
3478
        $partnersContentId = 59;
3479
        $repository = $this->getRepository();
3480
        $locationService = $repository->getLocationService();
3481
        $contentService = $repository->getContentService();
3482
3483
        // Add secondary Location for "Partners" user group, under "Design" page
3484
        $newLocation = $locationService->createLocation(
3485
            $contentService->loadContentInfo($partnersContentId),
3486
            $locationService->newLocationCreateStruct($designLocationId)
3487
        );
3488
3489
        $this->refreshSearch($repository);
3490
3491
        $query = new LocationQuery(
3492
            [
3493
                'filter' => new Criterion\LogicalAnd(
3494
                    [
3495
                        new Criterion\ParentLocationId($designLocationId),
3496
                        new Criterion\Location\IsMainLocation(
3497
                            Criterion\Location\IsMainLocation::NOT_MAIN
3498
                        ),
3499
                    ]
3500
                ),
3501
                'offset' => 0,
3502
                'limit' => 10,
3503
                'sortClauses' => [],
3504
            ]
3505
        );
3506
3507
        $searchService = $repository->getSearchService();
3508
        $result = $searchService->findLocations($query);
3509
3510
        $this->assertEquals(1, $result->totalCount);
3511
        $this->assertEquals($newLocation->id, $result->searchHits[0]->valueObject->id);
3512
    }
3513
3514
    /**
3515
     * Test for the findLocations() method.