public function testGetDerivedTypesNonArrayReturnedThrows()
 {
     $fakeName = "FakeType";
     Phockito::when($this->mockMetadataProvider->getDerivedTypes($this->mockResourceType))->return($this->mockResourceType);
     Phockito::when($this->mockResourceType->getName())->return($fakeName);
     $wrapper = $this->getMockedWrapper();
     try {
         $wrapper->getDerivedTypes($this->mockResourceType);
         $this->fail("Expected exception not thrown");
     } catch (InvalidOperationException $ex) {
         $this->assertEquals(Messages::metadataAssociationTypeSetInvalidGetDerivedTypesReturnType($fakeName), $ex->getMessage());
     }
 }
Beispiel #2
0
 /**
  * The method must return a collection of all the types derived from 
  * $resourceType The collection returned should NOT include the type 
  * passed in as a parameter
  * Note: Wrapper for IMetadataProvider::getDerivedTypes
  * method implementation
  * 
  * @param ResourceType $resourceType Resource to get derived resource types from
  * 
  * @return ResourceType[]
  *
  * @throws InvalidOperationException when the meat provider doesn't return an array
  */
 public function getDerivedTypes(ResourceType $resourceType)
 {
     $derivedTypes = $this->metaProvider->getDerivedTypes($resourceType);
     if (!is_array($derivedTypes)) {
         throw new InvalidOperationException(Messages::metadataAssociationTypeSetInvalidGetDerivedTypesReturnType($resourceType->getName()));
     }
     foreach ($derivedTypes as $derivedType) {
         $this->_validateResourceType($derivedType);
     }
     return $derivedTypes;
 }