Add test to check if config setting is correctly retrieved
authoreileen <eileen@fuzion.co.nz>
Thu, 11 Apr 2013 11:04:17 +0000 (23:04 +1200)
committereileen <eileen@fuzion.co.nz>
Fri, 12 Apr 2013 05:40:44 +0000 (17:40 +1200)
add a bit more assertation description on test

tests/phpunit/api/v3/SettingTest.php

index 48617a58c7f7bf5b0dd5600da902995bbce50c1a..e816fc73c1f91c922f9433907fb36b765495d9a8 100644 (file)
@@ -248,7 +248,6 @@ class api_v3_SettingTest extends CiviUnitTestCase {
     $params = array('version' => $this->_apiversion,
         'domain_id' => 'all',
         'uniq_email_per_site' => 1,
-      'debug' =>1,
     );
     $result = civicrm_api('setting', 'create', $params);
     $description = "shows setting a variable for all domains";
@@ -343,12 +342,39 @@ class api_v3_SettingTest extends CiviUnitTestCase {
     $settings = civicrm_api('setting', 'get', array(
       'name' => 'defaultCurrency',
       'version' => $this->_apiversion,
-      'sequential' => 1,
-      'debug' => 1)
+      'sequential' => 1,)
     );
     $this->assertAPISuccess($settings);
     $this->assertEquals('USD', $settings['values'][0]['defaultCurrency']);
   }
+
+  /**
+   * setting api should set & fetch settings stored in config as well as those in settings table
+   */
+  function testGetSetConfigSettingMultipleDomains() {
+    $settings = civicrm_api('setting', 'create', array(
+      'defaultCurrency' => 'USD',
+      'version' => $this->_apiversion,
+      'domain_id' => $this->_currentDomain)
+    );
+    $settings = civicrm_api('setting', 'create', array(
+      'defaultCurrency' => 'CAD',
+      'version' => $this->_apiversion,
+      'domain_id' => $this->_domainID2)
+    );
+    $this->assertAPISuccess($settings);
+    $settings = civicrm_api('setting', 'get', array(
+      'return' => 'defaultCurrency',
+      'version' => $this->_apiversion,
+      'domain_id' => 'all',
+      )
+    );
+    $this->assertEquals('USD', $settings['values'][$this->_currentDomain]['defaultCurrency']);
+    $this->assertEquals('CAD', $settings['values'][$this->_domainID2]['defaultCurrency'],
+      "second domain (id {$this->_domainID2} ) should be set to CAD. First dom was {$this->_currentDomain} & was USD");
+
+  }
+
 /*
  * Use getValue against a config setting
  */