Beispiel #1
0
 function validRelationships()
 {
     require_once "api/v2/Relationship.php";
     $this->relationTypes = $relationTypes = array();
     $params = array('contact_type_b' => 'Household');
     $typesA =& civicrm_relationship_types_get($params);
     foreach ($typesA as $rel) {
         $relationTypes[$rel['id']][$rel['id'] . '_b_a'] = $rel['label_b_a'];
         //$this->relationTypes[$rel['id'].'_b_a'] = $rel['label_b_a'];
     }
     $params = array('contact_type_a' => 'Household');
     $typesB =& civicrm_relationship_types_get($params);
     foreach ($typesB as $rel) {
         $relationTypes[$rel['id']][$rel['id'] . '_a_b'] = $rel['label_a_b'];
         //$this->relationTypes[$rel['id'].'_a_b'] = $rel['label_a_b'];
     }
     ksort($relationTypes);
     foreach ($relationTypes as $relationship) {
         foreach ($relationship as $index => $label) {
             $this->relationTypes[$index] = $label;
         }
     }
 }
/**
 * Wrapper to support rest calls, CRM-6860
 * return An array of Relationship_type
 * * @access  public
 */
function civicrm_relationshipType_get($params = null)
{
    return civicrm_relationship_types_get($params);
}
 /**
  * check with valid params array.
  */
 function testRelationshipTypesGet()
 {
     $firstRelTypeParams = array('name_a_b' => 'Relation 1 for create', 'name_b_a' => 'Relation 2 for create', 'description' => 'Testing relationship type', 'contact_type_a' => 'Individual', 'contact_type_b' => 'Organization', 'is_reserved' => 1, 'is_active' => 1);
     $secondRelTypeParams = array('name_a_b' => 'Relation 3 for create', 'name_b_a' => 'Relation 4 for create', 'description' => 'Testing relationship type second', 'contact_type_a' => 'Individual', 'contact_type_b' => 'Organization', 'is_reserved' => 0, 'is_active' => 1);
     $relTypeIds = array();
     // create sample relationship types.
     foreach (array('firstRelType', 'secondRelType') as $relType) {
         $params = "{$relType}Params";
         $relTypeIds["{$relType}Id"] = $this->_relationshipTypeCreate(${$params});
     }
     //get relationship types from db.
     $params = array('name_a_b' => 'Relation 3 for create', 'name_b_a' => 'Relation 4 for create', 'description' => 'Testing relationship type second');
     $results =& civicrm_relationship_types_get($params);
     $retrievedRelTypes = array();
     if (is_array($results)) {
         foreach ($results as $relTypeValues) {
             if (($relTypeId = CRM_Utils_Array::value('id', $relTypeValues)) && in_array($relTypeId, $relTypeIds)) {
                 $retrievedRelTypes[$relTypeId] = $relTypeValues;
             }
         }
     }
     if (count($retrievedRelTypes) != 1) {
         $this->fail('Fail to retrieve target relationship type.');
     }
     foreach ($secondRelTypeParams as $key => $val) {
         $this->assertEquals(CRM_Utils_Array::value($key, $retrievedRelTypes[$relTypeIds['secondRelTypeId']]), $val, "Fail to retrieve {$key}");
     }
 }