Merge pull request #5536 from totten/4.5-httpclient
[civicrm-core.git] / tests / phpunit / api / v3 / OptionGroupTest.php
index add644e1321883f5cf313e4f66aefc6eec77ea7b..a84e114537317f864c6d843807d782e34c7a8e26 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';
 
@@ -35,7 +35,7 @@ class api_v3_OptionGroupTest extends CiviUnitTestCase {
 
   protected $_entity = 'OptionGroup';
 
-  function setUp() {
+  public function setUp() {
     parent::setUp();
     $this->useTransaction(TRUE);
     $this->_params = array(
@@ -45,14 +45,14 @@ class api_v3_OptionGroupTest extends CiviUnitTestCase {
     );
   }
 
-  /*
-  * Good to test option group as a representative on the Camel Case
-  */
-
+  /**
+   * Good to test option group as a representative on the Camel Case.
+   */
   public function testGetOptionGroupGetFields() {
     $result = $this->callAPISuccess('option_group', 'getfields', array());
     $this->assertFalse(empty($result['values']), 'In line ' . __LINE__);
   }
+
   public function testGetOptionGroupGetFieldsCreateAction() {
     $result = $this->callAPISuccess('option_group', 'getfields', array('action' => 'create'));
     $this->assertFalse(empty($result['values']), 'In line ' . __LINE__);
@@ -81,20 +81,34 @@ class api_v3_OptionGroupTest extends CiviUnitTestCase {
     $result = $this->callAPISuccess('option_group', 'get', array('name' => 'FSIGUBSFGOMUUBSFGMOOUUBSFGMOOBUFSGMOOIIB'));
     $this->assertEquals(0, $result['count'], 'In line ' . __LINE__);
   }
+
   public function testGetOptionCreateSuccess() {
-    $params = array('sequential' => 1, 'name' => 'civicrm_event.amount.560', 'is_reserved' => 1, 'is_active' => 1, 'api.OptionValue.create' => array('label' => 'workshop', 'value' => 35, 'is_default' => 1, 'is_active' => 1, 'format.only_id' => 1));
+    $params = array(
+      'sequential' => 1,
+      'name' => 'civicrm_event.amount.560',
+      'is_reserved' => 1,
+      'is_active' => 1,
+      'api.OptionValue.create' => array(
+        'label' => 'workshop',
+        'value' => 35,
+        'is_default' => 1,
+        'is_active' => 1,
+        'format.only_id' => 1,
+      ),
+    );
     $result = $this->callAPIAndDocument('OptionGroup', 'create', $params, __FUNCTION__, __FILE__);
     $this->assertEquals('civicrm_event.amount.560', $result['values'][0]['name'], 'In line ' . __LINE__);
-    $this->assertTrue(is_integer($result['values'][0]['api.OptionValue.create']));
+    $this->assertTrue(is_int($result['values'][0]['api.OptionValue.create']));
     $this->assertGreaterThan(0, $result['values'][0]['api.OptionValue.create']);
     $this->callAPISuccess('OptionGroup', 'delete', array('id' => $result['id']));
   }
-  /*
-   * Test the error message when a failure is due to a key duplication issue
-   */
 
+  /**
+   * Test the error message when a failure is due to a key duplication issue.
+   */
   public function testGetOptionCreateFailOnDuplicate() {
-    $params = array(      'sequential' => 1,
+    $params = array(
+      'sequential' => 1,
       'name' => 'civicrm_dup entry',
       'is_reserved' => 1,
       'is_active' => 1,
@@ -104,17 +118,18 @@ class api_v3_OptionGroupTest extends CiviUnitTestCase {
     $this->callAPISuccess('OptionGroup', 'delete', array('id' => $result1['id']));
   }
 
-  /*
+  /**
    * Test that transaction is completely rolled back on fail.
-   * Also check error returned
+   *
+   * Check error returned.
    */
-
   public function testGetOptionCreateFailRollback() {
     $countFirst = $this->callAPISuccess('OptionGroup', 'getcount', array(
-               'options' => array('limit' => 5000),
+        'options' => array('limit' => 5000),
       )
     );
-    $params = array(      'sequential' => 1,
+    $params = array(
+      'sequential' => 1,
       'name' => 'civicrm_rolback_test',
       'is_reserved' => 1,
       'is_active' => 1,
@@ -129,7 +144,7 @@ class api_v3_OptionGroupTest extends CiviUnitTestCase {
     );
     $result = $this->callAPIFailure('OptionGroup', 'create', $params);
     $countAfter = $this->callAPISuccess('OptionGroup', 'getcount', array(
-               'options' => array('limit' => 5000),
+        'options' => array('limit' => 5000),
       )
     );
     $this->assertEquals($countFirst, $countAfter,
@@ -138,7 +153,7 @@ class api_v3_OptionGroupTest extends CiviUnitTestCase {
   }
 
   /**
-   * Success test for updating an existing Option Group
+   * Success test for updating an existing Option Group.
    */
   public function testCreateUpdateOptionGroup() {
     $result = $this->callAPISuccess($this->_entity, 'create', $this->_params);
@@ -148,11 +163,11 @@ class api_v3_OptionGroupTest extends CiviUnitTestCase {
   }
 
   /**
-   * Success test for deleting an existing Option Group
+   * Success test for deleting an existing Option Group.
    */
   public function testDeleteOptionGroup() {
     $result = $this->callAPISuccess($this->_entity, 'create', $this->_params);
     $this->callAPIAndDocument('OptionGroup', 'delete', array('id' => $result['id']), __FUNCTION__, __FILE__);
   }
-}
 
+}