Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
fb32de45 | 2 | /** |
3 | * Test Generated example of using activity_type create API | |
4 | * * | |
6a488035 TO |
5 | */ |
6 | function activity_type_create_example(){ | |
edb0d67a | 7 | $params = array( |
6a488035 TO |
8 | 'weight' => '2', |
9 | 'label' => 'send out letters', | |
6a488035 TO |
10 | 'filter' => 0, |
11 | 'is_active' => 1, | |
12 | 'is_optgroup' => 1, | |
13 | 'is_default' => 0, | |
14 | ); | |
15 | ||
fb32de45 | 16 | try{ |
17 | $result = civicrm_api3('activity_type', 'create', $params); | |
18 | } | |
19 | catch (CiviCRM_API3_Exception $e) { | |
20 | // handle error here | |
21 | $errorMessage = $e->getMessage(); | |
22 | $errorCode = $e->getErrorCode(); | |
23 | $errorData = $e->getExtraParams(); | |
24 | return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData); | |
25 | } | |
6a488035 | 26 | |
fb32de45 | 27 | return $result; |
6a488035 TO |
28 | } |
29 | ||
fb32de45 | 30 | /** |
6a488035 TO |
31 | * Function returns array of result expected from previous function |
32 | */ | |
33 | function activity_type_create_expectedresult(){ | |
34 | ||
edb0d67a | 35 | $expectedResult = array( |
6a488035 TO |
36 | 'is_error' => 0, |
37 | 'version' => 3, | |
38 | 'count' => 1, | |
b259a4ab | 39 | 'id' => 727, |
edb0d67a | 40 | 'values' => array( |
b259a4ab EM |
41 | '727' => array( |
42 | 'id' => '727', | |
6a488035 TO |
43 | 'option_group_id' => '2', |
44 | 'label' => 'send out letters', | |
edb0d67a | 45 | 'value' => '46', |
6a488035 TO |
46 | 'name' => 'send out letters', |
47 | 'grouping' => '', | |
48 | 'filter' => 0, | |
49 | 'is_default' => 0, | |
50 | 'weight' => '2', | |
51 | 'description' => '', | |
52 | 'is_optgroup' => '1', | |
53 | 'is_reserved' => '', | |
54 | 'is_active' => '1', | |
55 | 'component_id' => '', | |
56 | 'domain_id' => '', | |
57 | 'visibility_id' => '', | |
58 | ), | |
59 | ), | |
60 | ); | |
61 | ||
fb32de45 | 62 | return $expectedResult; |
6a488035 TO |
63 | } |
64 | ||
65 | ||
66 | /* | |
67 | * This example has been generated from the API test suite. The test that created it is called | |
68 | * | |
69 | * testActivityTypeCreate and can be found in | |
69d79249 | 70 | * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ActivityTypeTest.php |
6a488035 TO |
71 | * |
72 | * You can see the outcome of the API tests at | |
69d79249 | 73 | * https://test.civicrm.org/job/CiviCRM-master-git/ |
6a488035 TO |
74 | * |
75 | * To Learn about the API read | |
69d79249 | 76 | * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API |
6a488035 | 77 | * |
69d79249 E |
78 | * Browse the api on your own site with the api explorer |
79 | * http://MYSITE.ORG/path/to/civicrm/api/explorer | |
6a488035 TO |
80 | * |
81 | * Read more about testing here | |
82 | * http://wiki.civicrm.org/confluence/display/CRM/Testing | |
83 | * | |
84 | * API Standards documentation: | |
85 | * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards | |
b259a4ab | 86 | */ |