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