public function testGetResourceSetsSecondOneIsNotVisible()
 {
     $fakeSets = array($this->mockResourceSet, $this->mockResourceSet2);
     Phockito::when($this->mockMetadataProvider->getResourceSets())->return($fakeSets);
     Phockito::when($this->mockResourceSet->getName())->return("fake name 1");
     Phockito::when($this->mockResourceSet2->getName())->return("fake name 2");
     Phockito::when($this->mockResourceSet->getResourceType())->return($this->mockResourceType);
     Phockito::when($this->mockResourceSet2->getResourceType())->return($this->mockResourceType);
     Phockito::when($this->mockServiceConfig->getEntitySetAccessRule($this->mockResourceSet))->return(EntitySetRights::NONE);
     Phockito::when($this->mockServiceConfig->getEntitySetAccessRule($this->mockResourceSet2))->return(EntitySetRights::READ_SINGLE);
     $wrapper = $this->getMockedWrapper();
     $actual = $wrapper->getResourceSets();
     $expected = array(new ResourceSetWrapper($this->mockResourceSet2, $this->mockServiceConfig));
     $this->assertEquals($expected, $actual);
 }
Beispiel #2
0
 /**
  *  To get all entity set information, 
  *  Note: Wrapper for IMetadataProvider::getResourceSets method implementation,
  *  This method returns array of ResourceSetWrapper instances but the corresponding IDSMP method returns array of ResourceSet instances
  *
  *  @return ResourceSetWrapper[] The ResourceSetWrappers for the visible ResourceSets
  *  @throws ODataException when two resource sets with the same name are encountered
  *
  */
 public function getResourceSets()
 {
     $resourceSets = $this->metaProvider->getResourceSets();
     $resourceSetWrappers = array();
     $resourceSetNames = array();
     foreach ($resourceSets as $resourceSet) {
         $name = $resourceSet->getName();
         if (in_array($name, $resourceSetNames)) {
             throw new ODataException(Messages::providersWrapperEntitySetNameShouldBeUnique($name), 500);
         }
         $resourceSetNames[] = $name;
         $resourceSetWrapper = $this->_validateResourceSetAndGetWrapper($resourceSet);
         if (!is_null($resourceSetWrapper)) {
             $resourceSetWrappers[] = $resourceSetWrapper;
         }
     }
     return $resourceSetWrappers;
 }