Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
50fb255d | 2 | /** |
a828d7b8 | 3 | * Test Generated example demonstrating the Event.get API. |
50fb255d | 4 | * |
5c49fee0 | 5 | * Demonstrates use of is.Current option. |
50fb255d | 6 | * |
7 | * @return array | |
8 | * API result array | |
9 | */ | |
10 | function event_get_example() { | |
cf8f0fff | 11 | $params = [ |
50fb255d | 12 | 'isCurrent' => 1, |
cf8f0fff | 13 | ]; |
6a488035 | 14 | |
50fb255d | 15 | try{ |
a828d7b8 | 16 | $result = civicrm_api3('Event', 'get', $params); |
50fb255d | 17 | } |
18 | catch (CiviCRM_API3_Exception $e) { | |
19 | // Handle error here. | |
20 | $errorMessage = $e->getMessage(); | |
21 | $errorCode = $e->getErrorCode(); | |
22 | $errorData = $e->getExtraParams(); | |
cf8f0fff | 23 | return [ |
5be22f39 | 24 | 'is_error' => 1, |
25 | 'error_message' => $errorMessage, | |
50fb255d | 26 | 'error_code' => $errorCode, |
27 | 'error_data' => $errorData, | |
cf8f0fff | 28 | ]; |
50fb255d | 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 event_get_expectedresult() { |
6a488035 | 41 | |
cf8f0fff | 42 | $expectedResult = [ |
50fb255d | 43 | 'is_error' => 0, |
44 | 'version' => 3, | |
45 | 'count' => 1, | |
46 | 'id' => 3, | |
cf8f0fff CW |
47 | 'values' => [ |
48 | '3' => [ | |
50fb255d | 49 | 'id' => '3', |
50 | 'title' => 'Annual CiviCRM meet 2', | |
51 | 'event_title' => 'Annual CiviCRM meet 2', | |
52 | 'summary' => 'If you have any CiviCRM realted issues or want to track where CiviCRM is heading, Sign up now', | |
53 | 'description' => 'This event is intended to give brief idea about progess of CiviCRM and giving solutions to common user issues', | |
54 | 'event_description' => 'This event is intended to give brief idea about progess of CiviCRM and giving solutions to common user issues', | |
55 | 'event_type_id' => '1', | |
56 | 'participant_listing_id' => 0, | |
57 | 'is_public' => '1', | |
58 | 'start_date' => '2013-07-29 00:00:00', | |
59 | 'event_start_date' => '2013-07-29 00:00:00', | |
60 | 'end_date' => '2013-08-04 00:00:00', | |
61 | 'event_end_date' => '2013-08-04 00:00:00', | |
62 | 'is_online_registration' => '1', | |
63 | 'registration_start_date' => '2010-06-01 00:00:00', | |
64 | 'registration_end_date' => '2010-10-15 00:00:00', | |
65 | 'max_participants' => '100', | |
66 | 'event_full_text' => 'Sorry! We are already full', | |
67 | 'is_monetary' => 0, | |
68 | 'is_map' => 0, | |
69 | 'is_active' => '1', | |
70 | 'is_show_location' => 0, | |
71 | 'default_role_id' => '1', | |
72 | 'is_email_confirm' => 0, | |
73 | 'is_pay_later' => 0, | |
74 | 'is_partial_payment' => 0, | |
75 | 'is_multiple_registrations' => 0, | |
5be22f39 | 76 | 'max_additional_participants' => 0, |
50fb255d | 77 | 'allow_same_participant_emails' => 0, |
5be22f39 | 78 | 'allow_selfcancelxfer' => 0, |
79 | 'selfcancelxfer_time' => 0, | |
50fb255d | 80 | 'is_template' => 0, |
81 | 'created_date' => '2013-07-28 08:49:19', | |
82 | 'is_share' => '1', | |
83 | 'is_confirm_enabled' => '1', | |
84 | 'is_billing_required' => 0, | |
cf8f0fff CW |
85 | ], |
86 | ], | |
87 | ]; | |
6a488035 | 88 | |
fb32de45 | 89 | return $expectedResult; |
6a488035 TO |
90 | } |
91 | ||
a828d7b8 | 92 | /* |
50fb255d | 93 | * This example has been generated from the API test suite. |
a828d7b8 CW |
94 | * The test that created it is called "testGetIsCurrent" |
95 | * and can be found at: | |
69d79249 | 96 | * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/EventTest.php |
6a488035 TO |
97 | * |
98 | * You can see the outcome of the API tests at | |
69d79249 | 99 | * https://test.civicrm.org/job/CiviCRM-master-git/ |
6a488035 TO |
100 | * |
101 | * To Learn about the API read | |
69d79249 | 102 | * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API |
6a488035 | 103 | * |
69d79249 | 104 | * Browse the api on your own site with the api explorer |
41d4d31f | 105 | * http://MYSITE.ORG/path/to/civicrm/api |
6a488035 TO |
106 | * |
107 | * Read more about testing here | |
108 | * http://wiki.civicrm.org/confluence/display/CRM/Testing | |
109 | * | |
110 | * API Standards documentation: | |
111 | * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards | |
b259a4ab | 112 | */ |