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