|
@@ 3629-3665 (lines=37) @@
|
| 3626 |
|
* |
| 3627 |
|
* @see \eZ\Publish\API\Repository\SearchService::findLocations() |
| 3628 |
|
*/ |
| 3629 |
|
public function testSortMainLocationAscending() |
| 3630 |
|
{ |
| 3631 |
|
$plainSiteLocationId = 56; |
| 3632 |
|
$designLocationId = 58; |
| 3633 |
|
$partnersContentId = 59; |
| 3634 |
|
$repository = $this->getRepository(); |
| 3635 |
|
$locationService = $repository->getLocationService(); |
| 3636 |
|
$contentService = $repository->getContentService(); |
| 3637 |
|
|
| 3638 |
|
// Add secondary Location for "Partners" user group, under "Design" page |
| 3639 |
|
$newLocation = $locationService->createLocation( |
| 3640 |
|
$contentService->loadContentInfo($partnersContentId), |
| 3641 |
|
$locationService->newLocationCreateStruct($designLocationId) |
| 3642 |
|
); |
| 3643 |
|
|
| 3644 |
|
$this->refreshSearch($repository); |
| 3645 |
|
|
| 3646 |
|
$query = new LocationQuery( |
| 3647 |
|
array( |
| 3648 |
|
'filter' => new Criterion\ParentLocationId($designLocationId), |
| 3649 |
|
'offset' => 0, |
| 3650 |
|
'limit' => 10, |
| 3651 |
|
'sortClauses' => array( |
| 3652 |
|
new SortClause\Location\IsMainLocation( |
| 3653 |
|
LocationQuery::SORT_ASC |
| 3654 |
|
), |
| 3655 |
|
), |
| 3656 |
|
) |
| 3657 |
|
); |
| 3658 |
|
|
| 3659 |
|
$searchService = $repository->getSearchService(); |
| 3660 |
|
$result = $searchService->findLocations($query); |
| 3661 |
|
|
| 3662 |
|
$this->assertEquals(2, $result->totalCount); |
| 3663 |
|
$this->assertEquals($newLocation->id, $result->searchHits[0]->valueObject->id); |
| 3664 |
|
$this->assertEquals($plainSiteLocationId, $result->searchHits[1]->valueObject->id); |
| 3665 |
|
} |
| 3666 |
|
|
| 3667 |
|
/** |
| 3668 |
|
* Test for the findLocations() method. |
|
@@ 3672-3708 (lines=37) @@
|
| 3669 |
|
* |
| 3670 |
|
* @see \eZ\Publish\API\Repository\SearchService::findLocations() |
| 3671 |
|
*/ |
| 3672 |
|
public function testSortMainLocationDescending() |
| 3673 |
|
{ |
| 3674 |
|
$plainSiteLocationId = 56; |
| 3675 |
|
$designLocationId = 58; |
| 3676 |
|
$partnersContentId = 59; |
| 3677 |
|
$repository = $this->getRepository(); |
| 3678 |
|
$locationService = $repository->getLocationService(); |
| 3679 |
|
$contentService = $repository->getContentService(); |
| 3680 |
|
|
| 3681 |
|
// Add secondary Location for "Partners" user group, under "Design" page |
| 3682 |
|
$newLocation = $locationService->createLocation( |
| 3683 |
|
$contentService->loadContentInfo($partnersContentId), |
| 3684 |
|
$locationService->newLocationCreateStruct($designLocationId) |
| 3685 |
|
); |
| 3686 |
|
|
| 3687 |
|
$this->refreshSearch($repository); |
| 3688 |
|
|
| 3689 |
|
$query = new LocationQuery( |
| 3690 |
|
array( |
| 3691 |
|
'filter' => new Criterion\ParentLocationId($designLocationId), |
| 3692 |
|
'offset' => 0, |
| 3693 |
|
'limit' => 10, |
| 3694 |
|
'sortClauses' => array( |
| 3695 |
|
new SortClause\Location\IsMainLocation( |
| 3696 |
|
LocationQuery::SORT_DESC |
| 3697 |
|
), |
| 3698 |
|
), |
| 3699 |
|
) |
| 3700 |
|
); |
| 3701 |
|
|
| 3702 |
|
$searchService = $repository->getSearchService(); |
| 3703 |
|
$result = $searchService->findLocations($query); |
| 3704 |
|
|
| 3705 |
|
$this->assertEquals(2, $result->totalCount); |
| 3706 |
|
$this->assertEquals($plainSiteLocationId, $result->searchHits[0]->valueObject->id); |
| 3707 |
|
$this->assertEquals($newLocation->id, $result->searchHits[1]->valueObject->id); |
| 3708 |
|
} |
| 3709 |
|
|
| 3710 |
|
/** |
| 3711 |
|
* Test for the findLocations() method. |