Merge pull request #11086 from agileware/CRM-21277
[civicrm-core.git] / tests / phpunit / api / v3 / SettingTest.php
index 5727487e15b8bcd93df2a8daf00b32f0311dc07c..3ba00895887ddf7a3fa219810c2b88b4f675a35d 100644 (file)
@@ -3,7 +3,7 @@
  +--------------------------------------------------------------------+
  | CiviCRM version 4.7                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2017                                |
+ | Copyright CiviCRM LLC (c) 2004-2018                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -527,4 +527,27 @@ class api_v3_SettingTest extends CiviUnitTestCase {
     $this->assertEquals('Unconfirmed', $result['values'][$dom['id']]['tag_unconfirmed']);
   }
 
+  /**
+   * Test to set isProductionEnvironment
+   *
+   */
+  public function testSetCivicrmEnvironment() {
+    $params = array(
+      'environment' => 'Staging',
+    );
+    $result = $this->callAPISuccess('Setting', 'create', $params);
+    $params = array(
+      'name' => 'environment',
+      'group' => 'Developer Preferences',
+    );
+    $result = $this->callAPISuccess('Setting', 'getvalue', $params);
+    $this->assertEquals('Staging', $result);
+
+    global $civicrm_setting;
+    $civicrm_setting[CRM_Core_BAO_Setting::DEVELOPER_PREFERENCES_NAME]['environment'] = 'Production';
+    Civi::service('settings_manager')->useMandatory();
+    $result = $this->callAPISuccess('Setting', 'getvalue', $params);
+    $this->assertEquals('Production', $result);
+  }
+
 }