Reorganize and update api examples
[civicrm-core.git] / api / v3 / examples / CustomGroupGet.php
CommitLineData
6a488035 1<?php
fb32de45 2/**
3 * Test Generated example of using custom_group get API
4 * *
6a488035
TO
5 */
6function custom_group_get_example(){
fb32de45 7$params = array();
6a488035 8
fb32de45 9try{
10 $result = civicrm_api3('custom_group', 'get', $params);
11}
12catch (CiviCRM_API3_Exception $e) {
13 // handle error here
14 $errorMessage = $e->getMessage();
15 $errorCode = $e->getErrorCode();
16 $errorData = $e->getExtraParams();
17 return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
18}
6a488035 19
fb32de45 20return $result;
6a488035
TO
21}
22
fb32de45 23/**
6a488035
TO
24 * Function returns array of result expected from previous function
25 */
26function custom_group_get_expectedresult(){
27
53ca8fd7 28 $expectedResult = array(
6a488035
TO
29 'is_error' => 0,
30 'version' => 3,
31 'count' => 1,
32 'id' => 1,
53ca8fd7 33 'values' => array(
34 '1' => array(
6a488035
TO
35 'id' => '1',
36 'name' => 'test_group_1',
37 'title' => 'Test_Group_1',
38 'extends' => 'Individual',
39 'style' => 'Inline',
40 'collapse_display' => '1',
41 'help_pre' => 'This is Pre Help For Test Group 1',
42 'help_post' => 'This is Post Help For Test Group 1',
43 'weight' => '2',
44 'is_active' => '1',
45 'table_name' => 'civicrm_value_test_group_1_1',
46 'is_multiple' => 0,
47 'collapse_adv_display' => 0,
fb32de45 48 'is_reserved' => 0,
6a488035
TO
49 ),
50 ),
51);
52
fb32de45 53 return $expectedResult;
6a488035
TO
54}
55
56
57/*
58* This example has been generated from the API test suite. The test that created it is called
59*
60* testGetCustomGroupSuccess and can be found in
61* http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/CustomGroupTest.php
62*
63* You can see the outcome of the API tests at
64* http://tests.dev.civicrm.org/trunk/results-api_v3
65*
66* To Learn about the API read
67* http://book.civicrm.org/developer/current/techniques/api/
68*
69* and review the wiki at
70* http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
71*
72* Read more about testing here
73* http://wiki.civicrm.org/confluence/display/CRM/Testing
74*
75* API Standards documentation:
76* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
b259a4ab 77*/