<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.5 |
+ | CiviCRM version 4.6 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
-*/
+ */
require_once 'CiviTest/CiviUnitTestCase.php';
* Class CRM_Core_BAO_SettingTest
*/
class CRM_Core_BAO_SettingTest extends CiviUnitTestCase {
- /**
- * @return array
- */
- function get_info() {
- return array(
- 'name' => 'Setting BAO',
- 'description' => 'Test set/get on setting variables.',
- 'group' => 'CiviCRM BAO Tests',
- );
- }
-
- function setUp() {
+ public function setUp() {
parent::setUp();
global $civicrm_setting;
$this->origSetting = $civicrm_setting;
CRM_Utils_Cache::singleton()->flush();
}
- function tearDown() {
+ public function tearDown() {
global $civicrm_setting;
$civicrm_setting = $this->origSetting;
CRM_Utils_Cache::singleton()->flush();
parent::tearDown();
}
- function testEnableComponentValid() {
+ public function testEnableComponentValid() {
$config = CRM_Core_Config::singleton(TRUE, TRUE);
$result = CRM_Core_BAO_ConfigSetting::enableComponent('CiviCampaign');
$this->assertTrue($result);
}
- function testEnableComponentAlreadyPresent() {
+ public function testEnableComponentAlreadyPresent() {
$config = CRM_Core_Config::singleton(TRUE, TRUE);
$result = CRM_Core_BAO_ConfigSetting::enableComponent('CiviCampaign');
$this->assertTrue($result);
}
- function testEnableComponentInvalid() {
+ public function testEnableComponentInvalid() {
$config = CRM_Core_Config::singleton(TRUE, TRUE);
$result = CRM_Core_BAO_ConfigSetting::enableComponent('CiviFake');
* Ensure that overrides in $civicrm_setting apply when
* using getItem($group,$name).
*/
- function testGetItem_Override() {
+ public function testGetItem_Override() {
global $civicrm_setting;
$civicrm_setting[CRM_Core_BAO_Setting::DIRECTORY_PREFERENCES_NAME]['imageUploadDir'] = '/test/override';
$value = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::DIRECTORY_PREFERENCES_NAME, 'imageUploadDir');
* Ensure that overrides in $civicrm_setting apply when
* using getItem($group).
*/
- function testGetItemGroup_Override() {
+ public function testGetItemGroup_Override() {
global $civicrm_setting;
$civicrm_setting[CRM_Core_BAO_Setting::DIRECTORY_PREFERENCES_NAME]['imageUploadDir'] = '/test/override';
$values = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::DIRECTORY_PREFERENCES_NAME);
* Ensure that overrides in $civicrm_setting apply when
* when using retrieveDirectoryAndURLPreferences().
*/
- function testRetrieveDirectoryAndURLPreferences_Override() {
+ public function testRetrieveDirectoryAndURLPreferences_Override() {
global $civicrm_setting;
$civicrm_setting[CRM_Core_BAO_Setting::DIRECTORY_PREFERENCES_NAME]['imageUploadDir'] = '/test/override';
* 2) for current domain setting max_attachments is set to the value that $config->maxAttachments
* had (6)
* 3) for other domain (2) max_attachments is set to the configured default (3)
- *
- *
- **/
- function testConvertAndFillSettings() {
+ */
+ public function testConvertAndFillSettings() {
$settings = array('maxAttachments' => 6);
CRM_Core_BAO_ConfigSetting::add($settings);
$config = CRM_Core_Config::singleton(TRUE, TRUE);
$currentDomain = CRM_Core_Config::domainID();
// we are setting up an artificial situation here as we are trying to drive out
// previous memory of this setting so we need to flush it out
- $cachekey = CRM_Core_BAO_Setting::inCache('CiviCRM Preferences', 'max_attachments', NULL, NULL, TRUE, $currentDomain);
+ $cachekey = CRM_Core_BAO_Setting::inCache('CiviCRM Preferences', 'max_attachments', NULL, NULL, TRUE, $currentDomain);
CRM_Core_BAO_Setting::flushCache($cachekey);
CRM_Core_BAO_Setting::updateSettingsFromMetaData();
//check current domain
'version' => 3,
'name' => 'max_attachments',
'group' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
- 'domain_id' => 2
+ 'domain_id' => 2,
));
$this->assertEquals(3, $value);
* Ensure that overrides in $civicrm_setting apply when
* when using retrieveDirectoryAndURLPreferences().
*/
- function testConvertConfigToSettingNoPrefetch() {
+ public function testConvertConfigToSettingNoPrefetch() {
$settings = array('maxAttachments' => 6);
CRM_Core_BAO_ConfigSetting::add($settings);
$config = CRM_Core_Config::singleton(TRUE, TRUE);
$this->assertEmpty($maxAttachments);
}
- /*
+ /* @codingStandardsIgnoreStart
* Check that setting is converted without config value being removed
*
- function testConvertConfigToSettingPrefetch() {
+ public function testConvertConfigToSettingPrefetch() {
$settings = array('debug' => 1);
CRM_Core_BAO_ConfigSetting::add($settings);
$config = CRM_Core_Config::singleton(true, true);
$config = CRM_Core_Config::singleton(true, true);
$this->assertEmpty($config->debug);
}
- */
+ @codingStandardsIgnoreEnd */
/**
* Ensure that on_change callbacks fire.
* are very similar, but they exercise different codepaths. The first uses the API
* and setItems [plural]; the second uses setItem [singular].
*/
- function testOnChange() {
+ public function testOnChange() {
global $_testOnChange_hookCalls;
$this->setMockSettingsMetaData(array(
'onChangeExample' => array(
'is_contact' => 0,
'description' => NULL,
'help_text' => NULL,
- 'on_change' => array( // list of callbacks
- array(__CLASS__, '_testOnChange_onChangeExample')
+ 'on_change' => array(// list of callbacks
+ array(__CLASS__, '_testOnChange_onChangeExample'),
),
),
));
* @param $newValue
* @param $metadata
*/
- static function _testOnChange_onChangeExample($oldValue, $newValue, $metadata) {
+ public static function _testOnChange_onChangeExample($oldValue, $newValue, $metadata) {
global $_testOnChange_hookCalls;
$_testOnChange_hookCalls['count']++;
$_testOnChange_hookCalls['oldValue'] = $oldValue;
}
}
-