* @return CRM_Core_DAO|NULL an instance of the BAO
*/
function _civicrm_api3_basic_create_fallback($bao_name, &$params) {
- $entityName = CRM_Core_DAO_AllCoreTables::getBriefName(get_parent_class($bao_name));
+ $dao_name = get_parent_class($bao_name);
+ if ($dao_name === 'CRM_Core_DAO' || !$dao_name) {
+ $dao_name = $bao_name;
+ }
+ $entityName = CRM_Core_DAO_AllCoreTables::getBriefName($dao_name);
if (empty($entityName)) {
throw new API_Exception("Class \"$bao_name\" does not map to an entity name", "unmapped_class_to_entity", array(
'class_name' => $bao_name,
$hook = empty($params['id']) ? 'create' : 'edit';
CRM_Utils_Hook::pre($hook, $entityName, CRM_Utils_Array::value('id', $params), $params);
- $instance = new $bao_name();
+ $instance = new $dao_name();
$instance->copyValues($params);
$instance->save();
CRM_Utils_Hook::post($hook, $entityName, $instance->id, $instance);
protected $_contactId1;
protected $_apiversion = 3;
protected $_groupId1;
- protected $_groupContactId;
function get_info() {
return array(
);
$result = $this->callAPISuccess('group_contact', 'create', $params);
- $this->_groupContactId = $result['id'];
$group = array(
'name' => 'Test Group 2',
}
function testDeletePermanent() {
+ $result = $this->callAPISuccess('group_contact', 'get', array('contact_id' => $this->_contactId));
$params = array(
- 'id' => $this->_groupContactId,
+ 'id' => $result['id'],
'skip_undelete' => TRUE,
);
$this->callAPIAndDocument('group_contact', 'delete', $params, __FUNCTION__, __FILE__);
$result = $this->callAPISuccess('group_contact', 'get', $params);
$this->assertEquals(0, $result['count'], "in line " . __LINE__);
+ $this->assertArrayNotHasKey('id', $result, "in line " . __LINE__);
}
}