Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
fb32de45 | 2 | /** |
3 | * Test Generated example of using activity API | |
4 | * Example demonstrates setting & retrieving the target & source * | |
6a488035 TO |
5 | */ |
6 | function activity__example(){ | |
feb2a730 | 7 | $params = array( |
9f1b81e0 | 8 | 'source_contact_id' => 1, |
6a488035 TO |
9 | 'subject' => 'Make-it-Happen Meeting', |
10 | 'activity_date_time' => '20110316', | |
11 | 'duration' => 120, | |
12 | 'location' => 'Pensulvania', | |
13 | 'details' => 'a test activity', | |
14 | 'status_id' => 1, | |
15 | 'activity_type_id' => 1, | |
6a488035 | 16 | 'priority_id' => 1, |
9f1b81e0 | 17 | 'target_contact_id' => 1, |
18 | 'assignee_contact_id' => 1, | |
6a488035 TO |
19 | ); |
20 | ||
fb32de45 | 21 | try{ |
22 | $result = civicrm_api3('activity', '', $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 activity__expectedresult(){ | |
39 | ||
feb2a730 | 40 | $expectedResult = array( |
6a488035 TO |
41 | 'is_error' => 0, |
42 | 'version' => 3, | |
43 | 'count' => 1, | |
44 | 'id' => 1, | |
feb2a730 | 45 | 'values' => array( |
46 | '1' => array( | |
6a488035 | 47 | 'id' => '1', |
6a488035 TO |
48 | 'source_record_id' => '', |
49 | 'activity_type_id' => '1', | |
50 | 'subject' => 'Make-it-Happen Meeting', | |
51 | 'activity_date_time' => '20110316000000', | |
52 | 'duration' => '120', | |
53 | 'location' => 'Pensulvania', | |
54 | 'phone_id' => '', | |
55 | 'phone_number' => '', | |
56 | 'details' => 'a test activity', | |
57 | 'status_id' => '1', | |
58 | 'priority_id' => '1', | |
59 | 'parent_id' => '', | |
60 | 'is_test' => '', | |
61 | 'medium_id' => '', | |
62 | 'is_auto' => '', | |
63 | 'relationship_id' => '', | |
64 | 'is_current_revision' => '', | |
65 | 'original_id' => '', | |
66 | 'result' => '', | |
67 | 'is_deleted' => '', | |
68 | 'campaign_id' => '', | |
69 | 'engagement_level' => '', | |
70 | 'weight' => '', | |
71 | ), | |
72 | ), | |
73 | ); | |
74 | ||
fb32de45 | 75 | return $expectedResult; |
6a488035 TO |
76 | } |
77 | ||
78 | ||
79 | /* | |
80 | * This example has been generated from the API test suite. The test that created it is called | |
81 | * | |
82 | * testActivityReturnTargetAssignee and can be found in | |
69d79249 | 83 | * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ActivityTest.php |
6a488035 TO |
84 | * |
85 | * You can see the outcome of the API tests at | |
69d79249 | 86 | * https://test.civicrm.org/job/CiviCRM-master-git/ |
6a488035 TO |
87 | * |
88 | * To Learn about the API read | |
69d79249 | 89 | * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API |
6a488035 | 90 | * |
69d79249 E |
91 | * Browse the api on your own site with the api explorer |
92 | * http://MYSITE.ORG/path/to/civicrm/api/explorer | |
6a488035 TO |
93 | * |
94 | * Read more about testing here | |
95 | * http://wiki.civicrm.org/confluence/display/CRM/Testing | |
96 | * | |
97 | * API Standards documentation: | |
98 | * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards | |
b259a4ab | 99 | */ |