Code Duplication    Length = 38-39 lines in 2 locations

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

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