public function testGetRelatedResourceSetReturnsArrayWhenQueryTypeIsEntitiesWithCount() { $orderBy = null; $top = 10; $skip = 10; $fakeQueryResult = new QueryResult(); $fakeQueryResult->count = 4; $fakeQueryResult->results = null; //null is not an array $fakeSourceEntity = new \stdClass(); Phockito::when($this->mockQueryProvider->getRelatedResourceSet(QueryType::ENTITIES_WITH_COUNT(), $this->mockResourceSet, $fakeSourceEntity, $this->mockResourceSet2, $this->mockResourceProperty, $this->mockFilterInfo, $orderBy, $top, $skip))->return($fakeQueryResult); $wrapper = $this->getMockedWrapper(); try { $wrapper->getRelatedResourceSet(QueryType::ENTITIES_WITH_COUNT(), $this->mockResourceSet, $fakeSourceEntity, $this->mockResourceSet2, $this->mockResourceProperty, $this->mockFilterInfo, $orderBy, $top, $skip); $this->fail("expected exception not thrown"); } catch (ODataException $ex) { $this->assertEquals(Messages::queryProviderResultsMissing("IQueryProvider::getRelatedResourceSet", QueryType::ENTITIES_WITH_COUNT()), $ex->getMessage()); $this->assertEquals(500, $ex->getStatusCode()); } }
/** * Get related resource set for a resource * * @param QueryType $queryType indicates if this is a query for a count, entities, or entities with a count * @param ResourceSet $sourceResourceSet The entity set containing the source entity * @param object $sourceEntity The source entity instance. * @param ResourceSet $targetResourceSet The resource set of containing the target of the navigation property * @param ResourceProperty $targetProperty The navigation property to retrieve * @param FilterInfo $filterInfo represents the $filter parameter of the OData query. NULL if no $filter specified * @param mixed $orderBy sorted order if we want to get the data in some specific order * @param int $top number of records which need to be skip * @param String $skip value indicating what records to skip * * @return QueryResult * * @throws ODataException */ public function getRelatedResourceSet(QueryType $queryType, ResourceSet $sourceResourceSet, $sourceEntity, ResourceSet $targetResourceSet, ResourceProperty $targetProperty, $filterInfo, $orderBy, $top, $skip) { $queryResult = $this->queryProvider->getRelatedResourceSet($queryType, $sourceResourceSet, $sourceEntity, $targetResourceSet, $targetProperty, $filterInfo, $orderBy, $top, $skip); $this->validateQueryResult($queryResult, $queryType, 'IQueryProvider::getRelatedResourceSet'); return $queryResult; }