*/
function civicrm_api3_entity_tag_get($params) {
-
- $values = CRM_Core_BAO_EntityTag::getTag($params['entity_id'], $params['entity_table']);
- $result = array();
- foreach ($values as $v) {
- $result[$v] = array('tag_id' => $v);
+ if(empty($params['entity_id'])) {
+ return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
+ }
+ else{
+ //do legacy non-standard behaviour
+ $values = CRM_Core_BAO_EntityTag::getTag($params['entity_id'], $params['entity_table']);
+ $result = array();
+ foreach ($values as $v) {
+ $result[$v] = array('tag_id' => $v);
+ }
+ return civicrm_api3_create_success($result, $params);
}
- return civicrm_api3_create_success($result, $params);
}
/**
* @param array $params array or parameters determined by getfields
*/
function _civicrm_api3_entity_tag_get_spec(&$params) {
- $params['entity_id']['api.required'] = 1;
$params['entity_id']['api.aliases'] = array('contact_id');
$params['entity_table']['api.default'] = 'civicrm_contact';
}
protected $_tagID;
protected $_apiversion = 3;
protected $_tag;
+ protected $_entity = 'entity_tag';
public $_eNoticeCompliant = TRUE;
function setUp() {
}
///////////////// civicrm_entity_tag_get methods
- function testGetWrongParamsType() {
+ function testGetNoEntityID() {
$ContactId = $this->_individualID;
$tagID = $this->_tagID;
$params = array(
$individualEntity = $this->callAPISuccess('entity_tag', 'create', $params);
$this->assertEquals($individualEntity['added'], 1);
- }
-
- function testIndividualEntityTagGetWithoutContactID() {
- $paramsEntity = array();
- $entity = $this->callAPIFailure('entity_tag', 'get', $paramsEntity,
- 'Mandatory key(s) missing from params array: entity_id'
- );
+ $result = $this->callAPISuccess($this->_entity, 'get', array('sequential' => 1, 'tag_id' => $tagID));
+ $this->assertEquals($ContactId, $result['values'][0]['entity_id']);
}
function testIndividualEntityTagGet() {
$entity = $this->callAPISuccess('entity_tag', 'get', $paramsEntity);
}
- function testHouseholdEntityGetWithoutContactID() {
- $entity = $this->callAPIFailure('entity_tag', 'get', array());
- }
-
function testHouseholdEntityGet() {
$ContactId = $this->_householdID;
$tagID = $this->_tagID;
$this->assertEquals($householdEntity['added'], 1);
}
- function testOrganizationEntityGetWithoutContactID() {
- $entity = $this->callAPIFailure('entity_tag', 'get', array());
- }
-
function testOrganizationEntityGet() {
$ContactId = $this->_organizationID;
$tagID = $this->_tagID;
$entity = $this->callAPISuccess('entity_tag', 'get', $paramsEntity);
}
- ///////////////// civicrm_entity_tag_remove methods
- function testEntityTagRemoveNoTagId() {
+ ///////////////// civicrm_entity_tag_Delete methods
+ function testEntityTagDeleteNoTagId() {
$entityTagParams = array(
'contact_id_i' => $this->_individualID,
'contact_id_h' => $this->_householdID,
);
}
- function testEntityTagRemoveINDHH() {
+ function testEntityTagDeleteINDHH() {
$entityTagParams = array(
'contact_id_i' => $this->_individualID,
'contact_id_h' => $this->_householdID,
$this->assertEquals($result['removed'], 1);
}
- function testEntityTagRemoveHHORG() {
+ function testEntityTagDeleteHHORG() {
$entityTagParams = array(
'contact_id_i' => $this->_individualID,
'contact_id_h' => $this->_householdID,
}
- function testEntityTagCommonRemoveINDHH() {
+ function testEntityTagCommonDeleteINDHH() {
$entityTagParams = array(
'contact_id_i' => $this->_individualID,
'contact_id_h' => $this->_householdID,
$this->assertEquals($result['removed'], 2);
}
- function testEntityTagCommonRemoveHH() {
+ function testEntityTagCommonDeleteHH() {
$entityTagParams = array(
'contact_id_i' => $this->_individualID,
'contact_id_h' => $this->_householdID,
$this->assertEquals($result['removed'], 1);
}
- function testEntityTagCommonRemoveHHORG() {
+ function testEntityTagCommonDeleteHHORG() {
$entityTagParams = array(
'contact_id_i' => $this->_individualID,
'contact_id_h' => $this->_householdID,