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 'saved_search_id' => '',
56 'visibility' => 'Public Pages',
57 'where_clause' => ' ( `civicrm_group_contact-1`.group_id IN ( 1 ) AND `civicrm_group_contact-1`.status IN (\"Added\") ) ',
58 '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 ) )\";}',
59 '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 ) )\";}',
60 'group_type' => array(
80 'api.group.get' => array(
88 'name' => 'Test Group 1',
89 'title' => 'New Test Group Created',
90 'description' => 'New Test Group Created',
92 'saved_search_id' => '',
94 'visibility' => 'Public Pages',
95 'where_clause' => ' ( `civicrm_group_contact-1`.group_id IN ( 1 ) AND `civicrm_group_contact-1`.status IN (\"Added\") ) ',
96 '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 ) )\";}',
97 '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 ) )\";}',
98 'group_type' => array(
103 'refresh_date' => '',
116 return $expectedResult;
121 * This example has been generated from the API test suite. The test that created it is called
123 * testGetGroupID and can be found in
124 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/GroupContactTest.php
126 * You can see the outcome of the API tests at
127 * https://test.civicrm.org/job/CiviCRM-master-git/
129 * To Learn about the API read
130 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
132 * Browse the api on your own site with the api explorer
133 * http://MYSITE.ORG/path/to/civicrm/api/explorer
135 * Read more about testing here
136 * http://wiki.civicrm.org/confluence/display/CRM/Testing
138 * API Standards documentation:
139 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards