public function testSortSectionName()
{
$locator = $this->getContentSearchHandler();
$result = $locator->findContent(new Query(array('filter' => new Criterion\SectionId(array(4, 2, 6, 3)), 'offset' => 0, 'limit' => null, 'sortClauses' => array(new SortClause\SectionName()))));
// First, results of section "Media" should appear, then the ones of "Protected",
// "Setup" and "Users"
// From inside a specific section, no particular order should be defined
// the logic is then to have a set of sorted id's to compare with
// the comparison being done slice by slice.
$idMapSet = array('media' => array(41, 49, 50, 51, 57, 58, 59, 60, 61, 62, 63, 64, 66, 200, 201), 'protected' => array(154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164), 'setup' => array(45, 52), 'users' => array(4, 10, 11, 12, 13, 14, 42, 226));
$contentIds = array_map(function ($hit) {
return $hit->valueObject->id;
}, $result->searchHits);
$expectedCount = 0;
foreach ($idMapSet as $set) {
$expectedCount += count($set);
}
$this->assertEquals($expectedCount, $result->totalCount);
$index = 0;
foreach ($idMapSet as $idSet) {
$contentIdsSubset = array_slice($contentIds, $index, $count = count($idSet));
$index += $count;
sort($contentIdsSubset);
$this->assertEquals($idSet, $contentIdsSubset);
}
}