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