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