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