eZ\Publish\Core\Search\Legacy\Tests\Content\HandlerContentSortTest::testSortSectionIdentifier PHP Method

testSortSectionIdentifier() public method

    public function testSortSectionIdentifier()
    {
        $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\SectionIdentifier()))));
        // First, results of section 2 should appear, then the ones of 3, 4 and 6
        // 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(2 => array(4, 10, 11, 12, 13, 14, 42, 226), 3 => array(41, 49, 50, 51, 57, 58, 59, 60, 61, 62, 63, 64, 66, 200, 201), 4 => array(45, 52), 6 => array(154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164));
        $contentIds = array_map(function ($hit) {
            return $hit->valueObject->id;
        }, $result->searchHits);
        $index = 0;
        foreach ($idMapSet as $idSet) {
            $contentIdsSubset = array_slice($contentIds, $index, $count = count($idSet));
            $index += $count;
            sort($contentIdsSubset);
            $this->assertEquals($idSet, $contentIdsSubset);
        }
    }