INFRA-132 - phpcbf Drupal.WhiteSpace.ScopeIndent.IncorrectExact
[civicrm-core.git] / tests / phpunit / CRM / Core / BAO / SettingTest.php
index 482c84366e6218e5a6eae21d0944cf6d758cea59..13a67d73ca1582f9ef5e7e22ffb53624e6a989df 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.5                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
@@ -23,7 +23,7 @@
  | 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';
@@ -32,32 +32,21 @@ 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');
@@ -65,7 +54,7 @@ class CRM_Core_BAO_SettingTest extends CiviUnitTestCase {
     $this->assertTrue($result);
   }
 
-  function testEnableComponentAlreadyPresent() {
+  public function testEnableComponentAlreadyPresent() {
     $config = CRM_Core_Config::singleton(TRUE, TRUE);
 
     $result = CRM_Core_BAO_ConfigSetting::enableComponent('CiviCampaign');
@@ -74,7 +63,7 @@ class CRM_Core_BAO_SettingTest extends CiviUnitTestCase {
     $this->assertTrue($result);
   }
 
-  function testEnableComponentInvalid() {
+  public function testEnableComponentInvalid() {
     $config = CRM_Core_Config::singleton(TRUE, TRUE);
 
     $result = CRM_Core_BAO_ConfigSetting::enableComponent('CiviFake');
@@ -86,7 +75,7 @@ class CRM_Core_BAO_SettingTest extends CiviUnitTestCase {
    * 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');
@@ -97,7 +86,7 @@ class CRM_Core_BAO_SettingTest extends CiviUnitTestCase {
    * 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);
@@ -108,7 +97,7 @@ class CRM_Core_BAO_SettingTest extends CiviUnitTestCase {
    * 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';
 
@@ -124,10 +113,8 @@ class CRM_Core_BAO_SettingTest extends CiviUnitTestCase {
    *  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);
@@ -142,7 +129,7 @@ class CRM_Core_BAO_SettingTest extends CiviUnitTestCase {
     $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
@@ -158,7 +145,7 @@ class CRM_Core_BAO_SettingTest extends CiviUnitTestCase {
       'version' => 3,
       'name' => 'max_attachments',
       'group' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
-      'domain_id' => 2
+      'domain_id' => 2,
     ));
 
     $this->assertEquals(3, $value);
@@ -174,7 +161,7 @@ class CRM_Core_BAO_SettingTest extends CiviUnitTestCase {
    * 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);
@@ -190,10 +177,10 @@ class CRM_Core_BAO_SettingTest extends CiviUnitTestCase {
     $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);
@@ -205,7 +192,7 @@ class CRM_Core_BAO_SettingTest extends CiviUnitTestCase {
     $config = CRM_Core_Config::singleton(true, true);
     $this->assertEmpty($config->debug);
   }
-   */
+  @codingStandardsIgnoreEnd */
 
   /**
    * Ensure that on_change callbacks fire.
@@ -214,7 +201,7 @@ class CRM_Core_BAO_SettingTest extends CiviUnitTestCase {
    * 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(
@@ -231,8 +218,8 @@ class CRM_Core_BAO_SettingTest extends CiviUnitTestCase {
         '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'),
         ),
       ),
     ));
@@ -268,7 +255,7 @@ class CRM_Core_BAO_SettingTest extends CiviUnitTestCase {
    * @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;
@@ -277,4 +264,3 @@ class CRM_Core_BAO_SettingTest extends CiviUnitTestCase {
   }
 
 }
-