Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
4 | | CiviCRM version 4.3 | | |
5 | +--------------------------------------------------------------------+ | |
6 | | Copyright CiviCRM LLC (c) 2004-2013 | | |
7 | +--------------------------------------------------------------------+ | |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
10 | | CiviCRM is free software; you can copy, modify, and distribute it | | |
11 | | under the terms of the GNU Affero General Public License | | |
12 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | |
13 | | | | |
14 | | CiviCRM is distributed in the hope that it will be useful, but | | |
15 | | WITHOUT ANY WARRANTY; without even the implied warranty of | | |
16 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | |
17 | | See the GNU Affero General Public License for more details. | | |
18 | | | | |
19 | | You should have received a copy of the GNU Affero General Public | | |
20 | | License along with this program; if not, contact CiviCRM LLC | | |
21 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
22 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
23 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
24 | +--------------------------------------------------------------------+ | |
25 | */ | |
26 | ||
27 | ||
28 | require_once 'CiviTest/CiviSeleniumTestCase.php'; | |
29 | class WebTest_Event_AddEventTest extends CiviSeleniumTestCase { | |
30 | ||
31 | protected function setUp() { | |
32 | parent::setUp(); | |
33 | } | |
34 | ||
35 | function testAddPaidEventNoTemplate() { | |
6a488035 TO |
36 | // Log in using webtestLogin() method |
37 | $this->webtestLogin(); | |
38 | ||
39 | // We need a payment processor | |
40 | $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7); | |
41 | $this->webtestAddPaymentProcessor($processorName); | |
42 | ||
071a6d2e | 43 | $this->openCiviPage("event/add", "reset=1&action=add"); |
6a488035 TO |
44 | |
45 | $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7); | |
46 | $eventDescription = "Here is a description for this conference."; | |
47 | $this->_testAddEventInfo($eventTitle, $eventDescription); | |
48 | ||
49 | $streetAddress = "100 Main Street"; | |
50 | $this->_testAddLocation($streetAddress); | |
51 | ||
52 | $this->_testAddReminder($eventTitle); | |
53 | ||
54 | $this->_testAddFees(FALSE, FALSE, $processorName); | |
55 | ||
56 | // intro text for registration page | |
57 | $registerIntro = "Fill in all the fields below and click Continue."; | |
58 | $multipleRegistrations = TRUE; | |
59 | $this->_testAddOnlineRegistration($registerIntro, $multipleRegistrations); | |
60 | ||
61 | $eventInfoStrings = array($eventTitle, $eventDescription, $streetAddress); | |
62 | $this->_testVerifyEventInfo($eventTitle, $eventInfoStrings); | |
63 | ||
64 | $registerStrings = array("225.00", "Member", "300.00", "Non-member", $registerIntro); | |
65 | $registerUrl = $this->_testVerifyRegisterPage($registerStrings); | |
66 | ||
67 | $numberRegistrations = 3; | |
68 | $anonymous = TRUE; | |
69 | $this->_testOnlineRegistration($registerUrl, $numberRegistrations, $anonymous); | |
70 | } | |
71 | ||
72 | function testAddPaidEventDiscount() { | |
6a488035 TO |
73 | |
74 | // Log in using webtestLogin() method | |
75 | $this->webtestLogin(); | |
76 | ||
77 | // We need a payment processor | |
78 | $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7); | |
79 | $this->webtestAddPaymentProcessor($processorName); | |
80 | ||
071a6d2e | 81 | $this->openCiviPage("event/add", "reset=1&action=add"); |
6a488035 TO |
82 | |
83 | $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7); | |
84 | $eventDescription = "Here is a description for this conference."; | |
85 | $this->_testAddEventInfo($eventTitle, $eventDescription); | |
86 | ||
87 | $streetAddress = "100 Main Street"; | |
88 | $this->_testAddLocation($streetAddress); | |
89 | ||
90 | $this->_testAddReminder($eventTitle); | |
91 | ||
92 | $this->_testAddFees(TRUE, FALSE, $processorName); | |
93 | ||
94 | // intro text for registration page | |
95 | $registerIntro = "Fill in all the fields below and click Continue."; | |
96 | $multipleRegistrations = TRUE; | |
97 | $this->_testAddOnlineRegistration($registerIntro, $multipleRegistrations); | |
98 | ||
99 | $discountFees = array("225.00", "300.00"); | |
100 | $eventInfoStrings = array($eventTitle, $eventDescription, $streetAddress); | |
101 | $this->_testVerifyEventInfo($eventTitle, $eventInfoStrings, $discountFees); | |
102 | ||
103 | $registerStrings = array_push($discountFees, "Member", "Non-member", $registerIntro); | |
104 | $registerUrl = $this->_testVerifyRegisterPage($registerStrings); | |
105 | ||
106 | $numberRegistrations = 3; | |
107 | $anonymous = TRUE; | |
108 | $this->_testOnlineRegistration($registerUrl, $numberRegistrations, $anonymous); | |
109 | } | |
110 | ||
111 | function testDeletePriceSetDiscount() { | |
6a488035 TO |
112 | |
113 | // Log in using webtestLogin() method | |
114 | $this->webtestLogin(); | |
115 | ||
116 | // We need a payment processor | |
117 | $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7); | |
118 | $this->webtestAddPaymentProcessor($processorName); | |
119 | ||
071a6d2e | 120 | $this->openCiviPage("event/add", "reset=1&action=add"); |
6a488035 TO |
121 | |
122 | $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7); | |
123 | $eventDescription = "Here is a description for this conference."; | |
124 | $this->_testAddEventInfo($eventTitle, $eventDescription); | |
125 | ||
126 | $streetAddress = "100 Main Street"; | |
127 | $this->_testAddLocation($streetAddress); | |
128 | ||
129 | //Add two discounts | |
130 | $discount = $this->_testAddFees(TRUE, FALSE, $processorName, TRUE); | |
131 | ||
132 | // intro text for registration page | |
133 | $registerIntro = "Fill in all the fields below and click Continue."; | |
134 | $multipleRegistrations = TRUE; | |
135 | $this->_testAddOnlineRegistration($registerIntro, $multipleRegistrations); | |
136 | ||
137 | $discountFees = array("225.00", "300.00"); | |
138 | $eventInfoStrings = array($eventTitle, $eventDescription, $streetAddress); | |
139 | $id = $this->_testVerifyEventInfo($eventTitle, $eventInfoStrings, $discountFees); | |
140 | ||
141 | $registerStrings = array_push($discountFees, "Member", "Non-member", $registerIntro); | |
142 | $registerUrl = $this->_testVerifyRegisterPage($registerStrings); | |
143 | ||
144 | //Add Price Set now | |
42daf119 | 145 | $this->openCiviPage("event/manage/fee", "reset=1&action=update&id=$id", "_qf_Fee_upload-bottom"); |
6a488035 TO |
146 | $this->click("xpath=//a[@id='quickconfig']"); |
147 | $this->waitForElementPresent('popupContainer'); | |
148 | sleep(3); | |
149 | $this->click("xpath=//div[@class='ui-dialog-buttonset']/button[1]"); | |
150 | sleep(3); | |
151 | ||
152 | //Assert quick config change and discount deletion | |
071a6d2e | 153 | $this->openCiviPage("admin/price", "reset=1"); |
6a488035 TO |
154 | $this->assertStringsPresent($discount); |
155 | } | |
156 | ||
157 | function testAddDeleteEventDiscount() { | |
6a488035 TO |
158 | |
159 | // Log in using webtestLogin() method | |
160 | $this->webtestLogin(); | |
161 | ||
162 | // We need a payment processor | |
163 | $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7); | |
164 | $this->webtestAddPaymentProcessor($processorName); | |
165 | ||
071a6d2e | 166 | $this->openCiviPage("event/add", "reset=1&action=add"); |
6a488035 TO |
167 | |
168 | $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7); | |
169 | $eventDescription = "Here is a description for this conference."; | |
170 | $this->_testAddEventInfo($eventTitle, $eventDescription); | |
171 | ||
172 | $streetAddress = "100 Main Street"; | |
173 | $this->_testAddLocation($streetAddress); | |
174 | ||
175 | //Add two discounts | |
176 | $discount = $this->_testAddFees(TRUE, FALSE, $processorName, TRUE); | |
177 | ||
178 | // intro text for registration page | |
179 | $registerIntro = "Fill in all the fields below and click Continue."; | |
180 | $multipleRegistrations = TRUE; | |
181 | $this->_testAddOnlineRegistration($registerIntro, $multipleRegistrations); | |
182 | ||
183 | $discountFees = array("225.00", "300.00"); | |
184 | $eventInfoStrings = array($eventTitle, $eventDescription, $streetAddress); | |
185 | $id = $this->_testVerifyEventInfo($eventTitle, $eventInfoStrings, $discountFees); | |
186 | ||
187 | $registerStrings = array_push($discountFees, "Member", "Non-member", $registerIntro); | |
188 | $registerUrl = $this->_testVerifyRegisterPage($registerStrings); | |
189 | //Delete the discount | |
190 | $this->_deleteDiscount($id, $eventTitle, $discount); | |
191 | } | |
192 | ||
193 | function _deleteDiscount($id, $eventTitle, $discount) { | |
42daf119 | 194 | $this->openCiviPage("event/manage/fee", "reset=1&action=update&id=$id", "_qf_Fee_upload-bottom"); |
6a488035 TO |
195 | $this->type("discount_name_2", ""); |
196 | $this->click("xpath=//tr[@id='discount_2']/td[3]/span/a"); | |
197 | $this->click("xpath=//tr[@id='discount_2']/td[4]/span/a"); | |
198 | $this->type("discounted_value_1_2", ""); | |
199 | $this->type("discounted_value_2_2", ""); | |
200 | $this->click("_qf_Fee_upload-bottom"); | |
071a6d2e | 201 | $this->waitForPageToLoad(); |
6a488035 | 202 | //Assertions |
071a6d2e | 203 | $this->openCiviPage("admin/price", "reset=1"); |
6a488035 TO |
204 | $this->assertStringsPresent($discount[1]); |
205 | } | |
206 | ||
207 | function testAddPaidEventWithTemplate() { | |
6a488035 TO |
208 | |
209 | // Log in using webtestLogin() method | |
210 | $this->webtestLogin(); | |
211 | ||
212 | // We need a payment processor | |
213 | $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7); | |
214 | $this->webtestAddPaymentProcessor($processorName); | |
215 | ||
071a6d2e | 216 | $this->openCiviPage("event/add", "reset=1&action=add"); |
6a488035 TO |
217 | |
218 | $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7); | |
219 | $eventDescription = "Here is a description for this conference."; | |
220 | // Select paid online registration template. | |
221 | $templateID = 6; | |
222 | $eventTypeID = 1; | |
223 | $this->_testAddEventInfoFromTemplate($eventTitle, $eventDescription, $templateID, $eventTypeID); | |
224 | ||
225 | $streetAddress = "100 Main Street"; | |
226 | $this->_testAddLocation($streetAddress); | |
227 | ||
228 | $this->_testAddFees(FALSE, FALSE, $processorName); | |
229 | ||
230 | // intro text for registration page | |
231 | $registerIntro = "Fill in all the fields below and click Continue."; | |
232 | $this->_testAddOnlineRegistration($registerIntro); | |
233 | ||
234 | // $eventInfoStrings = array( $eventTitle, $eventDescription, $streetAddress ); | |
235 | $eventInfoStrings = array($eventTitle, $streetAddress); | |
236 | $this->_testVerifyEventInfo($eventTitle, $eventInfoStrings); | |
237 | ||
238 | $registerStrings = array("225.00", "Member", "300.00", "Non-member", $registerIntro); | |
239 | $this->_testVerifyRegisterPage($registerStrings); | |
240 | } | |
241 | ||
242 | function testAddFreeEventWithTemplate() { | |
6a488035 TO |
243 | |
244 | // Log in using webtestLogin() method | |
245 | $this->webtestLogin(); | |
42daf119 | 246 | |
071a6d2e | 247 | $this->openCiviPage("event/add", "reset=1&action=add"); |
6a488035 TO |
248 | |
249 | $eventTitle = 'My Free Meeting - ' . substr(sha1(rand()), 0, 7); | |
250 | $eventDescription = "Here is a description for this free meeting."; | |
251 | // Select "Free Meeting with Online Registration" template (id = 5). | |
252 | $templateID = 5; | |
253 | $eventTypeID = 4; | |
254 | $this->_testAddEventInfoFromTemplate($eventTitle, $eventDescription, $templateID, $eventTypeID); | |
255 | ||
256 | $streetAddress = "100 Main Street"; | |
257 | $this->_testAddLocation($streetAddress); | |
258 | ||
259 | // Go to Fees tab and check that Paid Event is false (No) | |
260 | $this->click("link=Fees"); | |
261 | $this->waitForElementPresent("_qf_Fee_upload-bottom"); | |
262 | $this->verifyChecked("CIVICRM_QFID_0_is_monetary"); | |
263 | ||
264 | // intro text for registration page | |
265 | $registerIntro = "Fill in all the fields below and click Continue."; | |
266 | $this->_testAddOnlineRegistration($registerIntro); | |
267 | ||
268 | // $eventInfoStrings = array( $eventTitle, $eventDescription, $streetAddress ); | |
269 | $eventInfoStrings = array($eventTitle, $streetAddress); | |
270 | $this->_testVerifyEventInfo($eventTitle, $eventInfoStrings); | |
271 | ||
272 | $registerStrings = array($registerIntro); | |
273 | $this->_testVerifyRegisterPage($registerStrings); | |
274 | // make sure paid_event div is NOT present since this is a free event | |
275 | $this->verifyElementNotPresent("css=div.paid_event-section"); | |
276 | } | |
277 | ||
0dce9149 | 278 | function testUnpaidPaid() { |
0dce9149 PJ |
279 | |
280 | // Log in using webtestLogin() method | |
281 | $this->webtestLogin(); | |
282 | ||
071a6d2e | 283 | $this->openCiviPage("event/add", "reset=1&action=add"); |
0dce9149 PJ |
284 | $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7); |
285 | $eventDescription = "Here is a description for this conference."; | |
286 | $this->_testAddEventInfo($eventTitle, $eventDescription); | |
287 | ||
288 | //add fee section with pay later checked | |
289 | $this->_testAddFees(FALSE, FALSE, NULL, FALSE, TRUE); | |
290 | ||
291 | //make the event unpaid | |
292 | $this->waitForElementPresent("_qf_Fee_upload-bottom"); | |
293 | $this->assertChecked('is_pay_later'); | |
294 | $this->click("CIVICRM_QFID_0_is_monetary"); | |
295 | $this->click("_qf_Fee_upload-bottom"); | |
296 | $this->waitForElementPresent("_qf_Fee_upload-bottom"); | |
297 | ||
298 | //check if pay later option is disabled | |
299 | $this->click('CIVICRM_QFID_1_is_monetary'); | |
300 | sleep(3); | |
301 | $this->waitForElementPresent('is_pay_later'); | |
302 | $this->assertNotChecked('is_pay_later'); | |
303 | } | |
304 | ||
6a488035 | 305 | function _testAddEventInfo($eventTitle, $eventDescription) { |
6a488035 TO |
306 | $this->waitForElementPresent("_qf_EventInfo_upload-bottom"); |
307 | ||
6a488035 TO |
308 | $this->select("event_type_id", "value=1"); |
309 | ||
310 | // Attendee role s/b selected now. | |
311 | $this->select("default_role_id", "value=1"); | |
312 | ||
313 | // Enter Event Title, Summary and Description | |
314 | $this->type("title", $eventTitle); | |
315 | $this->type("summary", "This is a great conference. Sign up now!"); | |
316 | ||
317 | // Type description in ckEditor (fieldname, text to type, editor) | |
318 | $this->fillRichTextField("description", $eventDescription, 'CKEditor'); | |
319 | ||
320 | // Choose Start and End dates. | |
321 | // Using helper webtestFillDate function. | |
322 | $this->webtestFillDateTime("start_date", "+1 week"); | |
323 | $this->webtestFillDateTime("end_date", "+1 week 1 day 8 hours "); | |
324 | ||
325 | $this->type("max_participants", "50"); | |
326 | $this->click("is_map"); | |
327 | $this->click("is_public"); | |
328 | $this->click("_qf_EventInfo_upload-bottom"); | |
0dce9149 | 329 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
6a488035 TO |
330 | } |
331 | ||
332 | function _testAddEventInfoFromTemplate($eventTitle, $eventDescription, $templateID, $eventTypeID) { | |
6a488035 | 333 | $this->waitForElementPresent("_qf_EventInfo_upload-bottom"); |
42daf119 | 334 | |
6a488035 TO |
335 | // Select event template. Use option value, not label - since labels can be translated and test would fail |
336 | $this->select("template_id", "value={$templateID}"); | |
337 | ||
338 | // Wait for event type to be filled in (since page reloads) | |
339 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
340 | $this->verifySelectedValue("event_type_id", $eventTypeID); | |
341 | ||
342 | // Attendee role s/b selected now. | |
343 | $this->verifySelectedValue("default_role_id", "1"); | |
344 | ||
345 | // Enter Event Title, Summary and Description | |
346 | $this->type("title", $eventTitle); | |
347 | $this->type("summary", "This is a great conference. Sign up now!"); | |
348 | ||
349 | // Type description in ckEditor (fieldname, text to type, editor) | |
350 | $this->fillRichTextField("description", $eventDescription, 'CKEditor'); | |
351 | ||
352 | // Choose Start and End dates. | |
353 | // Using helper webtestFillDate function. | |
354 | $this->webtestFillDateTime("start_date", "+1 week"); | |
355 | $this->webtestFillDateTime("end_date", "+1 week 1 day 8 hours "); | |
356 | ||
357 | $this->type("max_participants", "50"); | |
358 | $this->click("is_map"); | |
359 | $this->click("_qf_EventInfo_upload-bottom"); | |
360 | } | |
361 | ||
362 | function _testAddLocation($streetAddress) { | |
363 | // Wait for Location tab form to load | |
364 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
365 | $this->waitForElementPresent("_qf_Location_upload-bottom"); | |
366 | ||
367 | // Fill in address fields | |
368 | $streetAddress = "100 Main Street"; | |
369 | $this->type("address_1_street_address", $streetAddress); | |
370 | $this->type("address_1_city", "San Francisco"); | |
371 | $this->type("address_1_postal_code", "94117"); | |
372 | $this->select("address_1_state_province_id", "value=1004"); | |
373 | $this->type("email_1_email", "info@civicrm.org"); | |
374 | ||
375 | $this->click("_qf_Location_upload-bottom"); | |
376 | ||
377 | // Wait for "saved" status msg | |
378 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
379 | $this->waitForTextPresent("'Location' information has been saved."); | |
380 | } | |
381 | ||
0dce9149 | 382 | function _testAddFees($discount = FALSE, $priceSet = FALSE, $processorName = "PP Pro", $double = FALSE, $payLater = FALSE) { |
6a488035 TO |
383 | $discount1 = "Early-bird" . substr(sha1(rand()), 0, 7); |
384 | $discount2 = ""; | |
385 | // Go to Fees tab | |
386 | $this->click("link=Fees"); | |
387 | $this->waitForElementPresent("_qf_Fee_upload-bottom"); | |
388 | $this->click("CIVICRM_QFID_1_is_monetary"); | |
0dce9149 PJ |
389 | |
390 | if ($payLater) { | |
391 | $this->check('is_pay_later'); | |
392 | $this->type('pay_later_receipt', 'testing later instructions'); | |
393 | } | |
394 | else { | |
395 | $this->uncheck('is_pay_later'); | |
396 | } | |
397 | ||
398 | if ($processorName) { | |
399 | $this->click("xpath=//tr[@class='crm-event-manage-fee-form-block-payment_processor']/td[2]/label[text()='$processorName']"); | |
400 | } | |
6a488035 TO |
401 | $this->select("financial_type_id", "value=4"); |
402 | if ($priceSet) { | |
403 | // get one - TBD | |
404 | } | |
405 | else { | |
406 | $this->type("label_1", "Member"); | |
407 | $this->type("value_1", "225.00"); | |
408 | $this->type("label_2", "Non-member"); | |
409 | $this->type("value_2", "300.00"); | |
410 | $this->click("CIVICRM_QFID_1_4"); | |
411 | } | |
412 | ||
413 | if ($discount) { | |
414 | // enter early bird discount fees | |
415 | $this->click("is_discount"); | |
416 | $this->waitForElementPresent("discount_name_1"); | |
417 | $this->type("discount_name_1", $discount1); | |
418 | $this->webtestFillDate("discount_start_date_1", "-3 week"); | |
419 | $this->webtestFillDate("discount_end_date_1", "-2 week"); | |
420 | $this->click("_qf_Fee_submit"); | |
421 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
422 | $this->waitForElementPresent("discounted_value_1_1"); | |
423 | $this->type("discounted_value_1_1","225.00"); | |
424 | $this->type("discounted_value_2_1","300.00"); | |
425 | ||
426 | if ($double) { | |
427 | $discount2 = "Early-bird" . substr(sha1(rand()), 0, 7); | |
428 | // enter early bird discount fees | |
429 | $this->click("link=another discount set"); | |
430 | $this->waitForElementPresent("discount_name_2"); | |
431 | $this->type("discount_name_2", $discount2); | |
432 | $this->webtestFillDate("discount_start_date_2", "-1 week"); | |
433 | $this->webtestFillDate("discount_end_date_2", "+1 week"); | |
434 | $this->click("_qf_Fee_submit"); | |
435 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
436 | $this->waitForElementPresent("discounted_value_2_1"); | |
437 | $this->type("discounted_value_1_2","225.00"); | |
438 | $this->type("discounted_value_2_2","300.00"); | |
439 | } | |
440 | $this->click("xpath=//fieldset[@id='discount']/fieldset/table/tbody/tr[2]/td[3]/input"); | |
441 | } | |
442 | $this->click("_qf_Fee_upload-bottom"); | |
443 | ||
444 | // Wait for "saved" status msg | |
445 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
0dce9149 | 446 | $this->assertElementContainsText("crm-notification-container", "'Fee' information has been saved"); |
6a488035 TO |
447 | return array($discount1, $discount2); |
448 | } | |
449 | ||
450 | function _testAddOnlineRegistration($registerIntro, $multipleRegistrations = FALSE) { | |
451 | // Go to Online Registration tab | |
452 | $this->click("link=Online Registration"); | |
453 | $this->waitForElementPresent("_qf_Registration_upload-bottom"); | |
454 | ||
455 | $this->check("is_online_registration"); | |
456 | $this->assertChecked("is_online_registration"); | |
457 | if ($multipleRegistrations) { | |
458 | $this->check("is_multiple_registrations"); | |
459 | $this->assertChecked("is_multiple_registrations"); | |
460 | } | |
461 | ||
462 | $this->fillRichTextField("intro_text", $registerIntro); | |
463 | ||
464 | // enable confirmation email | |
465 | $this->click("CIVICRM_QFID_1_is_email_confirm"); | |
466 | $this->type("confirm_from_name", "Jane Doe"); | |
467 | $this->type("confirm_from_email", "jane.doe@example.org"); | |
468 | ||
469 | $this->click("_qf_Registration_upload-bottom"); | |
470 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
471 | $this->waitForTextPresent("'Registration' information has been saved."); | |
472 | } | |
473 | ||
474 | function _testVerifyEventInfo($eventTitle, $eventInfoStrings, $eventFees = NULL) { | |
475 | // verify event input on info page | |
476 | // start at Manage Events listing | |
071a6d2e | 477 | $this->openCiviPage("event/manage", "reset=1"); |
6a488035 TO |
478 | $this->click("link=$eventTitle"); |
479 | ||
480 | // Look for Register button | |
481 | $this->waitForElementPresent("link=Register Now"); | |
482 | ||
483 | // Check for correct event info strings | |
484 | $this->assertStringsPresent($eventInfoStrings); | |
485 | ||
486 | // Optionally verify event fees (especially for discounts) | |
487 | if ($eventFees) { | |
488 | $this->assertStringsPresent($eventFees); | |
489 | } | |
490 | $elements = $this->parseURL(); | |
491 | return $elements['queryString']['id']; | |
492 | } | |
493 | ||
494 | function _testVerifyRegisterPage($registerStrings) { | |
495 | // Go to Register page and check for intro text and fee levels | |
496 | $this->click("link=Register Now"); | |
497 | $this->waitForElementPresent("_qf_Register_upload-bottom"); | |
498 | $this->assertStringsPresent($registerStrings); | |
499 | return $this->getLocation(); | |
500 | } | |
501 | ||
502 | function _testOnlineRegistration($registerUrl, $numberRegistrations = 1, $anonymous = TRUE) { | |
503 | if ($anonymous) { | |
42daf119 | 504 | $this->webtestLogout(); |
6a488035 TO |
505 | } |
506 | $this->open($registerUrl); | |
507 | ||
508 | $this->select("additional_participants", "value=" . $numberRegistrations); | |
509 | $this->type("email-Primary", "smith" . substr(sha1(rand()), 0, 7) . "@example.org"); | |
510 | ||
511 | $this->select("credit_card_type", "value=Visa"); | |
512 | $this->type("credit_card_number", "4111111111111111"); | |
513 | $this->type("cvv2", "000"); | |
514 | $this->select("credit_card_exp_date[M]", "value=1"); | |
515 | $this->select("credit_card_exp_date[Y]", "value=2020"); | |
516 | $this->type("billing_first_name", "Jane"); | |
517 | $this->type("billing_last_name", "Smith" . substr(sha1(rand()), 0, 7)); | |
518 | $this->type("billing_street_address-5", "15 Main St."); | |
519 | $this->type(" billing_city-5", "San Jose"); | |
520 | $this->select("billing_country_id-5", "value=1228"); | |
521 | $this->select("billing_state_province_id-5", "value=1004"); | |
522 | $this->type("billing_postal_code-5", "94129"); | |
523 | ||
524 | $this->click("_qf_Register_upload-bottom"); | |
525 | ||
526 | if ($numberRegistrations > 1) { | |
527 | for ($i = 1; $i <= $numberRegistrations; $i++) { | |
528 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
529 | // Look for Skip button | |
530 | $this->waitForElementPresent("_qf_Participant_{$i}_next_skip-Array"); | |
531 | $this->type("email-Primary", "smith" . substr(sha1(rand()), 0, 7) . "@example.org"); | |
532 | $this->click("_qf_Participant_{$i}_next"); | |
533 | } | |
534 | } | |
535 | ||
536 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
537 | $this->waitForElementPresent("_qf_Confirm_next-bottom"); | |
538 | $confirmStrings = array("Event Fee(s)", "Billing Name and Address", "Credit Card Information"); | |
539 | $this->assertStringsPresent($confirmStrings); | |
540 | $this->click("_qf_Confirm_next-bottom"); | |
541 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
542 | $thankStrings = array("Thank You for Registering", "Event Total", "Transaction Date"); | |
543 | $this->assertStringsPresent($thankStrings); | |
544 | } | |
545 | ||
546 | function _testAddReminder($eventTitle) { | |
547 | // Go to Schedule Reminders tab | |
548 | $this->click('css=li#tab_reminder a'); | |
549 | $this->waitForElementPresent("_qf_ScheduleReminders_upload-bottom"); | |
550 | $this->type("title", "Event Reminder for " . $eventTitle); | |
551 | $this->select('entity', 'label=Registered'); | |
552 | ||
553 | $this->select('start_action_offset', 'label=1'); | |
554 | $this->select('start_action_condition', 'label=after'); | |
555 | $this->click('is_repeat'); | |
556 | $this->select('repetition_frequency_interval', 'label=2'); | |
557 | $this->select('end_date', 'label=Event End Date'); | |
558 | $this->click('recipient'); | |
559 | $this->select('recipient', 'label=Participant Role'); | |
560 | // $this->select( 'recipient_listing', 'value=1' ); | |
561 | ||
562 | // Fill Subject | |
563 | $subject = 'subject' . substr(sha1(rand()), 0, 4); | |
564 | $this->type('subject', $subject); | |
565 | $this->fillRichTextField("html_message", "This is the test HTML version here!!!", 'CKEditor'); | |
566 | ||
567 | $this->type("text_message", "This is the test text version here!!!"); | |
568 | //click on save | |
569 | $this->click('_qf_ScheduleReminders_upload-bottom'); | |
570 | $this->waitForElementPresent("link=Add Reminder"); | |
571 | ||
572 | $this->waitForElementPresent("link=Edit"); | |
573 | ||
574 | $verifyText = array( | |
575 | 1 => 'Event Reminder for ' . $eventTitle, | |
576 | 3 => '1 hour after Event Start Date', | |
577 | 4 => 'Registered', | |
578 | 5 => 'Yes', | |
579 | 6 => 'Yes', | |
580 | ); | |
581 | ||
582 | //verify the fields for Event Reminder selector | |
583 | foreach ($verifyText as $key => $value) { | |
584 | $this->verifyText("xpath=//table[@class='display']/tbody/tr/td[$key]", $value); | |
585 | } | |
586 | } | |
587 | ||
42daf119 | 588 | } |