Merge branch 4.5 into master
[civicrm-core.git] / api / v3 / examples / CustomGroup / Get.php
1 <?php
2 /**
3 * @file
4 * Test Generated API Example.
5 * See bottom of this file for more detail.
6 */
7
8 /**
9 * Test Generated example of using custom_group get API.
10 *
11 *
12 * @return array
13 * API result array
14 */
15 function custom_group_get_example() {
16 $params = array();
17
18 try{
19 $result = civicrm_api3('custom_group', 'get', $params);
20 }
21 catch (CiviCRM_API3_Exception $e) {
22 // Handle error here.
23 $errorMessage = $e->getMessage();
24 $errorCode = $e->getErrorCode();
25 $errorData = $e->getExtraParams();
26 return array(
27 'error' => $errorMessage,
28 'error_code' => $errorCode,
29 'error_data' => $errorData,
30 );
31 }
32
33 return $result;
34 }
35
36 /**
37 * Function returns array of result expected from previous function.
38 *
39 * @return array
40 * API result array
41 */
42 function custom_group_get_expectedresult() {
43
44 $expectedResult = array(
45 'is_error' => 0,
46 'version' => 3,
47 'count' => 1,
48 'id' => 1,
49 'values' => array(
50 '1' => array(
51 'id' => '1',
52 'name' => 'test_group_1',
53 'title' => 'Test_Group_1',
54 'extends' => 'Individual',
55 'style' => 'Inline',
56 'collapse_display' => '1',
57 'help_pre' => 'This is Pre Help For Test Group 1',
58 'help_post' => 'This is Post Help For Test Group 1',
59 'weight' => '2',
60 'is_active' => '1',
61 'table_name' => 'civicrm_value_test_group_1_1',
62 'is_multiple' => 0,
63 'collapse_adv_display' => 0,
64 'is_reserved' => 0,
65 ),
66 ),
67 );
68
69 return $expectedResult;
70 }
71
72 /**
73 * This example has been generated from the API test suite.
74 * The test that created it is called
75 * testGetCustomGroupSuccess
76 * and can be found in
77 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/CustomGroupTest.php
78 *
79 * You can see the outcome of the API tests at
80 * https://test.civicrm.org/job/CiviCRM-master-git/
81 *
82 * To Learn about the API read
83 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
84 *
85 * Browse the api on your own site with the api explorer
86 * http://MYSITE.ORG/path/to/civicrm/api/explorer
87 *
88 * Read more about testing here
89 * http://wiki.civicrm.org/confluence/display/CRM/Testing
90 *
91 * API Standards documentation:
92 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
93 */