Commit | Line | Data |
---|---|---|
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 event create API. | |
10 | * | |
11 | * | |
12 | * @return array | |
13 | * API result array | |
14 | */ | |
15 | function event_create_example() { | |
16 | $params = array( | |
17 | 'title' => 'Annual CiviCRM meet', | |
18 | 'summary' => 'If you have any CiviCRM realted issues or want to track where CiviCRM is heading, Sign up now', | |
19 | 'description' => 'This event is intended to give brief idea about progess of CiviCRM and giving solutions to common user issues', | |
20 | 'event_type_id' => 1, | |
21 | 'is_public' => 1, | |
22 | 'start_date' => 20081021, | |
23 | 'end_date' => 20081023, | |
24 | 'is_online_registration' => 1, | |
25 | 'registration_start_date' => 20080601, | |
26 | 'registration_end_date' => '2008-10-15', | |
27 | 'max_participants' => 100, | |
28 | 'event_full_text' => 'Sorry! We are already full', | |
29 | 'is_monetary' => 0, | |
30 | 'is_active' => 1, | |
31 | 'is_show_location' => 0, | |
32 | ); | |
6a488035 | 33 | |
50fb255d | 34 | try{ |
35 | $result = civicrm_api3('event', 'create', $params); | |
36 | } | |
37 | catch (CiviCRM_API3_Exception $e) { | |
38 | // Handle error here. | |
39 | $errorMessage = $e->getMessage(); | |
40 | $errorCode = $e->getErrorCode(); | |
41 | $errorData = $e->getExtraParams(); | |
42 | return array( | |
43 | 'error' => $errorMessage, | |
44 | 'error_code' => $errorCode, | |
45 | 'error_data' => $errorData, | |
46 | ); | |
47 | } | |
48 | ||
49 | return $result; | |
6a488035 TO |
50 | } |
51 | ||
fb32de45 | 52 | /** |
50fb255d | 53 | * Function returns array of result expected from previous function. |
54 | * | |
55 | * @return array | |
56 | * API result array | |
6a488035 | 57 | */ |
50fb255d | 58 | function event_create_expectedresult() { |
6a488035 | 59 | |
53ca8fd7 | 60 | $expectedResult = array( |
50fb255d | 61 | 'is_error' => 0, |
62 | 'version' => 3, | |
63 | 'count' => 1, | |
64 | 'id' => 3, | |
65 | 'values' => array( | |
53ca8fd7 | 66 | '3' => array( |
50fb255d | 67 | 'id' => '3', |
68 | 'title' => 'Annual CiviCRM meet', | |
69 | 'summary' => 'If you have any CiviCRM realted issues or want to track where CiviCRM is heading, Sign up now', | |
70 | 'description' => 'This event is intended to give brief idea about progess of CiviCRM and giving solutions to common user issues', | |
71 | 'event_type_id' => '1', | |
72 | 'participant_listing_id' => '', | |
73 | 'is_public' => '1', | |
74 | 'start_date' => '2013-07-29 00:00:00', | |
75 | 'end_date' => '2013-08-04 00:00:00', | |
76 | 'is_online_registration' => '1', | |
77 | 'registration_link_text' => '', | |
78 | 'registration_start_date' => '20080601000000', | |
79 | 'registration_end_date' => '20081015000000', | |
80 | 'max_participants' => '100', | |
81 | 'event_full_text' => 'Sorry! We are already full', | |
82 | 'is_monetary' => 0, | |
83 | 'financial_type_id' => '', | |
84 | 'payment_processor' => '', | |
85 | 'is_map' => '', | |
86 | 'is_active' => '1', | |
87 | 'fee_label' => '', | |
88 | 'is_show_location' => 0, | |
89 | 'loc_block_id' => '', | |
90 | 'default_role_id' => '', | |
91 | 'intro_text' => '', | |
92 | 'footer_text' => '', | |
93 | 'confirm_title' => '', | |
94 | 'confirm_text' => '', | |
95 | 'confirm_footer_text' => '', | |
96 | 'is_email_confirm' => '', | |
97 | 'confirm_email_text' => '', | |
98 | 'confirm_from_name' => '', | |
99 | 'confirm_from_email' => '', | |
100 | 'cc_confirm' => '', | |
101 | 'bcc_confirm' => '', | |
102 | 'default_fee_id' => '', | |
103 | 'default_discount_fee_id' => '', | |
104 | 'thankyou_title' => '', | |
105 | 'thankyou_text' => '', | |
106 | 'thankyou_footer_text' => '', | |
107 | 'is_pay_later' => '', | |
108 | 'pay_later_text' => '', | |
109 | 'pay_later_receipt' => '', | |
110 | 'is_partial_payment' => '', | |
111 | 'initial_amount_label' => '', | |
112 | 'initial_amount_help_text' => '', | |
113 | 'min_initial_amount' => '', | |
114 | 'is_multiple_registrations' => '', | |
115 | 'allow_same_participant_emails' => '', | |
116 | 'has_waitlist' => '', | |
117 | 'requires_approval' => '', | |
118 | 'expiration_time' => '', | |
119 | 'waitlist_text' => '', | |
120 | 'approval_req_text' => '', | |
121 | 'is_template' => 0, | |
122 | 'template_title' => '', | |
123 | 'created_id' => '', | |
124 | 'created_date' => '2013-07-28 08:49:19', | |
125 | 'currency' => '', | |
126 | 'campaign_id' => '', | |
127 | 'is_share' => '', | |
128 | 'is_confirm_enabled' => '', | |
129 | 'parent_event_id' => '', | |
130 | 'slot_label_id' => '', | |
131 | 'dedupe_rule_group_id' => '', | |
132 | 'is_billing_required' => '', | |
133 | ), | |
6a488035 | 134 | ), |
50fb255d | 135 | ); |
6a488035 | 136 | |
fb32de45 | 137 | return $expectedResult; |
6a488035 TO |
138 | } |
139 | ||
50fb255d | 140 | /** |
141 | * This example has been generated from the API test suite. | |
142 | * The test that created it is called | |
143 | * testCreateEventSuccess | |
144 | * and can be found in | |
69d79249 | 145 | * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/EventTest.php |
6a488035 TO |
146 | * |
147 | * You can see the outcome of the API tests at | |
69d79249 | 148 | * https://test.civicrm.org/job/CiviCRM-master-git/ |
6a488035 TO |
149 | * |
150 | * To Learn about the API read | |
69d79249 | 151 | * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API |
6a488035 | 152 | * |
69d79249 E |
153 | * Browse the api on your own site with the api explorer |
154 | * http://MYSITE.ORG/path/to/civicrm/api/explorer | |
6a488035 TO |
155 | * |
156 | * Read more about testing here | |
157 | * http://wiki.civicrm.org/confluence/display/CRM/Testing | |
158 | * | |
159 | * API Standards documentation: | |
160 | * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards | |
b259a4ab | 161 | */ |