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_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:9:{s:15:"civicrm_contact";i:1;s:15:"civicrm_address";i:1;s:22:"civicrm_state_province";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:114:" LEFT JOIN civicrm_group_contact `civicrm_group_contact-1` ON contact_a.id = `civicrm_group_contact-1`.contact_id ";}',
59 'where_tables' => 'a:2:{s:15:"civicrm_contact";i:1;s:25:"`civicrm_group_contact-1`";s:114:" LEFT JOIN civicrm_group_contact `civicrm_group_contact-1` ON contact_a.id = `civicrm_group_contact-1`.contact_id ";}',
60 'group_type' => array(
80 'api.group.get' => array(
88 'name' => 'Test Group 1_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:9:{s:15:"civicrm_contact";i:1;s:15:"civicrm_address";i:1;s:22:"civicrm_state_province";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:114:" LEFT JOIN civicrm_group_contact `civicrm_group_contact-1` ON contact_a.id = `civicrm_group_contact-1`.contact_id ";}',
97 'where_tables' => 'a:2:{s:15:"civicrm_contact";i:1;s:25:"`civicrm_group_contact-1`";s:114:" LEFT JOIN civicrm_group_contact `civicrm_group_contact-1` ON contact_a.id = `civicrm_group_contact-1`.contact_id ";}',
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 * http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/GroupContactTest.php
126 * You can see the outcome of the API tests at
127 * http://tests.dev.civicrm.org/trunk/results-api_v3
129 * To Learn about the API read
130 * http://book.civicrm.org/developer/current/techniques/api/
132 * and review the wiki at
133 * http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
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