From a9739e5dcddfa3a8e30d7680d7c84c8657515e33 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Wed, 1 Jan 2014 14:10:49 -0800 Subject: [PATCH] Test fixes --- api/v3/utils.php | 8 ++++++-- tests/phpunit/api/v3/GroupContactTest.php | 6 +++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/api/v3/utils.php b/api/v3/utils.php index 4db65b24b7..02058a38f7 100644 --- a/api/v3/utils.php +++ b/api/v3/utils.php @@ -1056,7 +1056,11 @@ function _civicrm_api3_basic_create($bao_name, &$params, $entity = NULL) { * @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, @@ -1065,7 +1069,7 @@ function _civicrm_api3_basic_create_fallback($bao_name, &$params) { $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); diff --git a/tests/phpunit/api/v3/GroupContactTest.php b/tests/phpunit/api/v3/GroupContactTest.php index 4ad7ea1218..24c7304620 100644 --- a/tests/phpunit/api/v3/GroupContactTest.php +++ b/tests/phpunit/api/v3/GroupContactTest.php @@ -34,7 +34,6 @@ class api_v3_GroupContactTest extends CiviUnitTestCase { protected $_contactId1; protected $_apiversion = 3; protected $_groupId1; - protected $_groupContactId; function get_info() { return array( @@ -61,7 +60,6 @@ class api_v3_GroupContactTest extends CiviUnitTestCase { ); $result = $this->callAPISuccess('group_contact', 'create', $params); - $this->_groupContactId = $result['id']; $group = array( 'name' => 'Test Group 2', @@ -183,13 +181,15 @@ class api_v3_GroupContactTest extends CiviUnitTestCase { } 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__); } } -- 2.25.1