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