Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
50fb255d | 2 | /** |
3 | * Test Generated example of using activity get API. | |
4 | * | |
5 | * demonstrates _low filter (at time of writing doesn't work if contact_id is set | |
6 | * | |
7 | * @return array | |
8 | * API result array | |
9 | */ | |
10 | function activity_get_example() { | |
11 | $params = array( | |
12 | 'filter.activity_date_time_low' => '20120101000000', | |
13 | 'sequential' => 1, | |
14 | ); | |
6a488035 | 15 | |
50fb255d | 16 | try{ |
17 | $result = civicrm_api3('activity', 'get', $params); | |
18 | } | |
19 | catch (CiviCRM_API3_Exception $e) { | |
20 | // Handle error here. | |
21 | $errorMessage = $e->getMessage(); | |
22 | $errorCode = $e->getErrorCode(); | |
23 | $errorData = $e->getExtraParams(); | |
24 | return array( | |
25 | 'error' => $errorMessage, | |
26 | 'error_code' => $errorCode, | |
27 | 'error_data' => $errorData, | |
28 | ); | |
29 | } | |
30 | ||
31 | return $result; | |
6a488035 TO |
32 | } |
33 | ||
fb32de45 | 34 | /** |
50fb255d | 35 | * Function returns array of result expected from previous function. |
36 | * | |
37 | * @return array | |
38 | * API result array | |
6a488035 | 39 | */ |
50fb255d | 40 | function activity_get_expectedresult() { |
6a488035 | 41 | |
feb2a730 | 42 | $expectedResult = array( |
50fb255d | 43 | 'is_error' => 0, |
44 | 'version' => 3, | |
45 | 'count' => 1, | |
46 | 'id' => 2, | |
47 | 'values' => array( | |
feb2a730 | 48 | '0' => array( |
50fb255d | 49 | 'id' => '2', |
50 | 'activity_type_id' => '51', | |
51 | 'subject' => 'Make-it-Happen Meeting', | |
52 | 'activity_date_time' => '2012-02-16 00:00:00', | |
53 | 'duration' => '120', | |
e3aa0dd1 | 54 | 'location' => 'Pennsylvania', |
50fb255d | 55 | 'details' => 'a test activity', |
56 | 'status_id' => '1', | |
57 | 'priority_id' => '1', | |
58 | 'is_test' => 0, | |
59 | 'is_auto' => 0, | |
60 | 'is_current_revision' => '1', | |
61 | 'is_deleted' => 0, | |
62 | 'source_contact_id' => '1', | |
63 | ), | |
6a488035 | 64 | ), |
50fb255d | 65 | ); |
6a488035 | 66 | |
fb32de45 | 67 | return $expectedResult; |
6a488035 TO |
68 | } |
69 | ||
50fb255d | 70 | /** |
71 | * This example has been generated from the API test suite. | |
72 | * The test that created it is called | |
73 | * testGetFilterMaxDate | |
74 | * and can be found in | |
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 | */ |