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 | ||
6a488035 TO |
27 | require_once 'CiviTest/CiviSeleniumTestCase.php'; |
28 | class WebTest_Event_PricesetMaxCountTest extends CiviSeleniumTestCase { | |
29 | ||
30 | protected function setUp() { | |
31 | parent::setUp(); | |
32 | } | |
33 | ||
34 | function testWithoutFieldCount() { | |
6a488035 TO |
35 | // Log in using webtestLogin() method |
36 | $this->webtestLogin(); | |
37 | ||
38 | // We need a payment processor | |
39 | $processorName = 'Webtest Dummy' . substr(sha1(rand()), 0, 7); | |
40 | $this->webtestAddPaymentProcessor($processorName); | |
41 | ||
42 | // create priceset | |
43 | $priceset = 'Price - ' . substr(sha1(rand()), 0, 7); | |
44 | $financialType = 'Donation'; | |
45 | $this->_testAddSet($priceset, $financialType); | |
46 | ||
47 | // create price fields | |
48 | $fields = array( | |
49 | 'Full Conference' => array('type' => 'Text', | |
50 | 'amount' => '525.00', | |
51 | 'max_count' => 2, | |
52 | 'is_required' => TRUE, | |
53 | 'financial_type_id' => 1, | |
54 | ), | |
55 | 'Meal Choice' => array( | |
56 | 'type' => 'Select', | |
57 | 'options' => array( | |
58 | 1 => array('label' => 'Chicken', | |
59 | 'amount' => '525.00', | |
60 | 'max_count' => 1, | |
61 | 'financial_type_id' => 1, | |
62 | ), | |
63 | 2 => array( | |
64 | 'label' => 'Vegetarian', | |
65 | 'amount' => '200.00', | |
66 | 'max_count' => 5, | |
67 | 'financial_type_id' => 1, | |
68 | ), | |
69 | ), | |
70 | ), | |
71 | 'Pre-conference Meetup?' => array( | |
72 | 'type' => 'Radio', | |
73 | 'options' => array( | |
74 | 1 => array('label' => 'Yes', | |
75 | 'amount' => '50.00', | |
76 | 'max_count' => 1, | |
77 | 'financial_type_id' => 1, | |
78 | ), | |
79 | 2 => array( | |
80 | 'label' => 'No', | |
81 | 'amount' => '10', | |
82 | 'max_count' => 5, | |
83 | 'financial_type_id' => 1, | |
84 | ), | |
85 | ), | |
86 | ), | |
87 | 'Evening Sessions' => array( | |
88 | 'type' => 'CheckBox', | |
89 | 'options' => array( | |
90 | 1 => array('label' => 'First Five', | |
91 | 'amount' => '100.00', | |
92 | 'max_count' => 2, | |
93 | 'financial_type_id' => 1, | |
94 | ), | |
95 | 2 => array( | |
96 | 'label' => 'Second Four', | |
97 | 'amount' => '50.00', | |
98 | 'max_count' => 4, | |
99 | 'financial_type_id' => 1, | |
100 | ), | |
101 | ), | |
102 | ), | |
103 | ); | |
104 | ||
105 | // add price fields | |
106 | $this->_testAddPriceFields($fields); | |
107 | ||
108 | // get price set url. | |
109 | $pricesetLoc = $this->getLocation(); | |
110 | ||
111 | // get text field Id. | |
112 | $this->click("xpath=//div[@id='field_page']//table/tbody/tr[1]/td[9]/span[1]/a[2]"); | |
113 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
a471a3b6 | 114 | $textFieldId = $this->urlArg('fid'); |
6a488035 TO |
115 | |
116 | $this->open($pricesetLoc); | |
117 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
118 | ||
119 | // get select field id | |
120 | $this->click("xpath=//div[@id='field_page']//table/tbody/tr[2]/td[8]/a"); | |
121 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
122 | $selectFieldLoc = $this->getLocation(); | |
a471a3b6 | 123 | $selectFieldId = $this->urlArg('fid'); |
6a488035 TO |
124 | |
125 | // get select field ids | |
126 | // get select field option1 | |
127 | $this->click("xpath=//div[@id='field_page']//table/tbody/tr[1]/td[7]/span[1]/a[1]"); | |
128 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
a471a3b6 | 129 | $selectFieldOp1 = $this->urlArg('oid'); |
6a488035 TO |
130 | |
131 | $this->open($selectFieldLoc); | |
132 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
133 | ||
134 | // get select field option2 | |
135 | $this->click("xpath=//div[@id='field_page']//table/tbody/tr[2]/td[7]/span[1]/a[1]"); | |
136 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
a471a3b6 | 137 | $selectFieldOp2 = $this->urlArg('oid'); |
6a488035 TO |
138 | |
139 | // create event. | |
140 | $eventTitle = 'Meeting - ' . substr(sha1(rand()), 0, 7); | |
141 | $paramsEvent = array( | |
142 | 'title' => $eventTitle, | |
143 | 'template_id' => 6, | |
144 | 'event_type_id' => 4, | |
145 | 'payment_processor' => $processorName, | |
146 | 'price_set' => $priceset, | |
147 | ); | |
148 | ||
149 | $infoEvent = $this->_testAddEvent($paramsEvent); | |
150 | ||
151 | // logout to register for event. | |
42daf119 | 152 | $this->webtestLogout(); |
6a488035 TO |
153 | |
154 | // Register Participant 1 | |
155 | // visit event info page | |
156 | $this->open($infoEvent); | |
157 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
158 | ||
159 | // register for event | |
160 | $this->click('link=Register Now'); | |
161 | $this->waitForElementPresent('_qf_Register_upload-bottom'); | |
162 | ||
163 | // exceed maximun count for text field, check for form rule | |
164 | $this->type("xpath=//input[@id='price_{$textFieldId}']", '3'); | |
165 | ||
166 | $this->select("price_{$selectFieldId}", "value={$selectFieldOp1}"); | |
167 | ||
168 | $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org'; | |
169 | $this->type('email-Primary', $email); | |
170 | ||
171 | // fill billing related info | |
172 | $this->_fillRegisterWithBillingInfo(); | |
173 | ||
174 | $this->assertStringsPresent(array('Sorry, currently only 2 seats are available for this option.')); | |
175 | ||
176 | // fill correct value for text field | |
177 | $this->type("xpath=//input[@id='price_{$textFieldId}']", '1'); | |
178 | ||
179 | $this->click('_qf_Register_upload-bottom'); | |
180 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
181 | ||
182 | $this->_checkConfirmationAndRegister(); | |
183 | ||
184 | // Register Participant 2 | |
185 | // visit event info page | |
186 | $this->open($infoEvent); | |
187 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
188 | ||
189 | $this->click('link=Register Now'); | |
190 | $this->waitForElementPresent('_qf_Register_upload-bottom'); | |
191 | ||
192 | // exceed maximun count for text field, check for form rule | |
193 | $this->type("xpath=//input[@id='price_{$textFieldId}']", '2'); | |
194 | $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org'; | |
195 | $this->type('email-Primary', $email); | |
196 | ||
197 | // fill billing related info and register | |
198 | $this->_fillRegisterWithBillingInfo(); | |
199 | ||
200 | $this->assertStringsPresent(array('Sorry, currently only a single seat is available for this option.')); | |
201 | ||
202 | // fill correct value for test field | |
203 | $this->type("xpath=//input[@id='price_{$textFieldId}']", '1'); | |
204 | ||
205 | // select sold option for select field, check for form rule | |
206 | $this->select("price_{$selectFieldId}", "value={$selectFieldOp1}"); | |
207 | $this->click('_qf_Register_upload-bottom'); | |
208 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
209 | ||
210 | $this->assertStringsPresent(array('Sorry, this option is currently sold out.')); | |
211 | ||
212 | // fill correct available option for select field | |
213 | $this->select("price_{$selectFieldId}", "value={$selectFieldOp2}"); | |
214 | ||
215 | $this->click('_qf_Register_upload-bottom'); | |
216 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
217 | ||
218 | $this->_checkConfirmationAndRegister(); | |
219 | } | |
220 | ||
221 | function testWithFieldCount() { | |
6a488035 TO |
222 | // Log in using webtestLogin() method |
223 | $this->webtestLogin(); | |
224 | ||
225 | // We need a payment processor | |
226 | $processorName = 'Webtest Dummy' . substr(sha1(rand()), 0, 7); | |
227 | $this->webtestAddPaymentProcessor($processorName); | |
228 | ||
229 | // create priceset | |
230 | $priceset = 'Price - ' . substr(sha1(rand()), 0, 7); | |
231 | $financialType = 'Donation'; | |
232 | $this->_testAddSet($priceset, $financialType); | |
233 | ||
234 | // create price fields | |
235 | $fields = array( | |
236 | 'Full Conference' => array('type' => 'Text', | |
237 | 'amount' => '525.00', | |
238 | 'max_count' => 4, | |
239 | 'count' => 2, | |
240 | 'is_required' => TRUE, | |
241 | 'financial_type_id' => 1, | |
242 | ), | |
243 | 'Meal Choice' => array( | |
244 | 'type' => 'Select', | |
245 | 'options' => array( | |
246 | 1 => array('label' => 'Chicken', | |
247 | 'amount' => '525.00', | |
248 | 'max_count' => 2, | |
249 | 'count' => 2, | |
250 | 'financial_type_id' => 1, | |
251 | ), | |
252 | 2 => array( | |
253 | 'label' => 'Vegetarian', | |
254 | 'amount' => '200.00', | |
255 | 'max_count' => 10, | |
256 | 'count' => 5, | |
257 | 'financial_type_id' => 1, | |
258 | ), | |
259 | ), | |
260 | ), | |
261 | 'Pre-conference Meetup?' => array( | |
262 | 'type' => 'Radio', | |
263 | 'options' => array( | |
264 | 1 => array('label' => 'Yes', | |
265 | 'amount' => '50.00', | |
266 | 'max_count' => 2, | |
267 | 'count' => 1, | |
268 | 'financial_type_id' => 1, | |
269 | ), | |
270 | 2 => array( | |
271 | 'label' => 'No', | |
272 | 'amount' => '10', | |
273 | 'max_count' => 10, | |
274 | 'count' => 5, | |
275 | 'financial_type_id' => 1, | |
276 | ), | |
277 | ), | |
278 | ), | |
279 | 'Evening Sessions' => array( | |
280 | 'type' => 'CheckBox', | |
281 | 'options' => array( | |
282 | 1 => array('label' => 'First Five', | |
283 | 'amount' => '100.00', | |
284 | 'max_count' => 4, | |
285 | 'count' => 2, | |
286 | 'financial_type_id' => 1, | |
287 | ), | |
288 | 2 => array( | |
289 | 'label' => 'Second Four', | |
290 | 'amount' => '50.00', | |
291 | 'max_count' => 8, | |
292 | 'count' => 4, | |
293 | 'financial_type_id' => 1, | |
294 | ), | |
295 | ), | |
296 | ), | |
297 | ); | |
298 | ||
299 | // add price fields | |
300 | $this->_testAddPriceFields($fields); | |
301 | ||
302 | // get price set url. | |
303 | $pricesetLoc = $this->getLocation(); | |
304 | ||
305 | // get text field Id. | |
a471a3b6 CW |
306 | $this->clickLink("xpath=//div[@id='field_page']//table/tbody/tr[1]/td[9]/span[1]/a[2]"); |
307 | $textFieldId = $this->urlArg('fid'); | |
6a488035 TO |
308 | |
309 | $this->open($pricesetLoc); | |
310 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
311 | ||
312 | // get select field id | |
313 | $this->click("xpath=//div[@id='field_page']//table/tbody/tr[2]/td[8]/a"); | |
314 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
315 | $selectFieldLoc = $this->getLocation(); | |
a471a3b6 | 316 | $selectFieldId = $this->urlArg('fid'); |
6a488035 TO |
317 | |
318 | // get select field ids | |
319 | // get select field option1 | |
320 | $this->click("xpath=//div[@id='field_page']//table/tbody/tr[1]/td[7]/span[1]/a[1]"); | |
321 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
a471a3b6 | 322 | $selectFieldOp1 = $this->urlArg('oid'); |
6a488035 TO |
323 | |
324 | $this->open($selectFieldLoc); | |
325 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
326 | ||
327 | // get select field option2 | |
328 | $this->click("xpath=//div[@id='field_page']//table/tbody/tr[2]/td[7]/span[1]/a[1]"); | |
329 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
a471a3b6 | 330 | $selectFieldOp2 = $this->urlArg('oid'); |
6a488035 TO |
331 | |
332 | // create event. | |
333 | $eventTitle = 'Meeting - ' . substr(sha1(rand()), 0, 7); | |
334 | $paramsEvent = array( | |
335 | 'title' => $eventTitle, | |
336 | 'template_id' => 6, | |
337 | 'event_type_id' => 4, | |
338 | 'payment_processor' => $processorName, | |
339 | 'price_set' => $priceset, | |
340 | ); | |
341 | ||
342 | $infoEvent = $this->_testAddEvent($paramsEvent); | |
343 | ||
344 | // logout to register for event. | |
42daf119 | 345 | $this->webtestLogout(); |
6a488035 TO |
346 | |
347 | // Register Participant 1 | |
348 | // visit event info page | |
349 | $this->open($infoEvent); | |
350 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
351 | ||
352 | // register for event | |
353 | $this->click('link=Register Now'); | |
354 | $this->waitForElementPresent('_qf_Register_upload-bottom'); | |
355 | ||
356 | // check for form rule | |
357 | $this->type("xpath=//input[@id='price_{$textFieldId}']", '3'); | |
358 | ||
359 | $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org'; | |
360 | $this->type('email-Primary', $email); | |
361 | ||
362 | // fill billing related info | |
363 | $this->_fillRegisterWithBillingInfo(); | |
364 | ||
365 | $this->assertStringsPresent(array('Sorry, currently only 4 seats are available for this option.')); | |
366 | ||
367 | $this->select("price_{$selectFieldId}", "value={$selectFieldOp1}"); | |
368 | ||
369 | // fill correct value and register | |
370 | $this->type("xpath=//input[@id='price_{$textFieldId}']", '1'); | |
371 | ||
372 | $this->click('_qf_Register_upload-bottom'); | |
373 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
374 | ||
375 | $this->_checkConfirmationAndRegister(); | |
376 | ||
377 | // Register Participant 2 | |
378 | // visit event info page | |
379 | $this->open($infoEvent); | |
380 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
381 | ||
382 | $this->click('link=Register Now'); | |
383 | $this->waitForElementPresent('_qf_Register_upload-bottom'); | |
384 | ||
385 | // check for form rule | |
386 | $this->type("xpath=//input[@id='price_{$textFieldId}']", '2'); | |
387 | $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org'; | |
388 | $this->type('email-Primary', $email); | |
389 | ||
390 | // fill billing related info and register | |
391 | $this->_fillRegisterWithBillingInfo(); | |
392 | ||
393 | $this->assertStringsPresent(array('Sorry, currently only 2 seats are available for this option.')); | |
394 | ||
395 | // fill correct value and register | |
396 | $this->type("xpath=//input[@id='price_{$textFieldId}']", '1'); | |
397 | ||
398 | // check for sold option for select field | |
399 | $this->select("price_{$selectFieldId}", "value={$selectFieldOp1}"); | |
400 | ||
401 | $this->click('_qf_Register_upload-bottom'); | |
402 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
403 | ||
404 | $this->assertStringsPresent(array('Sorry, this option is currently sold out.')); | |
405 | ||
406 | // check for sold option for select field | |
407 | $this->select("price_{$selectFieldId}", "value={$selectFieldOp2}"); | |
408 | ||
409 | $this->click('_qf_Register_upload-bottom'); | |
410 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
411 | ||
412 | $this->_checkConfirmationAndRegister(); | |
413 | } | |
414 | ||
415 | function testAdditionalParticipantWithoutFieldCount() { | |
6a488035 TO |
416 | // Log in using webtestLogin() method |
417 | $this->webtestLogin(); | |
418 | ||
419 | // We need a payment processor | |
420 | $processorName = 'Webtest Dummy' . substr(sha1(rand()), 0, 7); | |
421 | $this->webtestAddPaymentProcessor($processorName); | |
422 | ||
423 | // create priceset | |
424 | $priceset = 'Price - ' . substr(sha1(rand()), 0, 7); | |
425 | $financialType = 'Donation'; | |
426 | $this->_testAddSet($priceset, $financialType); | |
427 | ||
428 | // create price fields | |
429 | $fields = array( | |
430 | 'Full Conference' => array('type' => 'Text', | |
431 | 'amount' => '525.00', | |
432 | 'max_count' => 6, | |
433 | 'is_required' => TRUE, | |
434 | 'financial_type_id' => 1, | |
435 | ), | |
436 | 'Meal Choice' => array( | |
437 | 'type' => 'Select', | |
438 | 'options' => array( | |
439 | 1 => array('label' => 'Chicken', | |
440 | 'amount' => '525.00', | |
441 | 'max_count' => 3, | |
442 | 'financial_type_id' => 1, | |
443 | ), | |
444 | 2 => array( | |
445 | 'label' => 'Vegetarian', | |
446 | 'amount' => '200.00', | |
447 | 'max_count' => 2, | |
448 | 'financial_type_id' => 1, | |
449 | ), | |
450 | ), | |
451 | ), | |
452 | 'Pre-conference Meetup?' => array( | |
453 | 'type' => 'Radio', | |
454 | 'options' => array( | |
455 | 1 => array('label' => 'Yes', | |
456 | 'amount' => '50.00', | |
457 | 'max_count' => 4, | |
458 | 'financial_type_id' => 1, | |
459 | ), | |
460 | 2 => array( | |
461 | 'label' => 'No', | |
462 | 'amount' => '10', | |
463 | 'max_count' => 5, | |
464 | 'financial_type_id' => 1, | |
465 | ), | |
466 | ), | |
467 | ), | |
468 | 'Evening Sessions' => array( | |
469 | 'type' => 'CheckBox', | |
470 | 'options' => array( | |
471 | 1 => array('label' => 'First Five', | |
472 | 'amount' => '100.00', | |
473 | 'max_count' => 6, | |
474 | 'financial_type_id' => 1, | |
475 | ), | |
476 | 2 => array( | |
477 | 'label' => 'Second Four', | |
478 | 'amount' => '50.00', | |
479 | 'max_count' => 4, | |
480 | 'financial_type_id' => 1, | |
481 | ), | |
482 | ), | |
483 | ), | |
484 | ); | |
485 | ||
486 | // add price fields | |
487 | $this->_testAddPriceFields($fields); | |
488 | ||
489 | // get price set url. | |
490 | $pricesetLoc = $this->getLocation(); | |
491 | ||
492 | // get text field Id. | |
a471a3b6 CW |
493 | $this->clickLink("xpath=//div[@id='field_page']//table/tbody/tr[1]/td[9]/span[1]/a[2]"); |
494 | $textFieldId = $this->urlArg('fid'); | |
6a488035 TO |
495 | |
496 | $this->open($pricesetLoc); | |
497 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
498 | ||
499 | // get select field id | |
500 | $this->click("xpath=//div[@id='field_page']//table/tbody/tr[2]/td[8]/a"); | |
501 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
502 | $selectFieldLoc = $this->getLocation(); | |
a471a3b6 | 503 | $selectFieldId = $this->urlArg('fid'); |
6a488035 TO |
504 | |
505 | // get select field ids | |
506 | // get select field option1 | |
507 | $this->click("xpath=//div[@id='field_page']//table/tbody/tr[1]/td[7]/span[1]/a[1]"); | |
508 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
a471a3b6 | 509 | $selectFieldOp1 = $this->urlArg('oid'); |
6a488035 TO |
510 | |
511 | $this->open($selectFieldLoc); | |
512 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
513 | ||
514 | // get select field option2 | |
515 | $this->click("xpath=//div[@id='field_page']//table/tbody/tr[2]/td[7]/span[1]/a[1]"); | |
516 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
a471a3b6 | 517 | $selectFieldOp2 = $this->urlArg('oid'); |
6a488035 TO |
518 | |
519 | // create event. | |
520 | $eventTitle = 'Meeting - ' . substr(sha1(rand()), 0, 7); | |
521 | $paramsEvent = array( | |
522 | 'title' => $eventTitle, | |
523 | 'template_id' => 6, | |
524 | 'event_type_id' => 4, | |
525 | 'payment_processor' => $processorName, | |
526 | 'price_set' => $priceset, | |
527 | 'is_multiple_registrations' => TRUE, | |
528 | ); | |
529 | ||
530 | $infoEvent = $this->_testAddEvent($paramsEvent); | |
531 | ||
532 | // logout to register for event. | |
42daf119 | 533 | $this->webtestLogout(); |
6a488035 TO |
534 | |
535 | // 1'st registration | |
536 | // Register Participant 1 | |
537 | // visit event info page | |
538 | $this->open($infoEvent); | |
539 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
540 | ||
541 | // register for event | |
542 | $this->click('link=Register Now'); | |
543 | $this->waitForElementPresent('_qf_Register_upload-bottom'); | |
544 | ||
545 | // select 3 participants ( including current ) | |
546 | $this->select('additional_participants', 'value=2'); | |
547 | ||
548 | // Check for Participant1 | |
549 | // exceed maximun count for text field, check for form rule | |
550 | $this->type("xpath=//input[@id='price_{$textFieldId}']", '7'); | |
551 | ||
552 | $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org'; | |
553 | $this->type('email-Primary', $email); | |
554 | ||
555 | // fill billing related info | |
556 | $this->_fillRegisterWithBillingInfo(); | |
557 | ||
558 | $this->assertStringsPresent(array('Sorry, currently only 6 seats are available for this option.')); | |
559 | ||
560 | // fill correct value for text field | |
561 | $this->type("xpath=//input[@id='price_{$textFieldId}']", '1'); | |
562 | $this->select("price_{$selectFieldId}", "value={$selectFieldOp2}"); | |
563 | ||
564 | $this->click('_qf_Register_upload-bottom'); | |
565 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
566 | ||
567 | // Check for Participant2 | |
568 | // exceed maximun count for text field, check for form rule | |
569 | $this->type("xpath=//input[@id='price_{$textFieldId}']", '6'); | |
570 | ||
571 | $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org'; | |
572 | $this->type('email-Primary', $email); | |
573 | ||
574 | $this->click('_qf_Participant_1_next-Array'); | |
575 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
576 | ||
577 | $this->assertStringsPresent(array('Sorry, currently only 6 seats are available for this option.')); | |
578 | ||
579 | // fill correct value for text field | |
580 | $this->type("xpath=//input[@id='price_{$textFieldId}']", '3'); | |
581 | $this->select("price_{$selectFieldId}", "value={$selectFieldOp2}"); | |
582 | ||
583 | $this->click('_qf_Participant_1_next-Array'); | |
584 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
585 | ||
586 | // Check for Participant3, check and skip | |
587 | // exceed maximun count for text field, check for form rule | |
588 | $this->type("xpath=//input[@id='price_{$textFieldId}']", '3'); | |
589 | ||
590 | $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org'; | |
591 | $this->type('email-Primary', $email); | |
592 | ||
593 | $this->click('_qf_Participant_2_next-Array'); | |
594 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
595 | ||
596 | $this->assertStringsPresent(array('Sorry, currently only 6 seats are available for this option.')); | |
597 | ||
598 | // fill correct value for text field | |
599 | $this->type("xpath=//input[@id='price_{$textFieldId}']", '1'); | |
600 | ||
601 | // check for select | |
602 | $this->select("price_{$selectFieldId}", "value={$selectFieldOp2}"); | |
603 | ||
604 | $this->click('_qf_Participant_2_next-Array'); | |
605 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
606 | ||
607 | $this->assertStringsPresent(array('Sorry, currently only 2 seats are available for this option.')); | |
608 | ||
609 | // Skip participant3 and register | |
610 | $this->click('_qf_Participant_2_next_skip-Array'); | |
611 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
612 | ||
613 | $this->_checkConfirmationAndRegister(); | |
614 | ||
6a488035 TO |
615 | // 2'st registration |
616 | // Register Participant 1 | |
617 | // visit event info page | |
618 | $this->open($infoEvent); | |
619 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
620 | ||
621 | // register for event | |
622 | $this->click('link=Register Now'); | |
623 | $this->waitForElementPresent('_qf_Register_upload-bottom'); | |
624 | ||
625 | // select 2 participants ( including current ) | |
626 | $this->select('additional_participants', 'value=1'); | |
627 | ||
628 | // Check for Participant1 | |
629 | // exceed maximun count for text field, check for form rule | |
630 | $this->type("xpath=//input[@id='price_{$textFieldId}']", '3'); | |
631 | ||
632 | $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org'; | |
633 | $this->type('email-Primary', $email); | |
634 | ||
635 | // fill billing related info | |
636 | $this->_fillRegisterWithBillingInfo(); | |
637 | ||
638 | $this->assertStringsPresent(array('Sorry, currently only 2 seats are available for this option.')); | |
639 | ||
640 | // fill correct value for text field | |
641 | $this->type("xpath=//input[@id='price_{$textFieldId}']", '1'); | |
642 | ||
643 | // check for select field | |
644 | $this->select("price_{$selectFieldId}", "value={$selectFieldOp2}"); | |
645 | ||
646 | $this->click('_qf_Register_upload-bottom'); | |
647 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
648 | ||
649 | $this->assertStringsPresent(array('Sorry, this option is currently sold out.')); | |
650 | ||
651 | // fill available value for select | |
652 | $this->select("price_{$selectFieldId}", "value={$selectFieldOp1}"); | |
653 | ||
654 | $this->click('_qf_Register_upload-bottom'); | |
655 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
656 | ||
657 | // Check for Participant2 | |
658 | // exceed maximun count for text field, check for form rule | |
659 | $this->type("xpath=//input[@id='price_{$textFieldId}']", '2'); | |
660 | ||
661 | $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org'; | |
662 | $this->type('email-Primary', $email); | |
663 | ||
664 | $this->click('_qf_Participant_1_next-Array'); | |
665 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
666 | ||
667 | $this->assertStringsPresent(array('Sorry, currently only 2 seats are available for this option.')); | |
668 | ||
669 | // fill correct value for text field | |
670 | $this->type("xpath=//input[@id='price_{$textFieldId}']", '1'); | |
671 | ||
672 | // check for select field | |
673 | $this->select("price_{$selectFieldId}", "value={$selectFieldOp2}"); | |
674 | ||
675 | $this->click('_qf_Participant_1_next-Array'); | |
676 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
677 | ||
678 | $this->assertStringsPresent(array('Sorry, this option is currently sold out.')); | |
679 | ||
680 | // fill available value for select | |
681 | $this->select("price_{$selectFieldId}", "value={$selectFieldOp1}"); | |
682 | ||
683 | $this->click('_qf_Participant_1_next-Array'); | |
684 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
685 | ||
686 | $this->_checkConfirmationAndRegister(); | |
687 | } | |
688 | ||
689 | function testAdditionalParticipantWithFieldCount() { | |
6a488035 TO |
690 | // Log in using webtestLogin() method |
691 | $this->webtestLogin(); | |
692 | ||
693 | // We need a payment processor | |
694 | $processorName = 'Webtest Dummy' . substr(sha1(rand()), 0, 7); | |
695 | $this->webtestAddPaymentProcessor($processorName); | |
696 | ||
697 | // create priceset | |
698 | $priceset = 'Price - ' . substr(sha1(rand()), 0, 7); | |
699 | $financialType = 'Donation'; | |
700 | $this->_testAddSet($priceset, $financialType); | |
701 | ||
702 | // create price fields | |
703 | $fields = array( | |
704 | 'Full Conference' => array('type' => 'Text', | |
705 | 'amount' => '525.00', | |
706 | 'count' => 2, | |
707 | 'max_count' => 12, | |
708 | 'is_required' => TRUE, | |
709 | 'financial_type_id' => 1, | |
710 | ), | |
711 | 'Meal Choice' => array( | |
712 | 'type' => 'Select', | |
713 | 'options' => array( | |
714 | 1 => array('label' => 'Chicken', | |
715 | 'amount' => '525.00', | |
716 | 'count' => 1, | |
717 | 'max_count' => 3, | |
718 | 'financial_type_id' => 1, | |
719 | ), | |
720 | 2 => array( | |
721 | 'label' => 'Vegetarian', | |
722 | 'amount' => '200.00', | |
723 | 'count' => 2, | |
724 | 'max_count' => 4, | |
725 | 'financial_type_id' => 1, | |
726 | ), | |
727 | ), | |
728 | ), | |
729 | 'Pre-conference Meetup?' => array( | |
730 | 'type' => 'Radio', | |
731 | 'options' => array( | |
732 | 1 => array('label' => 'Yes', | |
733 | 'amount' => '50.00', | |
734 | 'count' => 2, | |
735 | 'max_count' => 8, | |
736 | 'financial_type_id' => 1, | |
737 | ), | |
738 | 2 => array( | |
739 | 'label' => 'No', | |
740 | 'amount' => '10', | |
741 | 'count' => 5, | |
742 | 'max_count' => 25, | |
743 | 'financial_type_id' => 1, | |
744 | ), | |
745 | ), | |
746 | ), | |
747 | 'Evening Sessions' => array( | |
748 | 'type' => 'CheckBox', | |
749 | 'options' => array( | |
750 | 1 => array('label' => 'First Five', | |
751 | 'amount' => '100.00', | |
752 | 'count' => 2, | |
753 | 'max_count' => 16, | |
754 | 'financial_type_id' => 1, | |
755 | ), | |
756 | 2 => array( | |
757 | 'label' => 'Second Four', | |
758 | 'amount' => '50.00', | |
759 | 'count' => 1, | |
760 | 'max_count' => 4, | |
761 | 'financial_type_id' => 1, | |
762 | ), | |
763 | ), | |
764 | ), | |
765 | ); | |
766 | ||
767 | // add price fields | |
768 | $this->_testAddPriceFields($fields); | |
769 | ||
770 | // get price set url. | |
771 | $pricesetLoc = $this->getLocation(); | |
772 | ||
773 | // get text field Id. | |
774 | $this->click("xpath=//div[@id='field_page']//table/tbody/tr[1]/td[9]/span[1]/a[2]"); | |
775 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
a471a3b6 | 776 | $textFieldId = $this->urlArg('fid'); |
6a488035 TO |
777 | |
778 | $this->open($pricesetLoc); | |
779 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
780 | ||
781 | // get select field id | |
782 | $this->click("xpath=//div[@id='field_page']//table/tbody/tr[2]/td[8]/a"); | |
783 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
784 | $selectFieldLoc = $this->getLocation(); | |
a471a3b6 | 785 | $selectFieldId = $this->urlArg('fid'); |
6a488035 TO |
786 | |
787 | // get select field ids | |
788 | // get select field option1 | |
789 | $this->click("xpath=//div[@id='field_page']//table/tbody/tr[1]/td[7]/span[1]/a[1]"); | |
790 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
a471a3b6 | 791 | $selectFieldOp1 = $this->urlArg('oid'); |
6a488035 TO |
792 | |
793 | $this->open($selectFieldLoc); | |
794 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
795 | ||
796 | // get select field option2 | |
797 | $this->click("xpath=//div[@id='field_page']//table/tbody/tr[2]/td[7]/span[1]/a[1]"); | |
798 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
a471a3b6 | 799 | $selectFieldOp2 = $this->urlArg('oid'); |
6a488035 TO |
800 | |
801 | // create event. | |
802 | $eventTitle = 'Meeting - ' . substr(sha1(rand()), 0, 7); | |
803 | $paramsEvent = array( | |
804 | 'title' => $eventTitle, | |
805 | 'template_id' => 6, | |
806 | 'event_type_id' => 4, | |
807 | 'payment_processor' => $processorName, | |
808 | 'price_set' => $priceset, | |
809 | 'is_multiple_registrations' => TRUE, | |
810 | ); | |
811 | ||
812 | $infoEvent = $this->_testAddEvent($paramsEvent); | |
813 | ||
814 | // logout to register for event. | |
42daf119 | 815 | $this->webtestLogout(); |
6a488035 TO |
816 | |
817 | // 1'st registration | |
818 | // Register Participant 1 | |
819 | // visit event info page | |
820 | $this->open($infoEvent); | |
821 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
822 | ||
823 | // register for event | |
824 | $this->click('link=Register Now'); | |
825 | $this->waitForElementPresent('_qf_Register_upload-bottom'); | |
826 | ||
827 | // select 3 participants ( including current ) | |
828 | $this->select('additional_participants', 'value=2'); | |
829 | ||
830 | // Check for Participant1 | |
831 | // exceed maximun count for text field, check for form rule | |
832 | $this->type("xpath=//input[@id='price_{$textFieldId}']", '7'); | |
833 | ||
834 | $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org'; | |
835 | $this->type('email-Primary', $email); | |
836 | ||
837 | // fill billing related info | |
838 | $this->_fillRegisterWithBillingInfo(); | |
839 | ||
840 | $this->assertStringsPresent(array('Sorry, currently only 12 seats are available for this option.')); | |
841 | ||
842 | // fill correct value for text field | |
843 | $this->type("xpath=//input[@id='price_{$textFieldId}']", '1'); | |
844 | $this->select("price_{$selectFieldId}", "value={$selectFieldOp2}"); | |
845 | ||
846 | $this->click('_qf_Register_upload-bottom'); | |
847 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
848 | ||
849 | // Check for Participant2 | |
850 | // exceed maximun count for text field, check for form rule | |
851 | $this->type("xpath=//input[@id='price_{$textFieldId}']", '6'); | |
852 | ||
853 | $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org'; | |
854 | $this->type('email-Primary', $email); | |
855 | ||
856 | $this->click('_qf_Participant_1_next-Array'); | |
857 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
858 | ||
859 | $this->assertStringsPresent(array('Sorry, currently only 12 seats are available for this option.')); | |
860 | ||
861 | // fill correct value for text field | |
862 | $this->type("xpath=//input[@id='price_{$textFieldId}']", '3'); | |
863 | $this->select("price_{$selectFieldId}", "value={$selectFieldOp2}"); | |
864 | ||
865 | $this->click('_qf_Participant_1_next-Array'); | |
866 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
867 | ||
868 | // Check for Participant3, check and skip | |
869 | // exceed maximun count for text field, check for form rule | |
870 | $this->type("xpath=//input[@id='price_{$textFieldId}']", '3'); | |
871 | ||
872 | $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org'; | |
873 | $this->type('email-Primary', $email); | |
874 | ||
875 | $this->click('_qf_Participant_2_next-Array'); | |
876 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
877 | ||
878 | $this->assertStringsPresent(array('Sorry, currently only 12 seats are available for this option.')); | |
879 | ||
880 | // fill correct value for text field | |
881 | $this->type("xpath=//input[@id='price_{$textFieldId}']", '1'); | |
882 | ||
883 | // check for select | |
884 | $this->select("price_{$selectFieldId}", "value={$selectFieldOp2}"); | |
885 | ||
886 | $this->click('_qf_Participant_2_next-Array'); | |
887 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
888 | ||
889 | $this->assertStringsPresent(array('Sorry, currently only 4 seats are available for this option.')); | |
890 | ||
891 | // Skip participant3 and register | |
892 | $this->click('_qf_Participant_2_next_skip-Array'); | |
893 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
894 | ||
895 | $this->_checkConfirmationAndRegister(); | |
896 | ||
6a488035 TO |
897 | // 2'st registration |
898 | // Register Participant 1 | |
899 | // visit event info page | |
900 | $this->open($infoEvent); | |
901 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
902 | ||
903 | // register for event | |
904 | $this->click('link=Register Now'); | |
905 | $this->waitForElementPresent('_qf_Register_upload-bottom'); | |
906 | ||
907 | // select 2 participants ( including current ) | |
908 | $this->select('additional_participants', 'value=1'); | |
909 | ||
910 | // Check for Participant1 | |
911 | // exceed maximun count for text field, check for form rule | |
912 | $this->type("xpath=//input[@id='price_{$textFieldId}']", '3'); | |
913 | ||
914 | $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org'; | |
915 | $this->type('email-Primary', $email); | |
916 | ||
917 | // fill billing related info | |
918 | $this->_fillRegisterWithBillingInfo(); | |
919 | ||
920 | $this->assertStringsPresent(array('Sorry, currently only 4 seats are available for this option.')); | |
921 | ||
922 | // fill correct value for text field | |
923 | $this->type("xpath=//input[@id='price_{$textFieldId}']", '1'); | |
924 | ||
925 | // check for select field | |
926 | $this->select("price_{$selectFieldId}", "value={$selectFieldOp2}"); | |
927 | ||
928 | $this->click('_qf_Register_upload-bottom'); | |
929 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
930 | ||
931 | $this->assertStringsPresent(array('Sorry, this option is currently sold out.')); | |
932 | ||
933 | // fill available value for select | |
934 | $this->select("price_{$selectFieldId}", "value={$selectFieldOp1}"); | |
935 | ||
936 | $this->click('_qf_Register_upload-bottom'); | |
937 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
938 | ||
939 | // Check for Participant2 | |
940 | // exceed maximun count for text field, check for form rule | |
941 | $this->type("xpath=//input[@id='price_{$textFieldId}']", '2'); | |
942 | ||
943 | $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org'; | |
944 | $this->type('email-Primary', $email); | |
945 | ||
946 | $this->click('_qf_Participant_1_next-Array'); | |
947 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
948 | ||
949 | $this->assertStringsPresent(array('Sorry, currently only 4 seats are available for this option.')); | |
950 | ||
951 | // fill correct value for text field | |
952 | $this->type("xpath=//input[@id='price_{$textFieldId}']", '1'); | |
953 | ||
954 | // check for select field | |
955 | $this->select("price_{$selectFieldId}", "value={$selectFieldOp2}"); | |
956 | ||
957 | $this->click('_qf_Participant_1_next-Array'); | |
958 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
959 | ||
960 | $this->assertStringsPresent(array('Sorry, this option is currently sold out.')); | |
961 | ||
962 | // fill available value for select | |
963 | $this->select("price_{$selectFieldId}", "value={$selectFieldOp1}"); | |
964 | ||
965 | $this->click('_qf_Participant_1_next-Array'); | |
966 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
967 | ||
968 | $this->_checkConfirmationAndRegister(); | |
969 | } | |
970 | ||
971 | function _testAddSet($setTitle, $financialType = NULL) { | |
42daf119 | 972 | $this->openCiviPage('admin/price', 'reset=1&action=add', '_qf_Set_next-bottom'); |
6a488035 TO |
973 | |
974 | // Enter Priceset fields (Title, Used For ...) | |
975 | $this->type('title', $setTitle); | |
976 | $this->check('extends_1'); | |
977 | ||
978 | if ($financialType) { | |
979 | $this->select("css=select.form-select", "label={$financialType}"); | |
980 | } | |
981 | ||
982 | $this->click("xpath=//form[@id='Set']/div[3]/table/tbody/tr[4]/td[2]/select"); | |
983 | $this->type('help_pre', 'This is test priceset.'); | |
984 | ||
985 | $this->assertChecked('is_active', 'Verify that Is Active checkbox is set.'); | |
225a8648 | 986 | $this->clickLink('_qf_Set_next-bottom', '_qf_Field_next-bottom'); |
6a488035 TO |
987 | } |
988 | ||
989 | function _testAddPriceFields($fields) { | |
990 | $fieldCount = count($fields); | |
991 | $count = 1; | |
992 | foreach ($fields as $label => $field) { | |
993 | $this->type('label', $label); | |
994 | $this->select('html_type', "value={$field['type']}"); | |
995 | ||
996 | if ($field['type'] == 'Text') { | |
997 | $this->type('price', $field['amount']); | |
998 | ||
999 | if (isset($field['count'])) { | |
1000 | $this->waitForElementPresent('count'); | |
1001 | $this->type('count', $field['count']); | |
1002 | } | |
1003 | ||
1004 | if (isset($field['count'])) { | |
1005 | $this->waitForElementPresent('count'); | |
1006 | $this->type('count', $field['count']); | |
1007 | } | |
1008 | ||
1009 | if (isset($field['max_count'])) { | |
1010 | $this->waitForElementPresent('max_value'); | |
1011 | $this->type('max_value', $field['max_count']); | |
1012 | } | |
1013 | ||
1014 | if (isset($field['financial_type_id'])) { | |
1015 | $this->waitForElementPresent('financial_type_id'); | |
1016 | $this->select('financial_type_id', "value={$field['financial_type_id']}"); | |
76e86fd8 CW |
1017 | } |
1018 | ||
6a488035 TO |
1019 | } |
1020 | else { | |
1021 | $this->_testAddMultipleChoiceOptions($field['options'], $field['type']); | |
1022 | } | |
1023 | ||
1024 | if (isset($field['is_required']) && $field['is_required']) { | |
1025 | $this->check('is_required'); | |
1026 | } | |
1027 | ||
1028 | if ($count < $fieldCount) { | |
1029 | $this->click('_qf_Field_next_new-bottom'); | |
1030 | } | |
1031 | else { | |
1032 | $this->click('_qf_Field_next-bottom'); | |
1033 | } | |
1034 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
1035 | ||
1036 | $count++; | |
1037 | } | |
1038 | } | |
1039 | ||
1040 | function _testAddMultipleChoiceOptions($options, $fieldType) { | |
1041 | foreach ($options as $oIndex => $oValue) { | |
1042 | $this->type("option_label_{$oIndex}", $oValue['label']); | |
1043 | $this->type("option_amount_{$oIndex}", $oValue['amount']); | |
1044 | ||
1045 | if (isset($oValue['count'])) { | |
1046 | $this->waitForElementPresent("option_count_{$oIndex}"); | |
1047 | $this->type("option_count_{$oIndex}", $oValue['count']); | |
1048 | } | |
1049 | ||
1050 | if (isset($oValue['max_count'])) { | |
1051 | $this->waitForElementPresent("option_max_value_{$oIndex}"); | |
1052 | $this->type("option_max_value_{$oIndex}", $oValue['max_count']); | |
1053 | } | |
76e86fd8 | 1054 | |
6a488035 TO |
1055 | if (!empty($oValue['financial_type_id'])) { |
1056 | $this->select( "option_financial_type_id_{$oIndex}", "value={$oValue['financial_type_id']}" ); | |
1057 | } | |
76e86fd8 | 1058 | |
6a488035 TO |
1059 | $this->click('link=another choice'); |
1060 | } | |
1061 | ||
1062 | // select first element as default | |
1063 | if ($fieldType == 'CheckBox') { | |
1064 | $this->click('default_checkbox_option[1]'); | |
1065 | } | |
1066 | else { | |
1067 | $this->click('CIVICRM_QFID_1_2'); | |
1068 | } | |
1069 | } | |
1070 | ||
1071 | function _testAddEvent($params) { | |
42daf119 | 1072 | $this->openCiviPage('event/add', 'reset=1&action=add', '_qf_EventInfo_upload-bottom'); |
6a488035 | 1073 | |
6a488035 TO |
1074 | $this->select('event_type_id', "value={$params['event_type_id']}"); |
1075 | ||
1076 | // Attendee role s/b selected now. | |
1077 | $this->select('default_role_id', 'value=1'); | |
1078 | ||
1079 | // Enter Event Title, Summary and Description | |
1080 | $this->type('title', $params['title']); | |
1081 | $this->type('summary', 'This is a great conference. Sign up now!'); | |
1082 | $this->fillRichTextField('description', 'Here is a description for this event.', 'CKEditor'); | |
1083 | ||
1084 | // Choose Start and End dates. | |
1085 | // Using helper webtestFillDate function. | |
1086 | $this->webtestFillDateTime('start_date', '+1 week'); | |
1087 | $this->webtestFillDateTime('end_date', '+1 week 1 day 8 hours '); | |
1088 | ||
1089 | $this->type('max_participants', '50'); | |
1090 | $this->click('is_map'); | |
1091 | $this->click('_qf_EventInfo_upload-bottom'); | |
1092 | ||
1093 | // Wait for Location tab form to load | |
1094 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
1095 | ||
1096 | // Go to Fees tab | |
1097 | $this->click('link=Fees'); | |
1098 | $this->waitForElementPresent('_qf_Fee_upload-bottom'); | |
1099 | $this->click('xpath=//form[@id="Fee"]/div[2]/table/tbody/tr[2]/td[2]/label[contains(text(), "Yes")]'); | |
1100 | $processorName = $params['payment_processor']; | |
1101 | $this->click("xpath=//tr[@class='crm-event-manage-fee-form-block-payment_processor']/td[2]/label[text()='$processorName']"); | |
1102 | $this->select('financial_type_id', 'value=4'); | |
76e86fd8 | 1103 | |
6a488035 TO |
1104 | if (array_key_exists('price_set', $params)) { |
1105 | $this->select('price_set_id', 'label=' . $params['price_set']); | |
1106 | } | |
1107 | if (array_key_exists('fee_level', $params)) { | |
1108 | $counter = 1; | |
1109 | foreach ($params['fee_level'] as $label => $amount) { | |
1110 | $this->type("label_{$counter}", $label); | |
1111 | $this->type("value_{$counter}", $amount); | |
1112 | $counter++; | |
1113 | } | |
1114 | } | |
1115 | ||
1116 | $this->click('_qf_Fee_upload-bottom'); | |
1117 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
1118 | ||
1119 | // Go to Online Registration tab | |
1120 | $this->click('link=Online Registration'); | |
1121 | $this->waitForElementPresent('_qf_Registration_upload-bottom'); | |
1122 | ||
1123 | $this->check('is_online_registration'); | |
1124 | $this->assertChecked('is_online_registration'); | |
1125 | ||
1126 | if (isset($params['is_multiple_registrations']) && $params['is_multiple_registrations']) { | |
1127 | $this->click('is_multiple_registrations'); | |
1128 | } | |
1129 | ||
1130 | $this->fillRichTextField('intro_text', 'Fill in all the fields below and click Continue.'); | |
1131 | ||
1132 | // enable confirmation email | |
1133 | $this->click('CIVICRM_QFID_1_is_email_confirm'); | |
1134 | $this->type('confirm_from_name', 'Jane Doe'); | |
1135 | $this->type('confirm_from_email', 'jane.doe@example.org'); | |
1136 | ||
1137 | $this->click('_qf_Registration_upload-bottom'); | |
1138 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
1139 | $this->waitForTextPresent("'Registration' information has been saved."); | |
1140 | ||
1141 | // verify event input on info page | |
1142 | // start at Manage Events listing | |
42daf119 | 1143 | $this->openCiviPage('event/manage', 'reset=1'); |
6a488035 TO |
1144 | $this->click('link=' . $params['title']); |
1145 | ||
1146 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
1147 | return $this->getLocation(); | |
1148 | } | |
1149 | ||
1150 | function _fillRegisterWithBillingInfo() { | |
1151 | $this->waitForElementPresent('credit_card_type'); | |
1152 | $this->select('credit_card_type', 'value=Visa'); | |
1153 | $this->type('credit_card_number', '4111111111111111'); | |
1154 | $this->type('cvv2', '000'); | |
1155 | $this->select('credit_card_exp_date[M]', 'value=1'); | |
1156 | $this->select('credit_card_exp_date[Y]', 'value=2020'); | |
1157 | $this->type('billing_first_name', 'Jane_' . substr(sha1(rand()), 0, 5)); | |
1158 | $this->type('billing_last_name', 'San_' . substr(sha1(rand()), 0, 5)); | |
1159 | $this->type('billing_street_address-5', '15 Main St.'); | |
1160 | $this->type(' billing_city-5', 'San Jose'); | |
1161 | $this->select('billing_country_id-5', 'value=1228'); | |
1162 | $this->select('billing_state_province_id-5', 'value=1004'); | |
1163 | $this->type('billing_postal_code-5', '94129'); | |
1164 | ||
1165 | $this->click('_qf_Register_upload-bottom'); | |
1166 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
1167 | } | |
1168 | ||
1169 | function _checkConfirmationAndRegister() { | |
1170 | $confirmStrings = array('Event Fee(s)', 'Billing Name and Address', 'Credit Card Information'); | |
1171 | $this->assertStringsPresent($confirmStrings); | |
1172 | $this->click('_qf_Confirm_next-bottom'); | |
1173 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
1174 | $thankStrings = array('Thank You for Registering', 'Event Total', 'Transaction Date'); | |
1175 | $this->assertStringsPresent($thankStrings); | |
1176 | } | |
1177 | } | |
1178 |