Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
50fb255d | 2 | /** |
a828d7b8 | 3 | * Test Generated example demonstrating the Activity.get API. |
50fb255d | 4 | * |
5c49fee0 | 5 | * Demonstrates _high filter (at time of writing doesn't work if contact_id is set. |
50fb255d | 6 | * |
7 | * @return array | |
8 | * API result array | |
9 | */ | |
10 | function activity_get_example() { | |
11 | $params = array( | |
12 | 'source_contact_id' => 1, | |
13 | 'filter.activity_date_time_high' => '20120101000000', | |
14 | 'sequential' => 1, | |
15 | ); | |
6a488035 | 16 | |
50fb255d | 17 | try{ |
a828d7b8 | 18 | $result = civicrm_api3('Activity', 'get', $params); |
50fb255d | 19 | } |
20 | catch (CiviCRM_API3_Exception $e) { | |
21 | // Handle error here. | |
22 | $errorMessage = $e->getMessage(); | |
23 | $errorCode = $e->getErrorCode(); | |
24 | $errorData = $e->getExtraParams(); | |
25 | return array( | |
26 | 'error' => $errorMessage, | |
27 | 'error_code' => $errorCode, | |
28 | 'error_data' => $errorData, | |
29 | ); | |
30 | } | |
31 | ||
32 | return $result; | |
6a488035 TO |
33 | } |
34 | ||
fb32de45 | 35 | /** |
50fb255d | 36 | * Function returns array of result expected from previous function. |
37 | * | |
38 | * @return array | |
39 | * API result array | |
6a488035 | 40 | */ |
50fb255d | 41 | function activity_get_expectedresult() { |
6a488035 | 42 | |
feb2a730 | 43 | $expectedResult = array( |
50fb255d | 44 | 'is_error' => 0, |
45 | 'version' => 3, | |
46 | 'count' => 1, | |
47 | 'id' => 1, | |
48 | 'values' => array( | |
feb2a730 | 49 | '0' => array( |
50fb255d | 50 | 'id' => '1', |
51 | 'activity_type_id' => '51', | |
52 | 'subject' => 'Make-it-Happen Meeting', | |
53 | 'activity_date_time' => '2011-01-01 00:00:00', | |
54 | 'duration' => '120', | |
e3aa0dd1 | 55 | 'location' => 'Pennsylvania', |
50fb255d | 56 | 'details' => 'a test activity', |
57 | 'status_id' => '1', | |
58 | 'priority_id' => '1', | |
59 | 'is_test' => 0, | |
60 | 'is_auto' => 0, | |
61 | 'is_current_revision' => '1', | |
62 | 'is_deleted' => 0, | |
63 | 'source_contact_id' => '1', | |
64 | ), | |
6a488035 | 65 | ), |
50fb255d | 66 | ); |
6a488035 | 67 | |
fb32de45 | 68 | return $expectedResult; |
6a488035 TO |
69 | } |
70 | ||
a828d7b8 | 71 | /* |
50fb255d | 72 | * This example has been generated from the API test suite. |
a828d7b8 CW |
73 | * The test that created it is called "testGetFilterMaxDate" |
74 | * and can be found at: | |
69d79249 | 75 | * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ActivityTest.php |
6a488035 TO |
76 | * |
77 | * You can see the outcome of the API tests at | |
69d79249 | 78 | * https://test.civicrm.org/job/CiviCRM-master-git/ |
6a488035 TO |
79 | * |
80 | * To Learn about the API read | |
69d79249 | 81 | * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API |
6a488035 | 82 | * |
69d79249 | 83 | * Browse the api on your own site with the api explorer |
41d4d31f | 84 | * http://MYSITE.ORG/path/to/civicrm/api |
6a488035 TO |
85 | * |
86 | * Read more about testing here | |
87 | * http://wiki.civicrm.org/confluence/display/CRM/Testing | |
88 | * | |
89 | * API Standards documentation: | |
90 | * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards | |
b259a4ab | 91 | */ |