Merge remote-tracking branch 'upstream/4.5' into 4.5-4.6-2015-03-16-17-24-33
[civicrm-core.git] / api / v3 / examples / Group / Get.php
CommitLineData
6a488035 1<?php
50fb255d 2/**
a828d7b8 3 * Test Generated example demonstrating the Group.get API.
50fb255d 4 *
50fb255d 5 * @return array
6 * API result array
7 */
8function group_get_example() {
9 $params = array(
10 'name' => 'Test Group 1',
11 );
6a488035 12
50fb255d 13 try{
a828d7b8 14 $result = civicrm_api3('Group', 'get', $params);
50fb255d 15 }
16 catch (CiviCRM_API3_Exception $e) {
17 // Handle error here.
18 $errorMessage = $e->getMessage();
19 $errorCode = $e->getErrorCode();
20 $errorData = $e->getExtraParams();
21 return array(
22 'error' => $errorMessage,
23 'error_code' => $errorCode,
24 'error_data' => $errorData,
25 );
26 }
27
28 return $result;
6a488035
TO
29}
30
fb32de45 31/**
50fb255d 32 * Function returns array of result expected from previous function.
33 *
34 * @return array
35 * API result array
6a488035 36 */
50fb255d 37function group_get_expectedresult() {
6a488035 38
53ca8fd7 39 $expectedResult = array(
50fb255d 40 'is_error' => 0,
41 'version' => 3,
42 'count' => 1,
43 'id' => 4,
44 'values' => array(
fb32de45 45 '4' => array(
50fb255d 46 'id' => '4',
47 'name' => 'Test Group 1',
48 'title' => 'New Test Group Created',
49 'description' => 'New Test Group Created',
50 'is_active' => '1',
51 'visibility' => 'Public Pages',
52 'where_clause' => ' ( `civicrm_group_contact-4`.group_id IN ( 4 ) AND `civicrm_group_contact-4`.status IN (\"Added\") ) ',
53 '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-4`\";s:165:\" LEFT JOIN civicrm_group_contact `civicrm_group_contact-4` ON ( contact_a.id = `civicrm_group_contact-4`.contact_id AND `civicrm_group_contact-4`.group_id IN ( 4 ) )\";}',
54 'where_tables' => 'a:2:{s:15:\"civicrm_contact\";i:1;s:25:\"`civicrm_group_contact-4`\";s:165:\" LEFT JOIN civicrm_group_contact `civicrm_group_contact-4` ON ( contact_a.id = `civicrm_group_contact-4`.contact_id AND `civicrm_group_contact-4`.group_id IN ( 4 ) )\";}',
55 'group_type' => array(
56 '0' => '1',
57 '1' => '2',
6a488035 58 ),
50fb255d 59 'is_hidden' => 0,
60 'is_reserved' => 0,
61 ),
6a488035 62 ),
50fb255d 63 );
6a488035 64
fb32de45 65 return $expectedResult;
6a488035
TO
66}
67
a828d7b8 68/*
50fb255d 69* This example has been generated from the API test suite.
a828d7b8
CW
70* The test that created it is called "testGetGroupParamsWithGroupName"
71* and can be found at:
69d79249 72* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/GroupTest.php
6a488035
TO
73*
74* You can see the outcome of the API tests at
69d79249 75* https://test.civicrm.org/job/CiviCRM-master-git/
6a488035
TO
76*
77* To Learn about the API read
69d79249 78* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
6a488035 79*
69d79249 80* Browse the api on your own site with the api explorer
41d4d31f 81* http://MYSITE.ORG/path/to/civicrm/api
6a488035
TO
82*
83* Read more about testing here
84* http://wiki.civicrm.org/confluence/display/CRM/Testing
85*
86* API Standards documentation:
87* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
b259a4ab 88*/