|
@@ 3521-3557 (lines=37) @@
|
| 3518 |
|
* |
| 3519 |
|
* @see \eZ\Publish\API\Repository\SearchService::findLocations() |
| 3520 |
|
*/ |
| 3521 |
|
public function testSortMainLocationAscending() |
| 3522 |
|
{ |
| 3523 |
|
$plainSiteLocationId = 56; |
| 3524 |
|
$designLocationId = 58; |
| 3525 |
|
$partnersContentId = 59; |
| 3526 |
|
$repository = $this->getRepository(); |
| 3527 |
|
$locationService = $repository->getLocationService(); |
| 3528 |
|
$contentService = $repository->getContentService(); |
| 3529 |
|
|
| 3530 |
|
// Add secondary Location for "Partners" user group, under "Design" page |
| 3531 |
|
$newLocation = $locationService->createLocation( |
| 3532 |
|
$contentService->loadContentInfo($partnersContentId), |
| 3533 |
|
$locationService->newLocationCreateStruct($designLocationId) |
| 3534 |
|
); |
| 3535 |
|
|
| 3536 |
|
$this->refreshSearch($repository); |
| 3537 |
|
|
| 3538 |
|
$query = new LocationQuery( |
| 3539 |
|
array( |
| 3540 |
|
'filter' => new Criterion\ParentLocationId($designLocationId), |
| 3541 |
|
'offset' => 0, |
| 3542 |
|
'limit' => 10, |
| 3543 |
|
'sortClauses' => array( |
| 3544 |
|
new SortClause\Location\IsMainLocation( |
| 3545 |
|
LocationQuery::SORT_ASC |
| 3546 |
|
), |
| 3547 |
|
), |
| 3548 |
|
) |
| 3549 |
|
); |
| 3550 |
|
|
| 3551 |
|
$searchService = $repository->getSearchService(); |
| 3552 |
|
$result = $searchService->findLocations($query); |
| 3553 |
|
|
| 3554 |
|
$this->assertEquals(2, $result->totalCount); |
| 3555 |
|
$this->assertEquals($newLocation->id, $result->searchHits[0]->valueObject->id); |
| 3556 |
|
$this->assertEquals($plainSiteLocationId, $result->searchHits[1]->valueObject->id); |
| 3557 |
|
} |
| 3558 |
|
|
| 3559 |
|
/** |
| 3560 |
|
* Test for the findLocations() method. |
|
@@ 3564-3600 (lines=37) @@
|
| 3561 |
|
* |
| 3562 |
|
* @see \eZ\Publish\API\Repository\SearchService::findLocations() |
| 3563 |
|
*/ |
| 3564 |
|
public function testSortMainLocationDescending() |
| 3565 |
|
{ |
| 3566 |
|
$plainSiteLocationId = 56; |
| 3567 |
|
$designLocationId = 58; |
| 3568 |
|
$partnersContentId = 59; |
| 3569 |
|
$repository = $this->getRepository(); |
| 3570 |
|
$locationService = $repository->getLocationService(); |
| 3571 |
|
$contentService = $repository->getContentService(); |
| 3572 |
|
|
| 3573 |
|
// Add secondary Location for "Partners" user group, under "Design" page |
| 3574 |
|
$newLocation = $locationService->createLocation( |
| 3575 |
|
$contentService->loadContentInfo($partnersContentId), |
| 3576 |
|
$locationService->newLocationCreateStruct($designLocationId) |
| 3577 |
|
); |
| 3578 |
|
|
| 3579 |
|
$this->refreshSearch($repository); |
| 3580 |
|
|
| 3581 |
|
$query = new LocationQuery( |
| 3582 |
|
array( |
| 3583 |
|
'filter' => new Criterion\ParentLocationId($designLocationId), |
| 3584 |
|
'offset' => 0, |
| 3585 |
|
'limit' => 10, |
| 3586 |
|
'sortClauses' => array( |
| 3587 |
|
new SortClause\Location\IsMainLocation( |
| 3588 |
|
LocationQuery::SORT_DESC |
| 3589 |
|
), |
| 3590 |
|
), |
| 3591 |
|
) |
| 3592 |
|
); |
| 3593 |
|
|
| 3594 |
|
$searchService = $repository->getSearchService(); |
| 3595 |
|
$result = $searchService->findLocations($query); |
| 3596 |
|
|
| 3597 |
|
$this->assertEquals(2, $result->totalCount); |
| 3598 |
|
$this->assertEquals($plainSiteLocationId, $result->searchHits[0]->valueObject->id); |
| 3599 |
|
$this->assertEquals($newLocation->id, $result->searchHits[1]->valueObject->id); |
| 3600 |
|
} |
| 3601 |
|
|
| 3602 |
|
/** |
| 3603 |
|
* Test for the findLocations() method. |