Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
fb32de45 | 2 | /** |
3 | * Test Generated example of using custom_group create API | |
4 | * * | |
6a488035 TO |
5 | */ |
6 | function 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 | 21 | try{ |
22 | $result = civicrm_api3('custom_group', 'create', $params); | |
23 | } | |
24 | catch (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 | 32 | return $result; |
6a488035 TO |
33 | } |
34 | ||
fb32de45 | 35 | /** |
6a488035 TO |
36 | * Function returns array of result expected from previous function |
37 | */ | |
38 | function 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 | |
79 | * http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/CustomGroupTest.php | |
80 | * | |
81 | * You can see the outcome of the API tests at | |
82 | * http://tests.dev.civicrm.org/trunk/results-api_v3 | |
83 | * | |
84 | * To Learn about the API read | |
85 | * http://book.civicrm.org/developer/current/techniques/api/ | |
86 | * | |
87 | * and review the wiki at | |
88 | * http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs | |
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 | |
95 | */ |