/** * Query for a resource set pointed by the given segment descriptor and update the descriptor with the result. * * @param SegmentDescriptor $segment Describes the resource set to query * @return void * */ private function handleSegmentTargetsToResourceSet(SegmentDescriptor $segment) { if ($segment->isSingleResult()) { $entityInstance = $this->providers->getResourceFromResourceSet($segment->getTargetResourceSetWrapper(), $segment->getKeyDescriptor()); $segment->setResult($entityInstance); } else { $queryResult = $this->providers->getResourceSet($this->request->queryType, $segment->getTargetResourceSetWrapper(), $this->request->getFilterInfo(), $this->request->getInternalOrderByInfo(), $this->request->getTopCount(), $this->request->getSkipCount()); $segment->setResult($queryResult); } }
public function testProcessRequestForCollectionWithInlineCountProviderHandlesPaging() { $requestURI = new Url('http://host.com/data.svc/Collection/?$inlinecount=allpages'); Phockito::when($this->mockServiceHost->getAbsoluteRequestUri())->return($requestURI); //mock inline count as all pages Phockito::when($this->mockServiceHost->getQueryStringItem(ODataConstants::HTTPQUERY_STRING_INLINECOUNT))->return("allpages"); $this->fakeServiceConfig->setAcceptCountRequests(true); $this->fakeServiceConfig->setMaxDataServiceVersion(ProtocolVersion::V2()); $uriProcessor = UriProcessor::process($this->mockService); $fakeQueryResult = new QueryResult(); $fakeQueryResult->results = array(1, 2, 3); $fakeQueryResult->count = 10; Phockito::when($this->mockProvidersWrapper->getResourceSet(QueryType::ENTITIES_WITH_COUNT(), $this->mockCollectionResourceSetWrapper, null, null, null, null))->return($fakeQueryResult); //indicate that the Provider performs the paging (thus it will use the count in the QueryResult) Phockito::when($this->mockProvidersWrapper->handlesOrderedPaging())->return(true); $uriProcessor->execute(); $request = $uriProcessor->getRequest(); $actual = $request->getTargetResult(); $this->assertEquals(array(1, 2, 3), $actual); $this->assertEquals(10, $request->getCountValue()); }