Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
fb32de45 | 2 | /** |
50fb255d | 3 | * @file |
4 | * Test Generated API Example. | |
5 | * See bottom of this file for more detail. | |
6a488035 | 6 | */ |
6a488035 | 7 | |
50fb255d | 8 | /** |
9 | * Test Generated example of using activity create API. | |
10 | * | |
11 | * | |
12 | * @return array | |
13 | * API result array | |
14 | */ | |
15 | function activity_create_example() { | |
16 | $params = array( | |
17 | 'source_contact_id' => 1, | |
18 | 'activity_type_id' => '51', | |
19 | 'subject' => 'test activity type id', | |
20 | 'activity_date_time' => '2011-06-02 14:36:13', | |
21 | 'status_id' => 2, | |
22 | 'priority_id' => 1, | |
23 | 'duration' => 120, | |
e3aa0dd1 | 24 | 'location' => 'Pennsylvania', |
50fb255d | 25 | 'details' => 'a test activity', |
26 | 'custom_1' => 'custom string', | |
27 | ); | |
6a488035 | 28 | |
50fb255d | 29 | try{ |
30 | $result = civicrm_api3('activity', 'create', $params); | |
31 | } | |
32 | catch (CiviCRM_API3_Exception $e) { | |
33 | // Handle error here. | |
34 | $errorMessage = $e->getMessage(); | |
35 | $errorCode = $e->getErrorCode(); | |
36 | $errorData = $e->getExtraParams(); | |
37 | return array( | |
38 | 'error' => $errorMessage, | |
39 | 'error_code' => $errorCode, | |
40 | 'error_data' => $errorData, | |
41 | ); | |
42 | } | |
43 | ||
44 | return $result; | |
6a488035 TO |
45 | } |
46 | ||
fb32de45 | 47 | /** |
50fb255d | 48 | * Function returns array of result expected from previous function. |
49 | * | |
50 | * @return array | |
51 | * API result array | |
6a488035 | 52 | */ |
50fb255d | 53 | function activity_create_expectedresult() { |
6a488035 | 54 | |
feb2a730 | 55 | $expectedResult = array( |
50fb255d | 56 | 'is_error' => 0, |
57 | 'version' => 3, | |
58 | 'count' => 1, | |
59 | 'id' => 1, | |
60 | 'values' => array( | |
feb2a730 | 61 | '1' => array( |
50fb255d | 62 | 'id' => '1', |
63 | 'source_record_id' => '', | |
64 | 'activity_type_id' => '51', | |
65 | 'subject' => 'test activity type id', | |
66 | 'activity_date_time' => '20110602143613', | |
67 | 'duration' => '120', | |
e3aa0dd1 | 68 | 'location' => 'Pennsylvania', |
50fb255d | 69 | 'phone_id' => '', |
70 | 'phone_number' => '', | |
71 | 'details' => 'a test activity', | |
72 | 'status_id' => '2', | |
73 | 'priority_id' => '1', | |
74 | 'parent_id' => '', | |
75 | 'is_test' => '', | |
76 | 'medium_id' => '', | |
77 | 'is_auto' => '', | |
78 | 'relationship_id' => '', | |
79 | 'is_current_revision' => '', | |
80 | 'original_id' => '', | |
81 | 'result' => '', | |
82 | 'is_deleted' => '', | |
83 | 'campaign_id' => '', | |
84 | 'engagement_level' => '', | |
85 | 'weight' => '', | |
86 | ), | |
6a488035 | 87 | ), |
50fb255d | 88 | ); |
6a488035 | 89 | |
fb32de45 | 90 | return $expectedResult; |
6a488035 TO |
91 | } |
92 | ||
50fb255d | 93 | /** |
94 | * This example has been generated from the API test suite. | |
95 | * The test that created it is called | |
96 | * testActivityCreateCustom | |
97 | * and can be found in | |
69d79249 | 98 | * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ActivityTest.php |
2f3d72cf | 99 | * |
100 | * You can see the outcome of the API tests at | |
69d79249 | 101 | * https://test.civicrm.org/job/CiviCRM-master-git/ |
2f3d72cf | 102 | * |
103 | * To Learn about the API read | |
69d79249 | 104 | * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API |
2f3d72cf | 105 | * |
69d79249 E |
106 | * Browse the api on your own site with the api explorer |
107 | * http://MYSITE.ORG/path/to/civicrm/api/explorer | |
2f3d72cf | 108 | * |
6a488035 TO |
109 | * Read more about testing here |
110 | * http://wiki.civicrm.org/confluence/display/CRM/Testing | |
2f3d72cf | 111 | * |
112 | * API Standards documentation: | |
113 | * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards | |
b259a4ab | 114 | */ |