noisier
authordemeritcowboy <demeritcowboy@hotmail.com>
Sun, 26 Sep 2021 14:19:19 +0000 (10:19 -0400)
committerdemeritcowboy <demeritcowboy@hotmail.com>
Sun, 26 Sep 2021 20:31:17 +0000 (16:31 -0400)
CRM/Core/BAO/Setting.php
tests/phpunit/CRM/Core/BAO/SettingTest.php

index 2329a21acbcaae73697b007c7d3bc17144190703..e4c14859e066ce4339bac61208becf1098fb94e2 100644 (file)
@@ -75,13 +75,13 @@ class CRM_Core_BAO_Setting extends CRM_Core_DAO_Setting {
     $manager = \Civi::service('settings_manager');
     $settings = ($contactID === NULL) ? $manager->getBagByDomain($domainID) : $manager->getBagByContact($domainID, $contactID);
     if ($name === NULL) {
-      CRM_Core_Error::debug_log_message("Deprecated: Group='$group'. Name should be provided.\n");
+      CRM_Core_Error::deprecatedWarning("Deprecated: Group='$group'. Name should be provided.\n");
     }
     if ($componentID !== NULL) {
-      CRM_Core_Error::debug_log_message("Deprecated: Group='$group'. Name='$name'. Component should be omitted\n");
+      CRM_Core_Error::deprecatedWarning("Deprecated: Group='$group'. Name='$name'. Component should be omitted\n");
     }
     if ($defaultValue !== NULL) {
-      CRM_Core_Error::debug_log_message("Deprecated: Group='$group'. Name='$name'. Defaults should come from metadata\n");
+      CRM_Core_Error::deprecatedWarning("Deprecated: Group='$group'. Name='$name'. Defaults should come from metadata\n");
     }
     return $name ? $settings->get($name) : $settings->all();
   }
index 33162f5b5ecbca7c69c2e3c519666748263ad2fc..3aecff7247474661eedcb4e2e884def2ca82e923 100644 (file)
@@ -121,41 +121,25 @@ class CRM_Core_BAO_SettingTest extends CiviUnitTestCase {
     global $civicrm_setting;
     $civicrm_setting[CRM_Core_BAO_Setting::DIRECTORY_PREFERENCES_NAME]['imageUploadDir'] = '/test/override';
     Civi::service('settings_manager')->useMandatory();
-    $value = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::DIRECTORY_PREFERENCES_NAME, 'imageUploadDir');
+    $value = Civi::settings()->get('imageUploadDir');
     $this->assertEquals('/test/override', $value);
 
+    $civicrm_setting['domain']['customCSSURL'] = 'http://test.test/overridedomain';
+    Civi::service('settings_manager')->useMandatory();
+    $value = Civi::settings()->get('customCSSURL');
+    $this->assertEquals('http://test.test/overridedomain', $value);
+
     // CRM-14974 test suite
     $civicrm_setting['Test Preferences']['overrideSetting'] = '/test/override';
     Civi::service('settings_manager')->useMandatory();
-    $values = CRM_Core_BAO_Setting::getItem('Test Preferences');
-    $this->assertEquals('/test/override', $values['overrideSetting']);
-    Civi::settings()->set('databaseSetting', '/test/database');
-    $values = CRM_Core_BAO_Setting::getItem('Test Preferences');
-    $this->assertEquals('/test/override', $values['overrideSetting']);
-    $this->assertEquals('/test/database', $values['databaseSetting']);
-    $civicrm_setting['Test Preferences']['databaseSetting'] = '/test/dataride';
-    Civi::service('settings_manager')->useMandatory();
-    $values = CRM_Core_BAO_Setting::getItem('Test Preferences');
-    $this->assertEquals('/test/override', $values['overrideSetting']);
-    $this->assertEquals('/test/dataride', $values['databaseSetting']);
+    $value = Civi::settings()->get('overrideSetting');
+    $this->assertEquals('/test/override', $value);
     // CRM-14974 tear down
     unset($civicrm_setting['Test Preferences']);
-    $query = "DELETE FROM civicrm_setting WHERE name IN ('overrideSetting', 'databaseSetting');";
+    $query = "DELETE FROM civicrm_setting WHERE name = 'overrideSetting'";
     CRM_Core_DAO::executeQuery($query);
   }
 
-  /**
-   * Ensure that overrides in $civicrm_setting apply when
-   * using getItem($group).
-   */
-  public function testGetItemGroup_Override() {
-    global $civicrm_setting;
-    $civicrm_setting[CRM_Core_BAO_Setting::DIRECTORY_PREFERENCES_NAME]['imageUploadDir'] = '/test/override';
-    Civi::service('settings_manager')->useMandatory();
-    $values = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::DIRECTORY_PREFERENCES_NAME);
-    $this->assertEquals('/test/override', $values['imageUploadDir']);
-  }
-
   public function testDefaults() {
     CRM_Core_DAO::executeQuery('DELETE FROM civicrm_setting WHERE name = "max_attachments"');
     Civi::service('settings_manager')->flush();