Merge pull request #5536 from totten/4.5-httpclient
[civicrm-core.git] / tests / phpunit / api / v3 / SettingTest.php
index 5978b26f94401adec0c9122be0cb8d3fea1afb3c..638655a44b4a052731c93b3411c38896345cb0a0 100644 (file)
@@ -3,7 +3,7 @@
  +--------------------------------------------------------------------+
  | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014                                |
+ | Copyright CiviCRM LLC (c) 2004-2015                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -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';
 
@@ -92,7 +92,7 @@ class api_v3_SettingTest extends CiviUnitTestCase {
 
   /**
    * /**
-   * Check getfields works
+   * Check getfields works.
    */
   public function testGetFields() {
     $description = 'Demonstrate return from getfields - see subfolder for variants';
@@ -125,7 +125,7 @@ class api_v3_SettingTest extends CiviUnitTestCase {
   }
 
   /**
-   * Test that getfields will filter on group
+   * Test that getfields will filter on group.
    */
   public function testGetFieldsGroupFilters() {
     $params = array('filters' => array('group' => 'multisite'));
@@ -169,7 +169,7 @@ class api_v3_SettingTest extends CiviUnitTestCase {
         'description' => NULL,
         'help_text' => NULL,
         'on_change' => array(// list of callbacks
-          array(__CLASS__, '_testOnChange_onChangeExample')
+          array(__CLASS__, '_testOnChange_onChangeExample'),
         ),
       ),
     ));
@@ -210,10 +210,10 @@ class api_v3_SettingTest extends CiviUnitTestCase {
   }
 
   /**
-   * Check getfields works
+   * Check getfields works.
    */
   public function testCreateSetting() {
-    $description = "shows setting a variable for a given domain - if no domain is set current is assumed";
+    $description = "Shows setting a variable for a given domain - if no domain is set current is assumed.";
 
     $params = array(
       'domain_id' => $this->_domainID2,
@@ -222,13 +222,13 @@ class api_v3_SettingTest extends CiviUnitTestCase {
     $result = $this->callAPIAndDocument('setting', 'create', $params, __FUNCTION__, __FILE__);
 
     $params = array('uniq_email_per_site' => 1);
-    $description = "shows setting a variable for a current domain";
+    $description = "Shows setting a variable for a current domain.";
     $result = $this->callAPIAndDocument('setting', 'create', $params, __FUNCTION__, __FILE__, $description, 'CreateSettingCurrentDomain');
     $this->assertArrayHasKey(CRM_Core_Config::domainID(), $result['values']);
   }
 
   /**
-   * Check getfields works
+   * Check getfields works.
    */
   public function testCreateInvalidSettings() {
     $params = array(
@@ -255,7 +255,7 @@ class api_v3_SettingTest extends CiviUnitTestCase {
   }
 
   /**
-   * Check getfields works
+   * Check getfields works.
    */
   public function testCreateInvalidBooleanSettings() {
     $params = array(
@@ -290,10 +290,10 @@ class api_v3_SettingTest extends CiviUnitTestCase {
   }
 
   /**
-   * Check getfields works
+   * Check getfields works.
    */
   public function testCreateSettingMultipleDomains() {
-    $description = "shows setting a variable for all domains";
+    $description = "Shows setting a variable for all domains.";
 
     $params = array(
       'domain_id' => 'all',
@@ -308,11 +308,11 @@ class api_v3_SettingTest extends CiviUnitTestCase {
 
     $params = array(
       'domain_id' => 'all',
-      'return' => 'uniq_email_per_site'
+      'return' => 'uniq_email_per_site',
     );
     // we'll check it with a 'get'
-    $description = "shows getting a variable for all domains";
-    $result = $this->callAPIAndDocument('setting', 'get', $params, __FUNCTION__, __FILE__, $description, 'GetAllDomains', 'Get');
+    $description = "Shows getting a variable for all domains.";
+    $result = $this->callAPIAndDocument('setting', 'get', $params, __FUNCTION__, __FILE__, $description, 'GetAllDomains');
 
     $this->assertEquals(1, $result['values'][2]['uniq_email_per_site']);
     $this->assertEquals(1, $result['values'][1]['uniq_email_per_site']);
@@ -322,7 +322,7 @@ class api_v3_SettingTest extends CiviUnitTestCase {
       'domain_id' => array(1, 3),
       'uniq_email_per_site' => 0,
     );
-    $description = "shows setting a variable for specified domains";
+    $description = "Shows setting a variable for specified domains.";
     $result = $this->callAPIAndDocument('setting', 'create', $params, __FUNCTION__, __FILE__, $description, 'CreateSpecifiedDomains');
 
     $this->assertEquals(0, $result['values'][3]['uniq_email_per_site']);
@@ -331,8 +331,8 @@ class api_v3_SettingTest extends CiviUnitTestCase {
       'domain_id' => array(1, 2),
       'return' => array('uniq_email_per_site'),
     );
-    $description = "shows getting a variable for specified domains";
-    $result = $this->callAPIAndDocument('setting', 'get', $params, __FUNCTION__, __FILE__, $description, 'GetSpecifiedDomains', 'Get');
+    $description = "Shows getting a variable for specified domains.";
+    $result = $this->callAPIAndDocument('setting', 'get', $params, __FUNCTION__, __FILE__, $description, 'GetSpecifiedDomains');
     $this->assertEquals(1, $result['values'][2]['uniq_email_per_site']);
     $this->assertEquals(0, $result['values'][1]['uniq_email_per_site']);
 
@@ -343,20 +343,20 @@ class api_v3_SettingTest extends CiviUnitTestCase {
       'domain_id' => $this->_domainID2,
       'return' => 'uniq_email_per_site',
     );
-    $description = "shows get setting a variable for a given domain - if no domain is set current is assumed";
+    $description = "Shows get setting a variable for a given domain - if no domain is set current is assumed.";
 
     $result = $this->callAPIAndDocument('setting', 'get', $params, __FUNCTION__, __FILE__);
 
     $params = array(
       'return' => 'uniq_email_per_site',
     );
-    $description = "shows getting a variable for a current domain";
+    $description = "Shows getting a variable for a current domain.";
     $result = $this->callAPIAndDocument('setting', 'get', $params, __FUNCTION__, __FILE__, $description, 'GetSettingCurrentDomain');
     $this->assertArrayHasKey(CRM_Core_Config::domainID(), $result['values']);
   }
 
   /**
-   * Check that setting defined in extension can be retrieved
+   * Check that setting defined in extension can be retrieved.
    */
   public function testGetExtensionSetting() {
     $this->hookClass->setHook('civicrm_alterSettingsFolders', array($this, 'setExtensionMetadata'));
@@ -411,12 +411,12 @@ class api_v3_SettingTest extends CiviUnitTestCase {
   public function testGetSetConfigSettingMultipleDomains() {
     $settings = $this->callAPISuccess('setting', 'create', array(
         'defaultCurrency' => 'USD',
-        'domain_id' => $this->_currentDomain
+        'domain_id' => $this->_currentDomain,
       )
     );
     $settings = $this->callAPISuccess('setting', 'create', array(
         'defaultCurrency' => 'CAD',
-        'domain_id' => $this->_domainID2
+        'domain_id' => $this->_domainID2,
       )
     );
     $settings = $this->callAPISuccess('setting', 'get', array(
@@ -431,7 +431,7 @@ class api_v3_SettingTest extends CiviUnitTestCase {
   }
 
   /**
-   * Use getValue against a config setting
+   * Use getValue against a config setting.
    */
   public function testGetValueConfigSetting() {
     $params = array(
@@ -445,21 +445,21 @@ class api_v3_SettingTest extends CiviUnitTestCase {
   public function testGetValue() {
     $params = array(
       'name' => 'petition_contacts',
-      'group' => 'Campaign Preferences'
+      'group' => 'Campaign Preferences',
     );
-    $description = "Demonstrates getvalue action - intended for runtime use as better caching than get";
+    $description = "Demonstrates getvalue action - intended for runtime use as better caching than get.";
 
     $result = $this->callAPIAndDocument('setting', 'getvalue', $params, __FUNCTION__, __FILE__, $description);
     $this->assertEquals('Petition Contacts', $result);
   }
 
   public function testGetDefaults() {
-    $description = "gets defaults setting a variable for a given domain - if no domain is set current is assumed";
+    $description = "Gets defaults setting a variable for a given domain - if no domain is set current is assumed.";
 
     $params = array(
       'name' => 'address_format',
     );
-    $result = $this->callAPIAndDocument('setting', 'getdefaults', $params, __FUNCTION__, __FILE__, $description, 'GetDefaults', 'getdefaults');
+    $result = $this->callAPIAndDocument('setting', 'getdefaults', $params, __FUNCTION__, __FILE__, $description, 'GetDefaults');
     $this->assertEquals("{contact.address_name}\n{contact.street_address}\n{contact.supplemental_address_1}\n{contact.supplemental_address_2}\n{contact.city}{, }{contact.state_province}{ }{contact.postal_code}\n{contact.country}", $result['values'][CRM_Core_Config::domainID()]['address_format']);
     $params = array('name' => 'mailing_format');
     $result = $this->callAPISuccess('setting', 'getdefaults', $params);
@@ -468,7 +468,7 @@ class api_v3_SettingTest extends CiviUnitTestCase {
   }
 
   /**
-   * Function tests reverting a specific parameter
+   * Function tests reverting a specific parameter.
    */
   public function testRevert() {
     $params = array(
@@ -478,13 +478,13 @@ class api_v3_SettingTest extends CiviUnitTestCase {
     $result = $this->callAPISuccess('setting', 'create', $params);
     $this->assertAPISuccess($result, "in line " . __LINE__);
     $revertParams = array(
-      'name' => 'address_format'
+      'name' => 'address_format',
     );
     $result = $this->callAPISuccess('setting', 'get', $params);
     //make sure it's set
     $this->assertEquals('xyz', $result['values'][CRM_Core_Config::domainID()]['address_format']);
-    $description = "Demonstrates reverting a parameter to default value";
-    $result = $this->callAPIAndDocument('setting', 'revert', $revertParams, __FUNCTION__, __FILE__, $description, '', 'revert');
+    $description = "Demonstrates reverting a parameter to default value.";
+    $result = $this->callAPIAndDocument('setting', 'revert', $revertParams, __FUNCTION__, __FILE__, $description, '');
     //make sure it's reverted
     $result = $this->callAPISuccess('setting', 'get', $params);
     $this->assertEquals("{contact.address_name}\n{contact.street_address}\n{contact.supplemental_address_1}\n{contact.supplemental_address_2}\n{contact.city}{, }{contact.state_province}{ }{contact.postal_code}\n{contact.country}", $result['values'][CRM_Core_Config::domainID()]['address_format']);
@@ -518,7 +518,7 @@ class api_v3_SettingTest extends CiviUnitTestCase {
   }
 
   /**
-   * Tests filling missing params
+   * Tests filling missing params.
    */
   public function testFill() {
     $domparams = array(
@@ -549,4 +549,5 @@ class api_v3_SettingTest extends CiviUnitTestCase {
     $this->assertArrayHasKey('extensionsDir', $result['values'][$dom['id']]);
     $this->assertEquals('Unconfirmed', $result['values'][$dom['id']]['tag_unconfirmed']);
   }
+
 }