CRM-18591: add test
authoryashodha <yashodha.chaku@webaccessglobal.com>
Fri, 22 Jul 2016 07:24:11 +0000 (12:54 +0530)
committeryashodha <yashodha.chaku@webaccessglobal.com>
Fri, 22 Jul 2016 07:24:11 +0000 (12:54 +0530)
----------------------------------------
* CRM-18591: group_type parameter ignored when using API to create group
  https://issues.civicrm.org/jira/browse/CRM-18591

tests/phpunit/api/v3/GroupTest.php

index 90846bd835ad12fa0366814c309fddc6282daaf0..d668e3e366a4762bc7c5df2d28fb3fd291e09e74 100644 (file)
@@ -127,6 +127,33 @@ class api_v3_GroupTest extends CiviUnitTestCase {
     }
   }
 
+  /**
+   * Test Group create with Group Type
+   */
+  public function testgroupCreateWithGroupType() {
+    $params = array(
+      'name' => 'Test Group type',
+      'title' => 'Test Group Type',
+      'description' => 'Test Group with Group Type',
+      'is_active' => 1,
+      'visibility' => 'Public Pages',
+      'group_type' => array(1, 2),
+    );
+
+    $result = $this->callAPISuccess('Group', 'create', $params);
+    $group = $result['values'][$result['id']];
+    $this->assertEquals($group['name'], "Test Group type");
+    $this->assertEquals($group['is_active'], 1);
+    $this->assertEquals($group['group_type'], $params['group_type']);
+    $this->groupDelete($result['id']);
+
+    //assert single value for group_type
+    $params['group_type'] = 2;
+    $result = $this->callAPISuccess('Group', 'create', $params);
+    $group = $result["values"][$result['id']];
+    $this->assertEquals($group['group_type'], array($params['group_type']));
+  }
+
   public function testGetNonExistingGroup() {
     $params = array();
     $params['title'] = 'No such group Exist';