コード例 #1
0
 /**
  * Whether this association set represents a two way relationship between 
  * resource sets
  * 
  * @return boolean true if relationship is bidirectional, otherwise false 
  */
 public function isBidirectional()
 {
     return !is_null($this->_end1->getResourceProperty()) && !is_null($this->_end2->getResourceProperty());
 }
コード例 #2
0
 /**
  * Test ResourceAssociationSetEnd class
  * Note: ResourceAssociationSetEnd is an internal class used for metadata generation, not suppose to used by the developers 
  */
 public function testResourceAssociationSetEnd()
 {
     try {
         $customerResType = $this->_getCustomerResourceType();
         $orderResType = $this->_getOrderResourceType();
         $ordersReferenceSetProperty = new ResourceProperty('Orders', null, ResourcePropertyKind::RESOURCESET_REFERENCE, $orderResType);
         $customerResType->addProperty($ordersReferenceSetProperty);
         $customerResourceSet = new ResourceSet('Customers', $customerResType);
         $exceptionThrown = false;
         try {
             $customerIDPrimProperty = $customerResType->tryResolvePropertyTypeByName('CustomerID');
             $assoSetEnd = new ResourceAssociationSetEnd($customerResourceSet, $customerResType, $customerIDPrimProperty);
         } catch (\InvalidArgumentException $exception) {
             $exceptionThrown = true;
             $this->AssertEquals('The property CustomerID must be a navigation property of the resource type Northwind.Customer', $exception->getMessage());
         }
         if (!$exceptionThrown) {
             $this->fail('An expected InvalidArgumentException for \'not valid navigation property\' has not been raised');
         }
         $exceptionThrown = false;
         try {
             $assoSetEnd = new ResourceAssociationSetEnd($customerResourceSet, $orderResType, $ordersReferenceSetProperty);
         } catch (\InvalidArgumentException $exception) {
             $exceptionThrown = true;
             $this->AssertEquals('The property Orders must be a navigation property of the resource type Northwind.Order', $exception->getMessage());
         }
         if (!$exceptionThrown) {
             $this->fail('An expected InvalidArgumentException for \'not valid navigation property\' has not been raised');
         }
         $assoSetEnd = new ResourceAssociationSetEnd($customerResourceSet, $customerResType, $ordersReferenceSetProperty);
         $this->AssertEquals($assoSetEnd->getResourceSet()->getName(), 'Customers');
         $this->AssertEquals($assoSetEnd->getResourceType()->getName(), 'Customer');
         $this->AssertEquals($assoSetEnd->getResourceProperty()->getName(), 'Orders');
         $this->AssertTrue($assoSetEnd->isBelongsTo($customerResourceSet, $customerResType, $ordersReferenceSetProperty));
     } catch (\Exception $exception) {
         $this->fail('An unexpected Exception has been raised' . $exception->getMessage());
     }
 }