示例#1
0
 public function testGetTypesDuplicateNames()
 {
     $fakeTypes = array(new ResourceType(new String(), ResourceTypeKind::PRIMITIVE, "FakeType1"), new ResourceType(new String(), ResourceTypeKind::PRIMITIVE, "FakeType1"));
     Phockito::when($this->mockMetadataProvider->getTypes())->return($fakeTypes);
     $wrapper = $this->getMockedWrapper();
     try {
         $wrapper->getTypes();
         $this->fail('An expected ODataException for entity type name repetition has not been thrown');
     } catch (ODataException $exception) {
         $this->assertEquals(Messages::providersWrapperEntityTypeNameShouldBeUnique("FakeType1"), $exception->getMessage());
         $this->assertEquals(500, $exception->getStatusCode());
     }
 }
示例#2
0
 /**
  * To get all resource types in the data source,
  * Note: Wrapper for IMetadataProvider::getTypes method implementation
  * 
  * @return ResourceType[]
  */
 public function getTypes()
 {
     $resourceTypes = $this->metaProvider->getTypes();
     $resourceTypeNames = array();
     foreach ($resourceTypes as $resourceType) {
         if (in_array($resourceType->getName(), $resourceTypeNames)) {
             throw new ODataException(Messages::providersWrapperEntityTypeNameShouldBeUnique($resourceType->getName()), 500);
         }
         $resourceTypeNames[] = $resourceType->getName();
         $this->_validateResourceType($resourceType);
     }
     return $resourceTypes;
 }