Merge pull request #5058 from eileenmcnaughton/test-examples
[civicrm-core.git] / api / v3 / examples / Activity / DateTimeLow.php
CommitLineData
6a488035 1<?php
fb32de45 2/**
50fb255d 3 * @file
4 * Test Generated API Example.
5 * See bottom of this file for more detail.
6a488035 6 */
6a488035 7
50fb255d 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 */
16function activity_get_example() {
17 $params = array(
18 'filter.activity_date_time_low' => '20120101000000',
19 'sequential' => 1,
20 );
6a488035 21
50fb255d 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;
6a488035
TO
38}
39
fb32de45 40/**
50fb255d 41 * Function returns array of result expected from previous function.
42 *
43 * @return array
44 * API result array
6a488035 45 */
50fb255d 46function activity_get_expectedresult() {
6a488035 47
feb2a730 48 $expectedResult = array(
50fb255d 49 'is_error' => 0,
50 'version' => 3,
51 'count' => 1,
52 'id' => 2,
53 'values' => array(
feb2a730 54 '0' => array(
50fb255d 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',
e3aa0dd1 60 'location' => 'Pennsylvania',
50fb255d 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 ),
6a488035 70 ),
50fb255d 71 );
6a488035 72
fb32de45 73 return $expectedResult;
6a488035
TO
74}
75
50fb255d 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
69d79249 81* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ActivityTest.php
6a488035
TO
82*
83* You can see the outcome of the API tests at
69d79249 84* https://test.civicrm.org/job/CiviCRM-master-git/
6a488035
TO
85*
86* To Learn about the API read
69d79249 87* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
6a488035 88*
69d79249
E
89* Browse the api on your own site with the api explorer
90* http://MYSITE.ORG/path/to/civicrm/api/explorer
6a488035
TO
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
b259a4ab 97*/