Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
50fb255d | 2 | /** |
a828d7b8 | 3 | * Test Generated example demonstrating the ActivityType.create API. |
50fb255d | 4 | * |
a6ec24c4 | 5 | * @deprecated |
a828d7b8 | 6 | * The ActivityType api is deprecated. Please use the OptionValue api instead. |
50fb255d | 7 | * |
8 | * @return array | |
9 | * API result array | |
10 | */ | |
11 | function activity_type_create_example() { | |
12 | $params = array( | |
13 | 'weight' => '2', | |
14 | 'label' => 'send out letters', | |
15 | 'filter' => 0, | |
16 | 'is_active' => 1, | |
17 | 'is_optgroup' => 1, | |
18 | 'is_default' => 0, | |
19 | ); | |
6a488035 | 20 | |
50fb255d | 21 | try{ |
a828d7b8 | 22 | $result = civicrm_api3('ActivityType', 'create', $params); |
50fb255d | 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( | |
5be22f39 | 30 | 'is_error' => 1, |
31 | 'error_message' => $errorMessage, | |
50fb255d | 32 | 'error_code' => $errorCode, |
33 | 'error_data' => $errorData, | |
34 | ); | |
35 | } | |
36 | ||
37 | return $result; | |
6a488035 TO |
38 | } |
39 | ||
fb32de45 | 40 | /** |
50fb255d | 41 | * Function returns array of result expected from previous function. |
42 | * | |
43 | * @return array | |
44 | * API result array | |
6a488035 | 45 | */ |
50fb255d | 46 | function activity_type_create_expectedresult() { |
6a488035 | 47 | |
edb0d67a | 48 | $expectedResult = array( |
50fb255d | 49 | 'is_error' => 0, |
50 | 'version' => 3, | |
51 | 'count' => 1, | |
1d8ee3d6 | 52 | 'id' => 849, |
50fb255d | 53 | 'values' => array( |
1d8ee3d6 | 54 | '849' => array( |
55 | 'id' => '849', | |
50fb255d | 56 | 'option_group_id' => '2', |
57 | 'label' => 'send out letters', | |
1d8ee3d6 | 58 | 'value' => '55', |
50fb255d | 59 | 'name' => 'send out letters', |
60 | 'grouping' => '', | |
61 | 'filter' => 0, | |
62 | 'is_default' => 0, | |
63 | 'weight' => '2', | |
64 | 'description' => '', | |
65 | 'is_optgroup' => '1', | |
66 | 'is_reserved' => '', | |
67 | 'is_active' => '1', | |
68 | 'component_id' => '', | |
69 | 'domain_id' => '', | |
70 | 'visibility_id' => '', | |
1d8ee3d6 | 71 | 'icon' => '', |
72 | 'color' => '', | |
50fb255d | 73 | ), |
6a488035 | 74 | ), |
a828d7b8 | 75 | 'deprecated' => 'The ActivityType api is deprecated. Please use the OptionValue api instead.', |
50fb255d | 76 | ); |
6a488035 | 77 | |
fb32de45 | 78 | return $expectedResult; |
6a488035 TO |
79 | } |
80 | ||
a828d7b8 | 81 | /* |
50fb255d | 82 | * This example has been generated from the API test suite. |
a828d7b8 CW |
83 | * The test that created it is called "testActivityTypeCreate" |
84 | * and can be found at: | |
69d79249 | 85 | * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ActivityTypeTest.php |
6a488035 TO |
86 | * |
87 | * You can see the outcome of the API tests at | |
69d79249 | 88 | * https://test.civicrm.org/job/CiviCRM-master-git/ |
6a488035 TO |
89 | * |
90 | * To Learn about the API read | |
69d79249 | 91 | * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API |
6a488035 | 92 | * |
69d79249 | 93 | * Browse the api on your own site with the api explorer |
41d4d31f | 94 | * http://MYSITE.ORG/path/to/civicrm/api |
6a488035 TO |
95 | * |
96 | * Read more about testing here | |
97 | * http://wiki.civicrm.org/confluence/display/CRM/Testing | |
98 | * | |
99 | * API Standards documentation: | |
100 | * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards | |
b259a4ab | 101 | */ |