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