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