Merge pull request #4185 from samuelsov/CRM-15330
[civicrm-core.git] / tests / phpunit / api / v3 / CustomGroupTest.php
index 8d44de6980eb17e077ef0d2189e6ab2513752053..26f1509f780f5a77b3ce101981895bad8a74b91a 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';
 
@@ -31,10 +31,9 @@ require_once 'CiviTest/CiviUnitTestCase.php';
 /**
  *  Test APIv3 civicrm_custom_group* functions
  *
- *  @package CiviCRM_APIv3
- *  @subpackage API_CustomGroup
+ * @package CiviCRM_APIv3
+ * @subpackage API_CustomGroup
  */
-
 class api_v3_CustomGroupTest extends CiviUnitTestCase {
   protected $_apiversion = 3;
   protected $_entity;
@@ -42,20 +41,9 @@ class api_v3_CustomGroupTest extends CiviUnitTestCase {
 
   public $DBResetRequired = TRUE;
 
-  /**
-   * @return array
-   */
-  function get_info() {
-    return array(
-      'name' => 'Custom Group Create',
-      'description' => 'Test all Custom Group Create API methods.',
-      'group' => 'CiviCRM API Tests',
-    );
-  }
-
-  function setUp() {
-    $this->_entity     = 'CustomGroup';
-    $this->_params     = array(
+  public function setUp() {
+    $this->_entity = 'CustomGroup';
+    $this->_params = array(
       'title' => 'Test_Group_1',
       'name' => 'test_group_1',
       'extends' => 'Individual',
@@ -69,7 +57,7 @@ class api_v3_CustomGroupTest extends CiviUnitTestCase {
     parent::setUp();
   }
 
-  function tearDown() {
+  public function tearDown() {
     $tablesToTruncate = array('civicrm_custom_group', 'civicrm_custom_field');
     // true tells quickCleanup to drop any tables that might have been created in the test
     $this->quickCleanup($tablesToTruncate, TRUE);
@@ -83,7 +71,7 @@ class api_v3_CustomGroupTest extends CiviUnitTestCase {
    * code. The SyntaxConformance is capable of testing this for all entities on create
    * & delete (& it would be easy to add if not there)
    */
-  function testCustomGroupCreateNoParam() {
+  public function testCustomGroupCreateNoParam() {
     $customGroup = $this->callAPIFailure('custom_group', 'create', array(),
       'Mandatory key(s) missing from params array: title, extends'
     );
@@ -92,7 +80,7 @@ class api_v3_CustomGroupTest extends CiviUnitTestCase {
   /**
    * Check with empty array
    */
-  function testCustomGroupCreateNoExtends() {
+  public function testCustomGroupCreateNoExtends() {
     $params = array(
       'domain_id' => 1,
       'title' => 'Test_Group_1',
@@ -113,7 +101,7 @@ class api_v3_CustomGroupTest extends CiviUnitTestCase {
   /**
    * Check with empty array
    */
-  function testCustomGroupCreateInvalidExtends() {
+  public function testCustomGroupCreateInvalidExtends() {
     $params = array(
       'domain_id' => 1,
       'title' => 'Test_Group_1',
@@ -134,7 +122,7 @@ class api_v3_CustomGroupTest extends CiviUnitTestCase {
   /**
    * Check with a string instead of array for extends
    */
-  function testCustomGroupCreateExtendsString() {
+  public function testCustomGroupCreateExtendsString() {
     $params = array(
       'domain_id' => 1,
       'title' => 'Test_Group_1',
@@ -154,7 +142,7 @@ class api_v3_CustomGroupTest extends CiviUnitTestCase {
   /**
    * Check with valid array
    */
-  function testCustomGroupCreate() {
+  public function testCustomGroupCreate() {
     $params = array(
       'title' => 'Test_Group_1',
       'name' => 'test_group_1',
@@ -175,7 +163,7 @@ class api_v3_CustomGroupTest extends CiviUnitTestCase {
   /**
    * Check with valid array
    */
-  function testCustomGroupGetFields() {
+  public function testCustomGroupGetFields() {
     $params = array(
       'options' => array('get_options' => 'style'),
     );
@@ -192,7 +180,7 @@ class api_v3_CustomGroupTest extends CiviUnitTestCase {
   /**
    * Check with extends array length greater than 1
    */
-  function testCustomGroupExtendsMultipleCreate() {
+  public function testCustomGroupExtendsMultipleCreate() {
     $params = array(
       'title' => 'Test_Group_1',
       'name' => 'test_group_1',
@@ -206,13 +194,13 @@ class api_v3_CustomGroupTest extends CiviUnitTestCase {
     );
 
     $result = $this->callAPIFailure('custom_group', 'create', $params,
-    'implode(): Invalid arguments passed');
+      'implode(): Invalid arguments passed');
   }
 
   /**
    * Check with style missing from params array
    */
-  function testCustomGroupCreateNoStyle() {
+  public function testCustomGroupCreateNoStyle() {
     $params = array(
       'title' => 'Test_Group_1',
       'name' => 'test_group_1',
@@ -232,7 +220,7 @@ class api_v3_CustomGroupTest extends CiviUnitTestCase {
   /**
    * Check with not array
    */
-  function testCustomGroupCreateNotArray() {
+  public function testCustomGroupCreateNotArray() {
     $params = NULL;
     $customGroup = $this->callAPIFailure('custom_group', 'create', $params);
     $this->assertEquals($customGroup['error_message'], 'Input variable `params` is not an array', 'In line ' . __LINE__);
@@ -241,8 +229,9 @@ class api_v3_CustomGroupTest extends CiviUnitTestCase {
   /**
    * Check without title
    */
-  function testCustomGroupCreateNoTitle() {
-    $params = array('extends' => array('Contact'),
+  public function testCustomGroupCreateNoTitle() {
+    $params = array(
+      'extends' => array('Contact'),
       'weight' => 5,
       'collapse_display' => 1,
       'style' => 'Tab',
@@ -257,7 +246,7 @@ class api_v3_CustomGroupTest extends CiviUnitTestCase {
   /**
    * Check for household without weight
    */
-  function testCustomGroupCreateHouseholdNoWeight() {
+  public function testCustomGroupCreateHouseholdNoWeight() {
     $params = array(
       'title' => 'Test_Group_3',
       'name' => 'test_group_3',
@@ -278,7 +267,7 @@ class api_v3_CustomGroupTest extends CiviUnitTestCase {
   /**
    * Check for Contribution Donation
    */
-  function testCustomGroupCreateContributionDonation() {
+  public function testCustomGroupCreateContributionDonation() {
     $params = array(
       'title' => 'Test_Group_6',
       'name' => 'test_group_6',
@@ -299,7 +288,7 @@ class api_v3_CustomGroupTest extends CiviUnitTestCase {
   /**
    * Check with valid array
    */
-  function testCustomGroupCreateGroup() {
+  public function testCustomGroupCreateGroup() {
     $params = array(
       'domain_id' => 1,
       'title' => 'Test_Group_8',
@@ -321,7 +310,7 @@ class api_v3_CustomGroupTest extends CiviUnitTestCase {
   /**
    * Check with Activity - Meeting Type
    */
-  function testCustomGroupCreateActivityMeeting() {
+  public function testCustomGroupCreateActivityMeeting() {
     $params = array(
       'title' => 'Test_Group_10',
       'name' => 'test_group_10',
@@ -343,7 +332,7 @@ class api_v3_CustomGroupTest extends CiviUnitTestCase {
   /**
    * Check without GroupID
    */
-  function testCustomGroupDeleteWithoutGroupID() {
+  public function testCustomGroupDeleteWithoutGroupID() {
     $customGroup = $this->callAPIFailure('custom_group', 'delete', array());
     $this->assertEquals($customGroup['error_message'], 'Mandatory key(s) missing from params array: id', 'In line ' . __LINE__);
   }
@@ -351,7 +340,7 @@ class api_v3_CustomGroupTest extends CiviUnitTestCase {
   /**
    * Check with no array
    */
-  function testCustomGroupDeleteNoArray() {
+  public function testCustomGroupDeleteNoArray() {
     $params = NULL;
     $customGroup = $this->callAPIFailure('custom_group', 'delete', $params);
     $this->assertEquals($customGroup['error_message'], 'Input variable `params` is not an array', 'In line ' . __LINE__);
@@ -360,7 +349,7 @@ class api_v3_CustomGroupTest extends CiviUnitTestCase {
   /**
    * Check with valid custom group id
    */
-  function testCustomGroupDelete() {
+  public function testCustomGroupDelete() {
     $customGroup = $this->customGroupCreate(array('extends' => 'Individual', 'title' => 'test_group'));
     $params = array(
       'id' => $customGroup['id'],
@@ -385,5 +374,5 @@ class api_v3_CustomGroupTest extends CiviUnitTestCase {
       $this->assertEquals($value, $values[$key], $key . " doesn't match " . print_r($values, TRUE) . 'in line' . __LINE__);
     }
   }
-}
 
+}