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