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 | ||
6a488035 TO |
43 | $this->open($this->sboxPath . "civicrm/event/add?reset=1&action=add"); |
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 | ||
6a488035 TO |
81 | $this->open($this->sboxPath . "civicrm/event/add?reset=1&action=add"); |
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 | ||
6a488035 TO |
120 | $this->open($this->sboxPath . "civicrm/event/add?reset=1&action=add"); |
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 | |
153 | $this->open($this->sboxPath . "civicrm/admin/price?reset=1"); | |
154 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
155 | $this->assertStringsPresent($discount); | |
156 | } | |
157 | ||
158 | function testAddDeleteEventDiscount() { | |
6a488035 TO |
159 | |
160 | // Log in using webtestLogin() method | |
161 | $this->webtestLogin(); | |
162 | ||
163 | // We need a payment processor | |
164 | $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7); | |
165 | $this->webtestAddPaymentProcessor($processorName); | |
166 | ||
6a488035 TO |
167 | $this->open($this->sboxPath . "civicrm/event/add?reset=1&action=add"); |
168 | ||
169 | $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7); | |
170 | $eventDescription = "Here is a description for this conference."; | |
171 | $this->_testAddEventInfo($eventTitle, $eventDescription); | |
172 | ||
173 | $streetAddress = "100 Main Street"; | |
174 | $this->_testAddLocation($streetAddress); | |
175 | ||
176 | //Add two discounts | |
177 | $discount = $this->_testAddFees(TRUE, FALSE, $processorName, TRUE); | |
178 | ||
179 | // intro text for registration page | |
180 | $registerIntro = "Fill in all the fields below and click Continue."; | |
181 | $multipleRegistrations = TRUE; | |
182 | $this->_testAddOnlineRegistration($registerIntro, $multipleRegistrations); | |
183 | ||
184 | $discountFees = array("225.00", "300.00"); | |
185 | $eventInfoStrings = array($eventTitle, $eventDescription, $streetAddress); | |
186 | $id = $this->_testVerifyEventInfo($eventTitle, $eventInfoStrings, $discountFees); | |
187 | ||
188 | $registerStrings = array_push($discountFees, "Member", "Non-member", $registerIntro); | |
189 | $registerUrl = $this->_testVerifyRegisterPage($registerStrings); | |
190 | //Delete the discount | |
191 | $this->_deleteDiscount($id, $eventTitle, $discount); | |
192 | } | |
193 | ||
194 | function _deleteDiscount($id, $eventTitle, $discount) { | |
42daf119 | 195 | $this->openCiviPage("event/manage/fee", "reset=1&action=update&id=$id", "_qf_Fee_upload-bottom"); |
6a488035 TO |
196 | $this->type("discount_name_2", ""); |
197 | $this->click("xpath=//tr[@id='discount_2']/td[3]/span/a"); | |
198 | $this->click("xpath=//tr[@id='discount_2']/td[4]/span/a"); | |
199 | $this->type("discounted_value_1_2", ""); | |
200 | $this->type("discounted_value_2_2", ""); | |
201 | $this->click("_qf_Fee_upload-bottom"); | |
202 | sleep(3); | |
203 | //Assertions | |
204 | $this->open($this->sboxPath . "civicrm/admin/price?reset=1"); | |
205 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
206 | sleep(3); | |
207 | $this->assertStringsPresent($discount[1]); | |
208 | } | |
209 | ||
210 | function testAddPaidEventWithTemplate() { | |
6a488035 TO |
211 | |
212 | // Log in using webtestLogin() method | |
213 | $this->webtestLogin(); | |
214 | ||
215 | // We need a payment processor | |
216 | $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7); | |
217 | $this->webtestAddPaymentProcessor($processorName); | |
218 | ||
6a488035 TO |
219 | $this->open($this->sboxPath . "civicrm/event/add?reset=1&action=add"); |
220 | ||
221 | $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7); | |
222 | $eventDescription = "Here is a description for this conference."; | |
223 | // Select paid online registration template. | |
224 | $templateID = 6; | |
225 | $eventTypeID = 1; | |
226 | $this->_testAddEventInfoFromTemplate($eventTitle, $eventDescription, $templateID, $eventTypeID); | |
227 | ||
228 | $streetAddress = "100 Main Street"; | |
229 | $this->_testAddLocation($streetAddress); | |
230 | ||
231 | $this->_testAddFees(FALSE, FALSE, $processorName); | |
232 | ||
233 | // intro text for registration page | |
234 | $registerIntro = "Fill in all the fields below and click Continue."; | |
235 | $this->_testAddOnlineRegistration($registerIntro); | |
236 | ||
237 | // $eventInfoStrings = array( $eventTitle, $eventDescription, $streetAddress ); | |
238 | $eventInfoStrings = array($eventTitle, $streetAddress); | |
239 | $this->_testVerifyEventInfo($eventTitle, $eventInfoStrings); | |
240 | ||
241 | $registerStrings = array("225.00", "Member", "300.00", "Non-member", $registerIntro); | |
242 | $this->_testVerifyRegisterPage($registerStrings); | |
243 | } | |
244 | ||
245 | function testAddFreeEventWithTemplate() { | |
6a488035 TO |
246 | |
247 | // Log in using webtestLogin() method | |
248 | $this->webtestLogin(); | |
42daf119 | 249 | |
6a488035 TO |
250 | $this->open($this->sboxPath . "civicrm/event/add?reset=1&action=add"); |
251 | ||
252 | $eventTitle = 'My Free Meeting - ' . substr(sha1(rand()), 0, 7); | |
253 | $eventDescription = "Here is a description for this free meeting."; | |
254 | // Select "Free Meeting with Online Registration" template (id = 5). | |
255 | $templateID = 5; | |
256 | $eventTypeID = 4; | |
257 | $this->_testAddEventInfoFromTemplate($eventTitle, $eventDescription, $templateID, $eventTypeID); | |
258 | ||
259 | $streetAddress = "100 Main Street"; | |
260 | $this->_testAddLocation($streetAddress); | |
261 | ||
262 | // Go to Fees tab and check that Paid Event is false (No) | |
263 | $this->click("link=Fees"); | |
264 | $this->waitForElementPresent("_qf_Fee_upload-bottom"); | |
265 | $this->verifyChecked("CIVICRM_QFID_0_is_monetary"); | |
266 | ||
267 | // intro text for registration page | |
268 | $registerIntro = "Fill in all the fields below and click Continue."; | |
269 | $this->_testAddOnlineRegistration($registerIntro); | |
270 | ||
271 | // $eventInfoStrings = array( $eventTitle, $eventDescription, $streetAddress ); | |
272 | $eventInfoStrings = array($eventTitle, $streetAddress); | |
273 | $this->_testVerifyEventInfo($eventTitle, $eventInfoStrings); | |
274 | ||
275 | $registerStrings = array($registerIntro); | |
276 | $this->_testVerifyRegisterPage($registerStrings); | |
277 | // make sure paid_event div is NOT present since this is a free event | |
278 | $this->verifyElementNotPresent("css=div.paid_event-section"); | |
279 | } | |
280 | ||
0dce9149 | 281 | function testUnpaidPaid() { |
0dce9149 PJ |
282 | |
283 | // Log in using webtestLogin() method | |
284 | $this->webtestLogin(); | |
285 | ||
0dce9149 PJ |
286 | $this->open($this->sboxPath . "civicrm/event/add?reset=1&action=add"); |
287 | $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7); | |
288 | $eventDescription = "Here is a description for this conference."; | |
289 | $this->_testAddEventInfo($eventTitle, $eventDescription); | |
290 | ||
291 | //add fee section with pay later checked | |
292 | $this->_testAddFees(FALSE, FALSE, NULL, FALSE, TRUE); | |
293 | ||
294 | //make the event unpaid | |
295 | $this->waitForElementPresent("_qf_Fee_upload-bottom"); | |
296 | $this->assertChecked('is_pay_later'); | |
297 | $this->click("CIVICRM_QFID_0_is_monetary"); | |
298 | $this->click("_qf_Fee_upload-bottom"); | |
299 | $this->waitForElementPresent("_qf_Fee_upload-bottom"); | |
300 | ||
301 | //check if pay later option is disabled | |
302 | $this->click('CIVICRM_QFID_1_is_monetary'); | |
303 | sleep(3); | |
304 | $this->waitForElementPresent('is_pay_later'); | |
305 | $this->assertNotChecked('is_pay_later'); | |
306 | } | |
307 | ||
6a488035 | 308 | function _testAddEventInfo($eventTitle, $eventDescription) { |
6a488035 TO |
309 | $this->waitForElementPresent("_qf_EventInfo_upload-bottom"); |
310 | ||
6a488035 TO |
311 | $this->select("event_type_id", "value=1"); |
312 | ||
313 | // Attendee role s/b selected now. | |
314 | $this->select("default_role_id", "value=1"); | |
315 | ||
316 | // Enter Event Title, Summary and Description | |
317 | $this->type("title", $eventTitle); | |
318 | $this->type("summary", "This is a great conference. Sign up now!"); | |
319 | ||
320 | // Type description in ckEditor (fieldname, text to type, editor) | |
321 | $this->fillRichTextField("description", $eventDescription, 'CKEditor'); | |
322 | ||
323 | // Choose Start and End dates. | |
324 | // Using helper webtestFillDate function. | |
325 | $this->webtestFillDateTime("start_date", "+1 week"); | |
326 | $this->webtestFillDateTime("end_date", "+1 week 1 day 8 hours "); | |
327 | ||
328 | $this->type("max_participants", "50"); | |
329 | $this->click("is_map"); | |
330 | $this->click("is_public"); | |
331 | $this->click("_qf_EventInfo_upload-bottom"); | |
0dce9149 | 332 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
6a488035 TO |
333 | } |
334 | ||
335 | function _testAddEventInfoFromTemplate($eventTitle, $eventDescription, $templateID, $eventTypeID) { | |
6a488035 | 336 | $this->waitForElementPresent("_qf_EventInfo_upload-bottom"); |
42daf119 | 337 | |
6a488035 TO |
338 | // Select event template. Use option value, not label - since labels can be translated and test would fail |
339 | $this->select("template_id", "value={$templateID}"); | |
340 | ||
341 | // Wait for event type to be filled in (since page reloads) | |
342 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
343 | $this->verifySelectedValue("event_type_id", $eventTypeID); | |
344 | ||
345 | // Attendee role s/b selected now. | |
346 | $this->verifySelectedValue("default_role_id", "1"); | |
347 | ||
348 | // Enter Event Title, Summary and Description | |
349 | $this->type("title", $eventTitle); | |
350 | $this->type("summary", "This is a great conference. Sign up now!"); | |
351 | ||
352 | // Type description in ckEditor (fieldname, text to type, editor) | |
353 | $this->fillRichTextField("description", $eventDescription, 'CKEditor'); | |
354 | ||
355 | // Choose Start and End dates. | |
356 | // Using helper webtestFillDate function. | |
357 | $this->webtestFillDateTime("start_date", "+1 week"); | |
358 | $this->webtestFillDateTime("end_date", "+1 week 1 day 8 hours "); | |
359 | ||
360 | $this->type("max_participants", "50"); | |
361 | $this->click("is_map"); | |
362 | $this->click("_qf_EventInfo_upload-bottom"); | |
363 | } | |
364 | ||
365 | function _testAddLocation($streetAddress) { | |
366 | // Wait for Location tab form to load | |
367 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
368 | $this->waitForElementPresent("_qf_Location_upload-bottom"); | |
369 | ||
370 | // Fill in address fields | |
371 | $streetAddress = "100 Main Street"; | |
372 | $this->type("address_1_street_address", $streetAddress); | |
373 | $this->type("address_1_city", "San Francisco"); | |
374 | $this->type("address_1_postal_code", "94117"); | |
375 | $this->select("address_1_state_province_id", "value=1004"); | |
376 | $this->type("email_1_email", "info@civicrm.org"); | |
377 | ||
378 | $this->click("_qf_Location_upload-bottom"); | |
379 | ||
380 | // Wait for "saved" status msg | |
381 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
382 | $this->waitForTextPresent("'Location' information has been saved."); | |
383 | } | |
384 | ||
0dce9149 | 385 | function _testAddFees($discount = FALSE, $priceSet = FALSE, $processorName = "PP Pro", $double = FALSE, $payLater = FALSE) { |
6a488035 TO |
386 | $discount1 = "Early-bird" . substr(sha1(rand()), 0, 7); |
387 | $discount2 = ""; | |
388 | // Go to Fees tab | |
389 | $this->click("link=Fees"); | |
390 | $this->waitForElementPresent("_qf_Fee_upload-bottom"); | |
391 | $this->click("CIVICRM_QFID_1_is_monetary"); | |
0dce9149 PJ |
392 | |
393 | if ($payLater) { | |
394 | $this->check('is_pay_later'); | |
395 | $this->type('pay_later_receipt', 'testing later instructions'); | |
396 | } | |
397 | else { | |
398 | $this->uncheck('is_pay_later'); | |
399 | } | |
400 | ||
401 | if ($processorName) { | |
402 | $this->click("xpath=//tr[@class='crm-event-manage-fee-form-block-payment_processor']/td[2]/label[text()='$processorName']"); | |
403 | } | |
6a488035 TO |
404 | $this->select("financial_type_id", "value=4"); |
405 | if ($priceSet) { | |
406 | // get one - TBD | |
407 | } | |
408 | else { | |
409 | $this->type("label_1", "Member"); | |
410 | $this->type("value_1", "225.00"); | |
411 | $this->type("label_2", "Non-member"); | |
412 | $this->type("value_2", "300.00"); | |
413 | $this->click("CIVICRM_QFID_1_4"); | |
414 | } | |
415 | ||
416 | if ($discount) { | |
417 | // enter early bird discount fees | |
418 | $this->click("is_discount"); | |
419 | $this->waitForElementPresent("discount_name_1"); | |
420 | $this->type("discount_name_1", $discount1); | |
421 | $this->webtestFillDate("discount_start_date_1", "-3 week"); | |
422 | $this->webtestFillDate("discount_end_date_1", "-2 week"); | |
423 | $this->click("_qf_Fee_submit"); | |
424 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
425 | $this->waitForElementPresent("discounted_value_1_1"); | |
426 | $this->type("discounted_value_1_1","225.00"); | |
427 | $this->type("discounted_value_2_1","300.00"); | |
428 | ||
429 | if ($double) { | |
430 | $discount2 = "Early-bird" . substr(sha1(rand()), 0, 7); | |
431 | // enter early bird discount fees | |
432 | $this->click("link=another discount set"); | |
433 | $this->waitForElementPresent("discount_name_2"); | |
434 | $this->type("discount_name_2", $discount2); | |
435 | $this->webtestFillDate("discount_start_date_2", "-1 week"); | |
436 | $this->webtestFillDate("discount_end_date_2", "+1 week"); | |
437 | $this->click("_qf_Fee_submit"); | |
438 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
439 | $this->waitForElementPresent("discounted_value_2_1"); | |
440 | $this->type("discounted_value_1_2","225.00"); | |
441 | $this->type("discounted_value_2_2","300.00"); | |
442 | } | |
443 | $this->click("xpath=//fieldset[@id='discount']/fieldset/table/tbody/tr[2]/td[3]/input"); | |
444 | } | |
445 | $this->click("_qf_Fee_upload-bottom"); | |
446 | ||
447 | // Wait for "saved" status msg | |
448 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
0dce9149 | 449 | $this->assertElementContainsText("crm-notification-container", "'Fee' information has been saved"); |
6a488035 TO |
450 | return array($discount1, $discount2); |
451 | } | |
452 | ||
453 | function _testAddOnlineRegistration($registerIntro, $multipleRegistrations = FALSE) { | |
454 | // Go to Online Registration tab | |
455 | $this->click("link=Online Registration"); | |
456 | $this->waitForElementPresent("_qf_Registration_upload-bottom"); | |
457 | ||
458 | $this->check("is_online_registration"); | |
459 | $this->assertChecked("is_online_registration"); | |
460 | if ($multipleRegistrations) { | |
461 | $this->check("is_multiple_registrations"); | |
462 | $this->assertChecked("is_multiple_registrations"); | |
463 | } | |
464 | ||
465 | $this->fillRichTextField("intro_text", $registerIntro); | |
466 | ||
467 | // enable confirmation email | |
468 | $this->click("CIVICRM_QFID_1_is_email_confirm"); | |
469 | $this->type("confirm_from_name", "Jane Doe"); | |
470 | $this->type("confirm_from_email", "jane.doe@example.org"); | |
471 | ||
472 | $this->click("_qf_Registration_upload-bottom"); | |
473 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
474 | $this->waitForTextPresent("'Registration' information has been saved."); | |
475 | } | |
476 | ||
477 | function _testVerifyEventInfo($eventTitle, $eventInfoStrings, $eventFees = NULL) { | |
478 | // verify event input on info page | |
479 | // start at Manage Events listing | |
480 | $this->open($this->sboxPath . "civicrm/event/manage?reset=1"); | |
481 | $this->click("link=$eventTitle"); | |
482 | ||
483 | // Look for Register button | |
484 | $this->waitForElementPresent("link=Register Now"); | |
485 | ||
486 | // Check for correct event info strings | |
487 | $this->assertStringsPresent($eventInfoStrings); | |
488 | ||
489 | // Optionally verify event fees (especially for discounts) | |
490 | if ($eventFees) { | |
491 | $this->assertStringsPresent($eventFees); | |
492 | } | |
493 | $elements = $this->parseURL(); | |
494 | return $elements['queryString']['id']; | |
495 | } | |
496 | ||
497 | function _testVerifyRegisterPage($registerStrings) { | |
498 | // Go to Register page and check for intro text and fee levels | |
499 | $this->click("link=Register Now"); | |
500 | $this->waitForElementPresent("_qf_Register_upload-bottom"); | |
501 | $this->assertStringsPresent($registerStrings); | |
502 | return $this->getLocation(); | |
503 | } | |
504 | ||
505 | function _testOnlineRegistration($registerUrl, $numberRegistrations = 1, $anonymous = TRUE) { | |
506 | if ($anonymous) { | |
42daf119 | 507 | $this->webtestLogout(); |
6a488035 TO |
508 | } |
509 | $this->open($registerUrl); | |
510 | ||
511 | $this->select("additional_participants", "value=" . $numberRegistrations); | |
512 | $this->type("email-Primary", "smith" . substr(sha1(rand()), 0, 7) . "@example.org"); | |
513 | ||
514 | $this->select("credit_card_type", "value=Visa"); | |
515 | $this->type("credit_card_number", "4111111111111111"); | |
516 | $this->type("cvv2", "000"); | |
517 | $this->select("credit_card_exp_date[M]", "value=1"); | |
518 | $this->select("credit_card_exp_date[Y]", "value=2020"); | |
519 | $this->type("billing_first_name", "Jane"); | |
520 | $this->type("billing_last_name", "Smith" . substr(sha1(rand()), 0, 7)); | |
521 | $this->type("billing_street_address-5", "15 Main St."); | |
522 | $this->type(" billing_city-5", "San Jose"); | |
523 | $this->select("billing_country_id-5", "value=1228"); | |
524 | $this->select("billing_state_province_id-5", "value=1004"); | |
525 | $this->type("billing_postal_code-5", "94129"); | |
526 | ||
527 | $this->click("_qf_Register_upload-bottom"); | |
528 | ||
529 | if ($numberRegistrations > 1) { | |
530 | for ($i = 1; $i <= $numberRegistrations; $i++) { | |
531 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
532 | // Look for Skip button | |
533 | $this->waitForElementPresent("_qf_Participant_{$i}_next_skip-Array"); | |
534 | $this->type("email-Primary", "smith" . substr(sha1(rand()), 0, 7) . "@example.org"); | |
535 | $this->click("_qf_Participant_{$i}_next"); | |
536 | } | |
537 | } | |
538 | ||
539 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
540 | $this->waitForElementPresent("_qf_Confirm_next-bottom"); | |
541 | $confirmStrings = array("Event Fee(s)", "Billing Name and Address", "Credit Card Information"); | |
542 | $this->assertStringsPresent($confirmStrings); | |
543 | $this->click("_qf_Confirm_next-bottom"); | |
544 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
545 | $thankStrings = array("Thank You for Registering", "Event Total", "Transaction Date"); | |
546 | $this->assertStringsPresent($thankStrings); | |
547 | } | |
548 | ||
549 | function _testAddReminder($eventTitle) { | |
550 | // Go to Schedule Reminders tab | |
551 | $this->click('css=li#tab_reminder a'); | |
552 | $this->waitForElementPresent("_qf_ScheduleReminders_upload-bottom"); | |
553 | $this->type("title", "Event Reminder for " . $eventTitle); | |
554 | $this->select('entity', 'label=Registered'); | |
555 | ||
556 | $this->select('start_action_offset', 'label=1'); | |
557 | $this->select('start_action_condition', 'label=after'); | |
558 | $this->click('is_repeat'); | |
559 | $this->select('repetition_frequency_interval', 'label=2'); | |
560 | $this->select('end_date', 'label=Event End Date'); | |
561 | $this->click('recipient'); | |
562 | $this->select('recipient', 'label=Participant Role'); | |
563 | // $this->select( 'recipient_listing', 'value=1' ); | |
564 | ||
565 | // Fill Subject | |
566 | $subject = 'subject' . substr(sha1(rand()), 0, 4); | |
567 | $this->type('subject', $subject); | |
568 | $this->fillRichTextField("html_message", "This is the test HTML version here!!!", 'CKEditor'); | |
569 | ||
570 | $this->type("text_message", "This is the test text version here!!!"); | |
571 | //click on save | |
572 | $this->click('_qf_ScheduleReminders_upload-bottom'); | |
573 | $this->waitForElementPresent("link=Add Reminder"); | |
574 | ||
575 | $this->waitForElementPresent("link=Edit"); | |
576 | ||
577 | $verifyText = array( | |
578 | 1 => 'Event Reminder for ' . $eventTitle, | |
579 | 3 => '1 hour after Event Start Date', | |
580 | 4 => 'Registered', | |
581 | 5 => 'Yes', | |
582 | 6 => 'Yes', | |
583 | ); | |
584 | ||
585 | //verify the fields for Event Reminder selector | |
586 | foreach ($verifyText as $key => $value) { | |
587 | $this->verifyText("xpath=//table[@class='display']/tbody/tr/td[$key]", $value); | |
588 | } | |
589 | } | |
590 | ||
42daf119 | 591 | } |