From: CiviCRM Date: Wed, 20 Mar 2013 12:21:36 +0000 (-0400) Subject: CRM-12133 - api/v3/CustomSearch - Fix option_group_id error X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=e310e1293c39e49f349ad80e12eff388cb989b49;p=civicrm-core.git CRM-12133 - api/v3/CustomSearch - Fix option_group_id error --- diff --git a/api/v3/CustomSearch.php b/api/v3/CustomSearch.php index 1860ae48e5..26458cb4e4 100644 --- a/api/v3/CustomSearch.php +++ b/api/v3/CustomSearch.php @@ -54,6 +54,9 @@ function civicrm_api3_custom_search_create($params) { function _civicrm_api3_custom_search_create_spec(&$params) { require_once 'api/v3/OptionValue.php'; _civicrm_api3_option_value_create_spec($params); + $params['option_group_id']['api.default'] = CRM_Core_DAO::getFieldValue( + 'CRM_Core_DAO_OptionGroup', 'custom_search', 'id', 'name' + ); $params['name']['api.aliases'] = array('class_name'); } diff --git a/tests/phpunit/api/v3/CustomSearchTest.php b/tests/phpunit/api/v3/CustomSearchTest.php index 41783e4e70..eda0c03519 100644 --- a/tests/phpunit/api/v3/CustomSearchTest.php +++ b/tests/phpunit/api/v3/CustomSearchTest.php @@ -19,7 +19,7 @@ class api_v3_CustomSearchTest extends CiviUnitTestCase { 'description' => 'Longish description of the example search form', 'class_name' => 'CRM_Contact_Form_Search_Custom_Examplez', )); - $this->assertEquals(0, $result['is_error'], 'In line ' . __LINE__); + $this->assertAPISuccess($result); $this->assertEquals(1, $result['count'], 'In line ' . __LINE__); $entityId = $result['id']; $this->assertTrue(is_numeric($entityId), 'In line ' . __LINE__); @@ -36,7 +36,7 @@ class api_v3_CustomSearchTest extends CiviUnitTestCase { 'id' => $entityId, 'is_active' => 0, )); - $this->assertEquals(0, $result['is_error'], 'In line ' . __LINE__); + $this->assertAPISuccess($result); $this->assertEquals(1, $result['count'], 'In line ' . __LINE__); $this->assertDBQuery(1, 'SELECT count(*) FROM civicrm_option_value WHERE name = "CRM_Contact_Form_Search_Custom_Examplez" @@ -51,7 +51,7 @@ class api_v3_CustomSearchTest extends CiviUnitTestCase { 'id' => $entityId, 'is_active' => 1, )); - $this->assertEquals(0, $result['is_error'], 'In line ' . __LINE__); + $this->assertAPISuccess($result); $this->assertEquals(1, $result['count'], 'In line ' . __LINE__); $this->assertDBQuery(1, 'SELECT count(*) FROM civicrm_option_value WHERE name = "CRM_Contact_Form_Search_Custom_Examplez" @@ -64,7 +64,7 @@ class api_v3_CustomSearchTest extends CiviUnitTestCase { 'version' => $this->_apiversion, 'id' => $entityId, )); - $this->assertEquals(0, $result['is_error'], 'In line ' . __LINE__); + $this->assertAPISuccess($result); $this->assertEquals(1, $result['count'], 'In line ' . __LINE__); $this->assertDBQuery(0, 'SELECT count(*) FROM civicrm_option_value WHERE name = "CRM_Contact_Form_Search_Custom_Examplez"