Revert changes to test and re-generate example from better test
authorSeamus Lee <seamuslee001@gmail.com>
Thu, 23 Feb 2017 10:35:12 +0000 (21:35 +1100)
committerSeamus Lee <seamuslee001@gmail.com>
Thu, 23 Feb 2017 10:35:12 +0000 (21:35 +1100)
api/v3/examples/Contact/GetActions.php
api/v3/examples/Contact/GroupFilterUsingContactAPI.php
tests/phpunit/api/v3/ContactTest.php

index d2c85713ed1ceecc4735db3475a133f495667b2a..585e5e8dca83137190c6126b0b619d2837f1ad06 100644 (file)
@@ -40,33 +40,28 @@ function contact_getactions_expectedresult() {
   $expectedResult = array(
     'is_error' => 0,
     'version' => 3,
-    'count' => 25,
+    'count' => 20,
     'values' => array(
       '0' => 'create',
       '1' => 'delete',
       '2' => 'duplicatecheck',
-      '3' => 'example_action1',
-      '4' => 'example_action2',
-      '5' => 'get',
-      '6' => 'getactions',
-      '7' => 'getcount',
-      '8' => 'getfield',
-      '9' => 'getfields',
-      '10' => 'getlist',
-      '11' => 'getoptions',
-      '12' => 'getquick',
-      '13' => 'getrefcount',
-      '14' => 'getsingle',
-      '15' => 'getvalue',
-      '16' => 'merge',
-      '17' => 'proximity',
-      '18' => 'replace',
-      '19' => 'setvalue',
-      '20' => 'type_create',
-      '21' => 'type_delete',
-      '22' => 'type_get',
-      '23' => 'update',
-      '24' => 'validate',
+      '3' => 'get',
+      '4' => 'getactions',
+      '5' => 'getcount',
+      '6' => 'getfield',
+      '7' => 'getfields',
+      '8' => 'getlist',
+      '9' => 'getoptions',
+      '10' => 'getquick',
+      '11' => 'getrefcount',
+      '12' => 'getsingle',
+      '13' => 'getvalue',
+      '14' => 'merge',
+      '15' => 'proximity',
+      '16' => 'replace',
+      '17' => 'setvalue',
+      '18' => 'update',
+      '19' => 'validate',
     ),
     'deprecated' => array(
       'getquick' => 'The "getquick" action is deprecated in favor of "getlist".',
index 19bfee8c2330347ea884cd79a8ab64507dfe20bb..879b059fa5537f822b5fde8031a0068647f7ce9e 100644 (file)
@@ -11,11 +11,10 @@ function contact_get_example() {
   $params = array(
     'group' => array(
       'IN' => array(
-        '0' => 1,
-        '1' => 26,
+        '0' => 'Test group C',
+        '1' => 'Test group D',
       ),
     ),
-    'contact_type' => 'Individual',
   );
 
   try{
@@ -55,8 +54,8 @@ function contact_get_expectedresult() {
         'contact_id' => '3',
         'contact_type' => 'Individual',
         'contact_sub_type' => '',
-        'sort_name' => 'man2@yahoo.com',
-        'display_name' => 'man2@yahoo.com',
+        'sort_name' => 'Groupmember, Test2',
+        'display_name' => 'Test2 Groupmember',
         'do_not_email' => 0,
         'do_not_phone' => 0,
         'do_not_mail' => 0,
@@ -71,9 +70,9 @@ function contact_get_expectedresult() {
         'preferred_communication_method' => '',
         'preferred_language' => 'en_US',
         'preferred_mail_format' => 'Both',
-        'first_name' => '',
+        'first_name' => 'Test2',
         'middle_name' => '',
-        'last_name' => '',
+        'last_name' => 'Groupmember',
         'prefix_id' => '',
         'suffix_id' => '',
         'formal_title' => '',
@@ -103,7 +102,7 @@ function contact_get_expectedresult() {
         'phone_type_id' => '',
         'phone' => '',
         'email_id' => '1',
-        'email' => 'man2@yahoo.com',
+        'email' => 'test@example.org',
         'on_hold' => 0,
         'im_id' => '',
         'provider_id' => '',
@@ -127,7 +126,7 @@ function contact_get_expectedresult() {
 
 /*
 * This example has been generated from the API test suite.
-* The test that created it is called "testGetGroupIDFromContact"
+* The test that created it is called "testContactGetWithGroupTitleMultipleGroups"
 * and can be found at:
 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
 *
index d195d3f2fdbce0424bb68c907617fb4f3979fa28..15e3be87dbe308897d45ca99cca62aac314b33d9 100644 (file)
@@ -984,8 +984,6 @@ class api_v3_ContactTest extends CiviUnitTestCase {
    */
   public function testGetGroupIDFromContact() {
     $groupId = $this->groupCreate();
-    $description = "Get all from group and display contacts.";
-    $subFile = "GroupFilterUsingContactAPI";
     $params = array(
       'email' => 'man2@yahoo.com',
       'contact_type' => 'Individual',
@@ -996,46 +994,46 @@ class api_v3_ContactTest extends CiviUnitTestCase {
     $this->callAPISuccess('contact', 'create', $params);
     // testing as integer
     $params = array(
-      'group' => $groupId,
+      'filter.group_id' => $groupId,
       'contact_type' => 'Individual',
     );
-    $result = $this->callAPIAndDocument('contact', 'get', $params, __FUNCTION__, __FILE__, $description, $subFile);
+    $result = $this->callAPISuccess('contact', 'get', $params);
     $this->assertEquals(1, $result['count']);
     // group 26 doesn't exist, but we can still search contacts in it.
     $params = array(
-      'group' => 26,
+      'filter.group_id' => 26,
       'contact_type' => 'Individual',
     );
     $this->callAPISuccess('contact', 'get', $params);
     // testing as string
     $params = array(
-      'group' => array($groupId, 26),
+      'filter.group_id' => "$groupId, 26",
       'contact_type' => 'Individual',
     );
-    $result = $this->callAPIAndDocument('contact', 'get', $params, __FUNCTION__, __FILE__, $description, $subFile);
+    $result = $this->callAPISuccess('contact', 'get', $params);
     $this->assertEquals(1, $result['count']);
     $params = array(
-      'group' => array(26, 27),
+      'filter.group_id' => "26,27",
       'contact_type' => 'Individual',
     );
     $this->callAPISuccess('contact', 'get', $params);
 
     // testing as string
     $params = array(
-      'group' => array('IN' => array($groupId, 26)),
+      'filter.group_id' => array($groupId, 26),
       'contact_type' => 'Individual',
     );
-    $result = $this->callAPIAndDocument('contact', 'get', $params, __FUNCTION__, __FILE__, $description, $subFile);
+    $result = $this->callAPISuccess('contact', 'get', $params);
     $this->assertEquals(1, $result['count']);
 
     //test in conjunction with other criteria
     $params = array(
-      'group' => array($groupId, 26),
+      'filter.group_id' => array($groupId, 26),
       'contact_type' => 'Organization',
     );
     $this->callAPISuccess('contact', 'get', $params);
     $params = array(
-      'group' => array(26, 27),
+      'filter.group_id' => array(26, 27),
       'contact_type' => 'Individual',
     );
     $result = $this->callAPISuccess('contact', 'get', $params);
@@ -3219,6 +3217,8 @@ class api_v3_ContactTest extends CiviUnitTestCase {
    * contact.get group=array('IN' => array('title1', 'title2)
    */
   public function testContactGetWithGroupTitleMultipleGroups() {
+    $description = "Get all from group and display contacts.";
+    $subFile = "GroupFilterUsingContactAPI";
     // Set up a contact, asser that they were created.
     $contact_params = array(
       'contact_type' => 'Individual',
@@ -3254,6 +3254,7 @@ class api_v3_ContactTest extends CiviUnitTestCase {
     foreach ($createdGroupsIds as $id) {
       $this->assertContains((string) $id, $contact_groups);
     }
+    $contact_get2 = $this->callAPIAndDocument('contact', 'get', array('group' => array('IN' => $createdGroupTitles)), __FUNCTION__, __FILE__, $description, $subFile);
     $contact_get2 = $this->callAPISuccess('contact', 'get', array('group' => array('IN' => $createdGroupTitles), 'return' => 'group'));
     $this->assertEquals($created_contact_id, $contact_get2['id']);
     $contact_groups2 = explode(',', $contact_get2['values'][$created_contact_id]['groups']);