Code Duplication    Length = 38-39 lines in 2 locations

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

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