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