3 * Test Generated example of using group_contact get API
4 * Get all from group and display contacts *
6 function group_contact_get_example(){
14 $result = civicrm_api3('group_contact', 'get', $params);
16 catch (CiviCRM_API3_Exception
$e) {
18 $errorMessage = $e->getMessage();
19 $errorCode = $e->getErrorCode();
20 $errorData = $e->getExtraParams();
21 return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
28 * Function returns array of result expected from previous function
30 function group_contact_get_expectedresult(){
32 $expectedResult = array(
42 'api.group.get' => array(
50 'name' => 'Test Group 1',
51 'title' => 'New Test Group Created',
52 'description' => 'New Test Group Created',
54 'visibility' => 'Public Pages',
55 'where_clause' => ' ( `civicrm_group_contact-1`.group_id IN ( 1 ) AND `civicrm_group_contact-1`.status IN (\"Added\") ) ',
56 'select_tables' => 'a:8:{s:15:\"civicrm_contact\";i:1;s:15:\"civicrm_address\";i:1;s:15:\"civicrm_country\";i:1;s:13:\"civicrm_email\";i:1;s:13:\"civicrm_phone\";i:1;s:10:\"civicrm_im\";i:1;s:19:\"civicrm_worldregion\";i:1;s:25:\"`civicrm_group_contact-1`\";s:165:\" LEFT JOIN civicrm_group_contact `civicrm_group_contact-1` ON ( contact_a.id = `civicrm_group_contact-1`.contact_id AND `civicrm_group_contact-1`.group_id IN ( 1 ) )\";}',
57 'where_tables' => 'a:2:{s:15:\"civicrm_contact\";i:1;s:25:\"`civicrm_group_contact-1`\";s:165:\" LEFT JOIN civicrm_group_contact `civicrm_group_contact-1` ON ( contact_a.id = `civicrm_group_contact-1`.contact_id AND `civicrm_group_contact-1`.group_id IN ( 1 ) )\";}',
58 'group_type' => array(
73 'api.group.get' => array(
81 'name' => 'Test Group 1',
82 'title' => 'New Test Group Created',
83 'description' => 'New Test Group Created',
85 'visibility' => 'Public Pages',
86 'where_clause' => ' ( `civicrm_group_contact-1`.group_id IN ( 1 ) AND `civicrm_group_contact-1`.status IN (\"Added\") ) ',
87 'select_tables' => 'a:8:{s:15:\"civicrm_contact\";i:1;s:15:\"civicrm_address\";i:1;s:15:\"civicrm_country\";i:1;s:13:\"civicrm_email\";i:1;s:13:\"civicrm_phone\";i:1;s:10:\"civicrm_im\";i:1;s:19:\"civicrm_worldregion\";i:1;s:25:\"`civicrm_group_contact-1`\";s:165:\" LEFT JOIN civicrm_group_contact `civicrm_group_contact-1` ON ( contact_a.id = `civicrm_group_contact-1`.contact_id AND `civicrm_group_contact-1`.group_id IN ( 1 ) )\";}',
88 'where_tables' => 'a:2:{s:15:\"civicrm_contact\";i:1;s:25:\"`civicrm_group_contact-1`\";s:165:\" LEFT JOIN civicrm_group_contact `civicrm_group_contact-1` ON ( contact_a.id = `civicrm_group_contact-1`.contact_id AND `civicrm_group_contact-1`.group_id IN ( 1 ) )\";}',
89 'group_type' => array(
102 return $expectedResult;
107 * This example has been generated from the API test suite. The test that created it is called
109 * testGetGroupID and can be found in
110 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/GroupContactTest.php
112 * You can see the outcome of the API tests at
113 * https://test.civicrm.org/job/CiviCRM-master-git/
115 * To Learn about the API read
116 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
118 * Browse the api on your own site with the api explorer
119 * http://MYSITE.ORG/path/to/civicrm/api/explorer
121 * Read more about testing here
122 * http://wiki.civicrm.org/confluence/display/CRM/Testing
124 * API Standards documentation:
125 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards