Skip to content
Snippets Groups Projects
Commit 283c85e9 authored by eileen's avatar eileen
Browse files

CRM-13254 (Closes) make entity_tag.get api use basic create rather than error...

CRM-13254 (Closes) make entity_tag.get api use basic create rather than error if no entity_id passed in
parent 02dcc2fd
No related branches found
No related tags found
No related merge requests found
......@@ -50,13 +50,18 @@
*/
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);
}
/**
......@@ -66,7 +71,6 @@ function civicrm_api3_entity_tag_get($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';
}
......
......@@ -5,7 +5,7 @@
*/
function entity_tag_delete_example(){
$params = array(
'contact_id_h' => 46,
'contact_id_h' => 37,
'tag_id' => '1',
);
......
......@@ -5,7 +5,7 @@
*/
function entity_tag_get_example(){
$params = array(
'contact_id' => 24,
'contact_id' => 21,
'tag_id' => '1',
);
......
......@@ -44,6 +44,7 @@ class api_v3_EntityTagTest extends CiviUnitTestCase {
protected $_tagID;
protected $_apiversion = 3;
protected $_tag;
protected $_entity = 'entity_tag';
public $_eNoticeCompliant = TRUE;
function setUp() {
......@@ -118,7 +119,7 @@ class api_v3_EntityTagTest extends CiviUnitTestCase {
}
///////////////// civicrm_entity_tag_get methods
function testGetWrongParamsType() {
function testGetNoEntityID() {
$ContactId = $this->_individualID;
$tagID = $this->_tagID;
$params = array(
......@@ -128,13 +129,8 @@ class api_v3_EntityTagTest extends CiviUnitTestCase {
$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() {
......@@ -154,10 +150,6 @@ class api_v3_EntityTagTest extends CiviUnitTestCase {
$entity = $this->callAPISuccess('entity_tag', 'get', $paramsEntity);
}
function testHouseholdEntityGetWithoutContactID() {
$entity = $this->callAPIFailure('entity_tag', 'get', array());
}
function testHouseholdEntityGet() {
$ContactId = $this->_householdID;
$tagID = $this->_tagID;
......@@ -170,10 +162,6 @@ class api_v3_EntityTagTest extends CiviUnitTestCase {
$this->assertEquals($householdEntity['added'], 1);
}
function testOrganizationEntityGetWithoutContactID() {
$entity = $this->callAPIFailure('entity_tag', 'get', array());
}
function testOrganizationEntityGet() {
$ContactId = $this->_organizationID;
$tagID = $this->_tagID;
......@@ -189,8 +177,8 @@ class api_v3_EntityTagTest extends CiviUnitTestCase {
$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,
......@@ -208,7 +196,7 @@ class api_v3_EntityTagTest extends CiviUnitTestCase {
);
}
function testEntityTagRemoveINDHH() {
function testEntityTagDeleteINDHH() {
$entityTagParams = array(
'contact_id_i' => $this->_individualID,
'contact_id_h' => $this->_householdID,
......@@ -244,7 +232,7 @@ class api_v3_EntityTagTest extends CiviUnitTestCase {
$this->assertEquals($result['removed'], 1);
}
function testEntityTagRemoveHHORG() {
function testEntityTagDeleteHHORG() {
$entityTagParams = array(
'contact_id_i' => $this->_individualID,
'contact_id_h' => $this->_householdID,
......@@ -276,7 +264,7 @@ class api_v3_EntityTagTest extends CiviUnitTestCase {
}
function testEntityTagCommonRemoveINDHH() {
function testEntityTagCommonDeleteINDHH() {
$entityTagParams = array(
'contact_id_i' => $this->_individualID,
'contact_id_h' => $this->_householdID,
......@@ -294,7 +282,7 @@ class api_v3_EntityTagTest extends CiviUnitTestCase {
$this->assertEquals($result['removed'], 2);
}
function testEntityTagCommonRemoveHH() {
function testEntityTagCommonDeleteHH() {
$entityTagParams = array(
'contact_id_i' => $this->_individualID,
'contact_id_h' => $this->_householdID,
......@@ -311,7 +299,7 @@ class api_v3_EntityTagTest extends CiviUnitTestCase {
$this->assertEquals($result['removed'], 1);
}
function testEntityTagCommonRemoveHHORG() {
function testEntityTagCommonDeleteHHORG() {
$entityTagParams = array(
'contact_id_i' => $this->_individualID,
'contact_id_h' => $this->_householdID,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment