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