public function testGetSlice()
{
$offset = 20;
$limit = 25;
$nbResults = 123;
$query = new Query();
$query->query = $this->getMock('eZ\\Publish\\API\\Repository\\Values\\Content\\Query\\CriterionInterface');
$query->sortClauses = $this->getMockBuilder('eZ\\Publish\\API\\Repository\\Values\\Content\\Query\\SortClause')->disableOriginalConstructor()->getMockForAbstractClass();
// Injected query is being cloned to modify offset/limit,
// so we need to do the same here for our assertions.
$searchQuery = clone $query;
$searchQuery->offset = $offset;
$searchQuery->limit = $limit;
$searchQuery->performCount = false;
$hits = array();
for ($i = 0; $i < $limit; ++$i) {
$content = $this->getMockForAbstractClass('eZ\\Publish\\API\\Repository\\Values\\Content\\Content');
$hits[] = new SearchHit(array('valueObject' => $content));
}
$finalResult = $this->getExpectedFinalResultFromHits($hits);
$searchResult = new SearchResult(array('searchHits' => $hits, 'totalCount' => $nbResults));
$this->searchService->expects($this->once())->method('findContent')->with($this->equalTo($searchQuery))->will($this->returnValue($searchResult));
$adapter = $this->getAdapter($query, $this->searchService);
$this->assertSame($finalResult, $adapter->getSlice($offset, $limit));
$this->assertSame($nbResults, $adapter->getNbResults());
}