From 4ed3717844366427403633703ab1d29d33b16c4c Mon Sep 17 00:00:00 2001 From: Eileen Date: Sun, 5 Jan 2014 14:46:58 +1300 Subject: [PATCH] Additional Test, fix typos (mis-cased class-names), commit updated test-generated examples --- CRM/Core/BAO/Setting.php | 6 ++-- api/v3/examples/Setting/CreateAllDomains.php | 2 +- .../Setting/CreateSettingCurrentDomain.php | 2 +- .../Setting/CreateSpecifiedDomains.php | 2 +- api/v3/examples/Setting/GetAllDomains.php | 2 +- api/v3/examples/Setting/GetDefaults.php | 2 +- .../Setting/GetSettingCurrentDomain.php | 2 +- .../examples/Setting/GetSpecifiedDomains.php | 2 +- api/v3/examples/SettingCreate.php | 2 +- api/v3/examples/SettingGet.php | 2 +- api/v3/examples/SettingGetValue.php | 2 +- api/v3/examples/SettingGetfields.php | 33 ++++++++++++++++++- api/v3/examples/SettingRevert.php | 2 +- tests/phpunit/api/v3/SettingTest.php | 20 +++++++++++ 14 files changed, 66 insertions(+), 15 deletions(-) diff --git a/CRM/Core/BAO/Setting.php b/CRM/Core/BAO/Setting.php index 5638032038..adc9e04f84 100644 --- a/CRM/Core/BAO/Setting.php +++ b/CRM/Core/BAO/Setting.php @@ -511,7 +511,7 @@ class CRM_Core_BAO_Setting extends CRM_Core_DAO_Setting { $fields = civicrm_api('setting','getfields', $getFieldsParams); $invalidParams = (array_diff_key($settingParams, $fields['values'])); if (!empty($invalidParams)) { - throw new api_Exception(implode(',', $invalidParams) . " not valid settings"); + throw new API_Exception(implode(',', $invalidParams) . " not valid settings"); } if (!empty($settingParams)) { $filteredFields = array_intersect_key($settingParams, $fields['values']); @@ -539,7 +539,7 @@ class CRM_Core_BAO_Setting extends CRM_Core_DAO_Setting { else { list($class,$fn) = explode('::',$fieldSpec['validate_callback']); if (!$class::$fn($value,$fieldSpec)) { - throw new api_Exception("validation failed for {$fieldSpec['name']} = $value based on callback {$fieldSpec['validate_callback']}"); + throw new API_Exception("validation failed for {$fieldSpec['name']} = $value based on callback {$fieldSpec['validate_callback']}"); } } } @@ -552,7 +552,7 @@ class CRM_Core_BAO_Setting extends CRM_Core_DAO_Setting { */ static function validateBoolSetting(&$value, $fieldSpec) { if (!CRM_Utils_Rule::boolean($value)) { - throw new api_Exception("Boolean value required for {$fieldSpec['name']}"); + throw new API_Exception("Boolean value required for {$fieldSpec['name']}"); } if (!$value) { $value = 0; diff --git a/api/v3/examples/Setting/CreateAllDomains.php b/api/v3/examples/Setting/CreateAllDomains.php index fb82eb3c7f..8e1cc71ffa 100644 --- a/api/v3/examples/Setting/CreateAllDomains.php +++ b/api/v3/examples/Setting/CreateAllDomains.php @@ -69,4 +69,4 @@ function setting_create_expectedresult(){ * * API Standards documentation: * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards -*/ \ No newline at end of file +*/ diff --git a/api/v3/examples/Setting/CreateSettingCurrentDomain.php b/api/v3/examples/Setting/CreateSettingCurrentDomain.php index 78d29eeb58..95c6a3e748 100644 --- a/api/v3/examples/Setting/CreateSettingCurrentDomain.php +++ b/api/v3/examples/Setting/CreateSettingCurrentDomain.php @@ -63,4 +63,4 @@ function setting_create_expectedresult(){ * * API Standards documentation: * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards -*/ \ No newline at end of file +*/ diff --git a/api/v3/examples/Setting/CreateSpecifiedDomains.php b/api/v3/examples/Setting/CreateSpecifiedDomains.php index 4cc8712470..ced6602f96 100644 --- a/api/v3/examples/Setting/CreateSpecifiedDomains.php +++ b/api/v3/examples/Setting/CreateSpecifiedDomains.php @@ -69,4 +69,4 @@ function setting_create_expectedresult(){ * * API Standards documentation: * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards -*/ \ No newline at end of file +*/ diff --git a/api/v3/examples/Setting/GetAllDomains.php b/api/v3/examples/Setting/GetAllDomains.php index 32af9a1a66..dcf1fa8ac5 100644 --- a/api/v3/examples/Setting/GetAllDomains.php +++ b/api/v3/examples/Setting/GetAllDomains.php @@ -69,4 +69,4 @@ function setting_get_expectedresult(){ * * API Standards documentation: * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards -*/ \ No newline at end of file +*/ diff --git a/api/v3/examples/Setting/GetDefaults.php b/api/v3/examples/Setting/GetDefaults.php index 5084c159ce..4a9a404b3f 100644 --- a/api/v3/examples/Setting/GetDefaults.php +++ b/api/v3/examples/Setting/GetDefaults.php @@ -68,4 +68,4 @@ function setting_getdefaults_expectedresult(){ * * API Standards documentation: * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards -*/ \ No newline at end of file +*/ diff --git a/api/v3/examples/Setting/GetSettingCurrentDomain.php b/api/v3/examples/Setting/GetSettingCurrentDomain.php index b5b43f9741..c689047385 100644 --- a/api/v3/examples/Setting/GetSettingCurrentDomain.php +++ b/api/v3/examples/Setting/GetSettingCurrentDomain.php @@ -63,4 +63,4 @@ function setting_get_expectedresult(){ * * API Standards documentation: * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards -*/ \ No newline at end of file +*/ diff --git a/api/v3/examples/Setting/GetSpecifiedDomains.php b/api/v3/examples/Setting/GetSpecifiedDomains.php index f839e0934c..afa2601993 100644 --- a/api/v3/examples/Setting/GetSpecifiedDomains.php +++ b/api/v3/examples/Setting/GetSpecifiedDomains.php @@ -71,4 +71,4 @@ function setting_get_expectedresult(){ * * API Standards documentation: * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards -*/ \ No newline at end of file +*/ diff --git a/api/v3/examples/SettingCreate.php b/api/v3/examples/SettingCreate.php index 1463355532..b5a337a500 100644 --- a/api/v3/examples/SettingCreate.php +++ b/api/v3/examples/SettingCreate.php @@ -64,4 +64,4 @@ function setting_create_expectedresult(){ * * API Standards documentation: * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards -*/ \ No newline at end of file +*/ diff --git a/api/v3/examples/SettingGet.php b/api/v3/examples/SettingGet.php index 714ae6d338..e00ef28be3 100644 --- a/api/v3/examples/SettingGet.php +++ b/api/v3/examples/SettingGet.php @@ -64,4 +64,4 @@ function setting_get_expectedresult(){ * * API Standards documentation: * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards -*/ \ No newline at end of file +*/ diff --git a/api/v3/examples/SettingGetValue.php b/api/v3/examples/SettingGetValue.php index c48517dd99..6455fa9e37 100644 --- a/api/v3/examples/SettingGetValue.php +++ b/api/v3/examples/SettingGetValue.php @@ -54,4 +54,4 @@ function setting_getvalue_expectedresult(){ * * API Standards documentation: * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards -*/ \ No newline at end of file +*/ diff --git a/api/v3/examples/SettingGetfields.php b/api/v3/examples/SettingGetfields.php index bdbf056954..cff321c4d8 100644 --- a/api/v3/examples/SettingGetfields.php +++ b/api/v3/examples/SettingGetfields.php @@ -28,7 +28,7 @@ function setting_getfields_expectedresult(){ $expectedResult = array( 'is_error' => 0, 'version' => 3, - 'count' => 81, + 'count' => 82, 'values' => array( 'address_standardization_provider' => array( 'group_name' => 'Address Preferences', @@ -654,6 +654,27 @@ When enabled, statistics about your CiviCRM installation are reported anonymousl 'description' => '', 'help_text' => '', ), + 'blogUrl' => array( + 'group_name' => 'CiviCRM Preferences', + 'group' => 'core', + 'name' => 'blogUrl', + 'prefetch' => 0, + 'config_only' => 0, + 'type' => 'String', + 'quick_form_type' => 'Element', + 'html_type' => 'Text', + 'html_attributes' => array( + 'size' => 64, + 'maxlength' => 128, + ), + 'default' => '*default*', + 'add' => '4.3', + 'title' => 'Blog Feed URL', + 'is_domain' => 1, + 'is_contact' => 0, + 'description' => 'Blog feed URL used by the blog dashlet', + 'help_text' => 'Use \"*default*\" for the system default or override with a custom URL', + ), 'communityMessagesUrl' => array( 'group_name' => 'CiviCRM Preferences', 'group' => 'core', @@ -768,6 +789,16 @@ When enabled, statistics about your CiviCRM installation are reported anonymousl 'is_contact' => 0, 'description' => '', 'help_text' => '', + 'on_change' => array( + '0' => array( + '0' => 'CRM_Case_Info', + '1' => 'onToggleComponents', + ), + '1' => array( + '0' => 'CRM_Core_Component', + '1' => 'flushEnabledComponents', + ), + ), ), 'disable_core_css' => array( 'group_name' => 'CiviCRM Preferences', diff --git a/api/v3/examples/SettingRevert.php b/api/v3/examples/SettingRevert.php index ffacc49fd4..5ae0d9d05a 100644 --- a/api/v3/examples/SettingRevert.php +++ b/api/v3/examples/SettingRevert.php @@ -74,4 +74,4 @@ function setting_revert_expectedresult(){ * * API Standards documentation: * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards -*/ \ No newline at end of file +*/ diff --git a/tests/phpunit/api/v3/SettingTest.php b/tests/phpunit/api/v3/SettingTest.php index 31a923841d..2272085e01 100644 --- a/tests/phpunit/api/v3/SettingTest.php +++ b/tests/phpunit/api/v3/SettingTest.php @@ -125,6 +125,26 @@ class api_v3_SettingTest extends CiviUnitTestCase { $this->assertArrayHasKey('advanced_search_options',$result['values']); } + /** + * Test that getfields will filter on group + */ + function testGetFieldsGroupFilters() { + $params = array('filters' => array('group' => 'multisite')); + $result = $this->callAPISuccess('setting', 'getfields', $params); + $this->assertArrayNotHasKey('customCSSURL', $result['values']); + $this->assertArrayHasKey('domain_group_id',$result['values']); + } + + /** + * Test that getfields will filter on another field (prefetch) + */ + function testGetFieldsPrefetchFilters() { + $params = array('filters' => array('prefetch' => 1)); + $result = $this->callAPISuccess('setting', 'getfields', $params); + $this->assertArrayNotHasKey('disable_mandatory_tokens_check', $result['values']); + $this->assertArrayHasKey('monetaryDecimalPoint',$result['values']); + } + /** * Ensure that on_change callbacks fire. * -- 2.25.1