From 6a73ef3fd132fe88bfd3456cf6a4d4a6f54ae846 Mon Sep 17 00:00:00 2001 From: eileen Date: Thu, 6 Jun 2013 16:09:34 +1200 Subject: [PATCH] make ufgroup api tests & api enotice complian --- CRM/Core/BAO/UFGroup.php | 6 +++--- api/v3/UFGroup.php | 10 +--------- tests/phpunit/api/v3/UFGroupTest.php | 4 +++- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/CRM/Core/BAO/UFGroup.php b/CRM/Core/BAO/UFGroup.php index 05fed66b2d..cf4072839c 100644 --- a/CRM/Core/BAO/UFGroup.php +++ b/CRM/Core/BAO/UFGroup.php @@ -1367,7 +1367,7 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup { * * @return object */ - static function add(&$params, &$ids) { + static function add(&$params, $ids = array()) { $fields = array('is_active', 'add_captcha', 'is_map', 'is_update_dupe', 'is_edit_link', 'is_uf_link', 'is_cms_user'); foreach ($fields as $field) { $params[$field] = CRM_Utils_Array::value($field, $params, FALSE); @@ -1379,7 +1379,7 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup { $ufGroup = new CRM_Core_DAO_UFGroup(); $ufGroup->copyValues($params); - $ufGroupID = CRM_Utils_Array::value('ufgroup', $ids); + $ufGroupID = CRM_Utils_Array::value('ufgroup', $ids, CRM_Utils_Array::value('id', $params)); if (!$ufGroupID) { $ufGroup->name = CRM_Utils_String::munge($ufGroup->title, '_', 56); } @@ -2033,7 +2033,7 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) ) as $suppress) { unset($contributionStatuses[CRM_Utils_Array::key($suppress, $statusName)]); } - + $form->add('select', $name, $title, array( '' => ts('- select -')) + $contributionStatuses, $required diff --git a/api/v3/UFGroup.php b/api/v3/UFGroup.php index 0c77c402d1..2e847d2ee9 100644 --- a/api/v3/UFGroup.php +++ b/api/v3/UFGroup.php @@ -60,15 +60,7 @@ function _civicrm_api3_uf_group_create_spec(&$params) { * @access public */ function civicrm_api3_uf_group_create($params) { - - $ids = array(); - $ids['ufgroup'] = $params['id']; - - - $ufGroup = CRM_Core_BAO_UFGroup::add($params, $ids); - _civicrm_api3_object_to_array($ufGroup, $ufGroupArray[$ufGroup->id]); - - return civicrm_api3_create_success($ufGroupArray, $params); + return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params); } /** diff --git a/tests/phpunit/api/v3/UFGroupTest.php b/tests/phpunit/api/v3/UFGroupTest.php index edea02abd3..46e2ffa2a2 100644 --- a/tests/phpunit/api/v3/UFGroupTest.php +++ b/tests/phpunit/api/v3/UFGroupTest.php @@ -44,6 +44,7 @@ class api_v3_UFGroupTest extends CiviUnitTestCase { protected $_contactId = 69; protected $_apiversion; protected $params; + public $_eNoticeCompliant = TRUE; protected function setUp() { parent::setUp(); @@ -173,7 +174,7 @@ class api_v3_UFGroupTest extends CiviUnitTestCase { $result = civicrm_api('uf_group', 'create', $this->params); $this->documentMe($this->params, $result, __FUNCTION__, __FILE__); - + $this->assertAPISuccess($result); $this->assertEquals($result['values'][$result['id']]['add_to_group_id'], $this->params['add_contact_to_group'], 'in line ' . __LINE__); $this->assertEquals($result['values'][$result['id']]['limit_listings_group_id'], $this->params['group'], 'in line ' . __LINE__); $this->params['created_date'] = date('YmdHis', strtotime($this->params['created_date'])); @@ -278,6 +279,7 @@ class api_v3_UFGroupTest extends CiviUnitTestCase { function testUFGroupDelete() { $ufGroup = civicrm_api('uf_group', 'create', $this->params); + $this->assertAPISuccess($ufGroup); $params = array('version' => $this->_apiversion, 'id' => $ufGroup['id']); $this->assertEquals(1, civicrm_api('uf_group', 'getcount', $params), "in line " . __LINE__); $result = civicrm_api('uf_group', 'delete', $params, "in line " . __LINE__); -- 2.25.1