Fix issue where a group contact record in status of pending cannot be immedately...
authorSeamus Lee <seamuslee001@gmail.com>
Tue, 7 Feb 2017 23:00:58 +0000 (10:00 +1100)
committerSeamus Lee <seamuslee001@gmail.com>
Tue, 7 Feb 2017 23:00:58 +0000 (10:00 +1100)
api/v3/GroupContact.php
tests/phpunit/api/v3/GroupContactTest.php

index 2528c827cbb4254909a6bf45aff8ef2cb7d13375..53f055e82b856ee0128c2fcc367c0c8c51a7cc14 100644 (file)
@@ -158,7 +158,7 @@ function civicrm_api3_group_contact_delete($params) {
   }
   $groupContact = civicrm_api3('GroupContact', 'get', $checkParams);
   if ($groupContact['count'] == 0 && !empty($params['skip_undelete'])) {
-    $checkParams['status'] = 'removed';
+    $checkParams['status'] = array('IN' => array('Removed', 'Pending'));
   }
   $groupContact2 = civicrm_api3('GroupContact', 'get', $checkParams);
   if ($groupContact['count'] == 0 && $groupContact2['count'] == 0) {
index c2c686871c906a88d44e147d912a234a38514b0b..39509f095ae89c0498da13887f8a1bd65432fbe6 100644 (file)
@@ -258,6 +258,31 @@ class api_v3_GroupContactTest extends CiviUnitTestCase {
     $groupContact = $this->callAPISuccess('groupContact', 'create', $groupContactCreateParams);
     $groupGetContact = $this->CallAPISuccess('groupContact', 'get', $groupContactCreateParams);
     $this->callAPISuccess('groupContact', 'delete', array('id' => $groupGetContact['id'], 'status' => 'Removed'));
+    $this->callAPISuccess('groupContact', 'delete', array('id' => $groupGetContact['id'], 'skip_undelete' => TRUE));
+    $this->callAPISuccess('group', 'delete', array('id' => $groupId3));
+  }
+
+  /**
+   * CRM-19979 test that group cotnact delete action works when contact is in status of pendin and is a permanent delete.
+   */
+  public function testPermanentDeleteWithPending() {
+    $groupId3 = $this->groupCreate(array(
+      'name' => 'Test Group 3',
+      'domain_id' => 1,
+      'title' => 'New Test Group3 Created',
+      'description' => 'New Test Group3 Created',
+      'is_active' => 1,
+      'visibility' => 'User and User Admin Only',
+    ));
+    $groupContactCreateParams = array(
+      'contact_id' => $this->_contactId,
+      'group_id' => $groupId3,
+      'status' => 'Pending',
+    );
+    $groupContact = $this->callAPISuccess('groupContact', 'create', $groupContactCreateParams);
+    $groupGetContact = $this->CallAPISuccess('groupContact', 'get', $groupContactCreateParams);
+    $this->callAPISuccess('groupContact', 'delete', array('id' => $groupGetContact['id'], 'skip_undelete' => TRUE));
+    $this->callAPISuccess('group', 'delete', array('id' => $groupId3));
   }
 
   /**