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