3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
27 require_once 'CiviTest/CiviSeleniumTestCase.php';
30 * Class WebTest_Event_PricesetMaxCountTest
32 class WebTest_Event_PricesetMaxCountTest
extends CiviSeleniumTestCase
{
34 protected function setUp() {
38 public function testWithoutFieldCount() {
39 // Log in using webtestLogin() method
40 $this->webtestLogin();
42 // Use default payment processor
43 $processorName = 'Test Processor';
44 $this->webtestAddPaymentProcessor($processorName);
47 $priceset = 'Price - ' . substr(sha1(rand()), 0, 7);
48 $financialType = 'Donation';
49 $this->_testAddSet($priceset, $financialType);
51 // create price fields
53 'Full Conference' => array(
57 'is_required' => TRUE,
58 'financial_type_id' => 1,
60 'Meal Choice' => array(
67 'financial_type_id' => 1,
70 'label' => 'Vegetarian',
73 'financial_type_id' => 1,
77 'Pre-conference Meetup?' => array(
84 'financial_type_id' => 1,
90 'financial_type_id' => 1,
94 'Evening Sessions' => array(
98 'label' => 'First Five',
101 'financial_type_id' => 1,
104 'label' => 'Second Four',
107 'financial_type_id' => 1,
114 $this->_testAddPriceFields($fields);
116 // get price set url.
117 $pricesetLoc = $this->getLocation();
119 // get text field Id.
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);
124 $this->open($pricesetLoc);
125 $this->waitForPageToLoad($this->getTimeoutMsec());
127 // get select field id
128 $this->click("xpath=//div[@id='field_page']//table/tbody/tr[2]/td[8]/a");
129 $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button[2]/span[2]");
130 $selectFieldLoc = $this->getLocation();
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);
134 // get select field ids
135 // get select field option1
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);
139 // get select field option2
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);
144 $eventTitle = 'Meeting - ' . substr(sha1(rand()), 0, 7);
145 $paramsEvent = array(
146 'title' => $eventTitle,
148 'event_type_id' => 4,
149 'payment_processor' => $processorName,
150 'price_set' => $priceset,
153 $infoEvent = $this->_testAddEvent($paramsEvent);
155 // logout to register for event.
156 $this->webtestLogout();
158 // Register Participant 1
159 // visit event info page
160 $this->open($infoEvent);
161 $this->waitForPageToLoad($this->getTimeoutMsec());
163 // register for event
164 $this->click('link=Register Now');
165 $this->waitForElementPresent('_qf_Register_upload-bottom');
167 // exceed maximun count for text field, check for form rule
168 $this->type("xpath=//input[@id='price_{$textFieldId}']", '3');
170 $this->select("price_{$selectFieldId}", "value={$selectFieldOp1}");
172 $this->type('first_name', 'Mary');
173 $this->type('last_name', 'Jones' . substr(sha1(rand()), 0, 5));
174 $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org';
175 $this->type('email-Primary', $email);
177 // fill billing related info
178 $this->_fillRegisterWithBillingInfo();
180 $this->assertStringsPresent(array('Sorry, currently only 2 seats are available for this option.'));
182 // fill correct value for text field
183 $this->type("xpath=//input[@id='price_{$textFieldId}']", '1');
185 $this->click('_qf_Register_upload-bottom');
186 $this->waitForPageToLoad($this->getTimeoutMsec());
188 $this->_checkConfirmationAndRegister();
190 // Register Participant 2
191 // visit event info page
192 $this->open($infoEvent);
193 $this->waitForPageToLoad($this->getTimeoutMsec());
195 $this->click('link=Register Now');
196 $this->waitForElementPresent('_qf_Register_upload-bottom');
198 // exceed maximun count for text field, check for form rule
199 $this->type("xpath=//input[@id='price_{$textFieldId}']", '2');
200 $this->type('first_name', 'Mary');
201 $this->type('last_name', 'Jane' . substr(sha1(rand()), 0, 5));
202 $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org';
203 $this->type('email-Primary', $email);
205 // fill billing related info and register
206 $this->_fillRegisterWithBillingInfo();
208 $this->assertStringsPresent(array('Sorry, currently only a single seat is available for this option.'));
210 // fill correct value for test field
211 $this->type("xpath=//input[@id='price_{$textFieldId}']", '1');
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());
218 $this->assertStringsPresent(array('Sorry, this option is currently sold out.'));
220 // fill correct available option for select field
221 $this->select("price_{$selectFieldId}", "value={$selectFieldOp2}");
223 $this->click("css=input[data-amount=10]");
224 $this->click('_qf_Register_upload-bottom');
225 $this->waitForPageToLoad($this->getTimeoutMsec());
227 $this->_checkConfirmationAndRegister();
230 public function testWithFieldCount() {
231 // Log in using webtestLogin() method
232 $this->webtestLogin();
234 // Use default payment processor
235 $processorName = 'Test Processor';
236 $this->webtestAddPaymentProcessor($processorName);
239 $priceset = 'Price - ' . substr(sha1(rand()), 0, 7);
240 $financialType = 'Donation';
241 $this->_testAddSet($priceset, $financialType);
243 // create price fields
245 'Full Conference' => array(
247 'amount' => '525.00',
250 'is_required' => TRUE,
251 'financial_type_id' => 1,
253 'Meal Choice' => array(
257 'label' => 'Chicken',
258 'amount' => '525.00',
261 'financial_type_id' => 1,
264 'label' => 'Vegetarian',
265 'amount' => '200.00',
268 'financial_type_id' => 1,
272 'Pre-conference Meetup?' => array(
280 'financial_type_id' => 1,
287 'financial_type_id' => 1,
291 'Evening Sessions' => array(
292 'type' => 'CheckBox',
295 'label' => 'First Five',
296 'amount' => '100.00',
299 'financial_type_id' => 1,
302 'label' => 'Second Four',
306 'financial_type_id' => 1,
313 $this->_testAddPriceFields($fields);
315 // get price set url.
316 $pricesetLoc = $this->getLocation();
318 // get text field Id.
319 $this->waitForElementPresent("xpath=//div[@id='crm-main-content-wrapper']/div/a[1]");
320 $textFieldIdURL = $this->getAttribute("xpath=//div[@id='field_page']//table/tbody/tr[1]/td[9]/span[1]/a[2]@href");
321 $textFieldId = $this->urlArg('fid', $textFieldIdURL);
323 $this->open($pricesetLoc);
324 $this->waitForPageToLoad($this->getTimeoutMsec());
326 // get select field id
327 $this->click("xpath=//div[@id='field_page']//table/tbody/tr[2]/td[8]/a");
328 $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button[2]/span[2]");
329 $selectFieldLoc = $this->getLocation();
330 $selectFieldURL = $this->getAttribute("xpath=//div[@id='field_page']//table/tbody/tr[2]/td[9]/span[1]/a[2]@href");
331 $selectFieldId = $this->urlArg('fid', $selectFieldURL);
333 // get select field ids
334 // get select field option1
335 $selectFieldOp1URL = $this->getAttribute("xpath=//div[@id='field_page']//table/tbody/tr[1]/td[7]/span[1]/a[1]@href");
336 $selectFieldOp1 = $this->urlArg('oid', $selectFieldOp1URL);
338 // get select field option2
339 $selectFieldOp2URL = $this->getAttribute("xpath=//div[@id='field_page']//table/tbody/tr[2]/td[7]/span[1]/a[1]@href");
340 $selectFieldOp2 = $this->urlArg('oid', $selectFieldOp2URL);
343 $eventTitle = 'Meeting - ' . substr(sha1(rand()), 0, 7);
344 $paramsEvent = array(
345 'title' => $eventTitle,
347 'event_type_id' => 4,
348 'payment_processor' => $processorName,
349 'price_set' => $priceset,
352 $infoEvent = $this->_testAddEvent($paramsEvent);
354 // logout to register for event.
355 $this->webtestLogout();
357 // Register Participant 1
358 // visit event info page
359 $this->open($infoEvent);
360 $this->waitForPageToLoad($this->getTimeoutMsec());
362 // register for event
363 $this->click('link=Register Now');
364 $this->waitForElementPresent('_qf_Register_upload-bottom');
366 // check for form rule
367 $this->type("xpath=//input[@id='price_{$textFieldId}']", '3');
369 $this->type('first_name', 'Mary');
370 $this->type('last_name', 'Jane' . substr(sha1(rand()), 0, 5));
371 $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org';
372 $this->type('email-Primary', $email);
374 // fill billing related info
375 $this->_fillRegisterWithBillingInfo();
377 $this->assertStringsPresent(array('Sorry, currently only 4 seats are available for this option.'));
379 $this->select("price_{$selectFieldId}", "value={$selectFieldOp1}");
381 // fill correct value and register
382 $this->type("xpath=//input[@id='price_{$textFieldId}']", '1');
384 $this->click('_qf_Register_upload-bottom');
385 $this->waitForPageToLoad($this->getTimeoutMsec());
387 $this->_checkConfirmationAndRegister();
389 // Register Participant 2
390 // visit event info page
391 $this->open($infoEvent);
392 $this->waitForPageToLoad($this->getTimeoutMsec());
394 $this->click('link=Register Now');
395 $this->waitForElementPresent('_qf_Register_upload-bottom');
397 // check for form rule
398 $this->type("xpath=//input[@id='price_{$textFieldId}']", '2');
399 $this->type('first_name', 'Mary');
400 $this->type('last_name', 'Jane' . substr(sha1(rand()), 0, 5));
401 $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org';
402 $this->type('email-Primary', $email);
404 // fill billing related info and register
405 $this->_fillRegisterWithBillingInfo();
407 $this->assertStringsPresent(array('Sorry, currently only 2 seats are available for this option.'));
409 // fill correct value and register
410 $this->type("xpath=//input[@id='price_{$textFieldId}']", '1');
412 // check for sold option for select field
413 $this->select("price_{$selectFieldId}", "value={$selectFieldOp1}");
415 $this->click('_qf_Register_upload-bottom');
416 $this->waitForPageToLoad($this->getTimeoutMsec());
418 $this->assertStringsPresent(array('Sorry, this option is currently sold out.'));
420 // check for sold option for select field
421 $this->select("price_{$selectFieldId}", "value={$selectFieldOp2}");
423 $this->click('_qf_Register_upload-bottom');
424 $this->waitForPageToLoad($this->getTimeoutMsec());
426 $this->_checkConfirmationAndRegister();
429 public function testAdditionalParticipantWithoutFieldCount() {
430 // Log in using webtestLogin() method
431 $this->webtestLogin();
433 // Use default payment processor
434 $processorName = 'Test Processor';
435 $this->webtestAddPaymentProcessor($processorName);
438 $priceset = 'Price - ' . substr(sha1(rand()), 0, 7);
439 $financialType = 'Donation';
440 $this->_testAddSet($priceset, $financialType);
442 // create price fields
444 'Full Conference' => array(
446 'amount' => '525.00',
448 'is_required' => TRUE,
449 'financial_type_id' => 1,
451 'Meal Choice' => array(
455 'label' => 'Chicken',
456 'amount' => '525.00',
458 'financial_type_id' => 1,
461 'label' => 'Vegetarian',
462 'amount' => '200.00',
464 'financial_type_id' => 1,
468 'Pre-conference Meetup?' => array(
475 'financial_type_id' => 1,
481 'financial_type_id' => 1,
485 'Evening Sessions' => array(
486 'type' => 'CheckBox',
489 'label' => 'First Five',
490 'amount' => '100.00',
492 'financial_type_id' => 1,
495 'label' => 'Second Four',
498 'financial_type_id' => 1,
505 $this->_testAddPriceFields($fields);
507 // get price set url.
508 $pricesetLoc = $this->getLocation();
510 // get text field Id.
511 $this->waitForElementPresent("xpath=//div[@id='crm-main-content-wrapper']/div/a[1]");
512 $textFieldURL = $this->getAttribute("xpath=//div[@id='field_page']/table/tbody/tr[1]/td[9]/span[1]/a[2]@href");
513 $textFieldId = $this->urlArg('fid', $textFieldURL);
515 $this->open($pricesetLoc);
516 $this->waitForPageToLoad($this->getTimeoutMsec());
518 // get select field id
519 $this->click("xpath=//div[@id='field_page']//table/tbody/tr[2]/td[8]/a");
520 $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button[2]/span[2]");
521 $selectFieldLoc = $this->getLocation();
522 $selectFieldURL = $this->getAttribute("xpath=//div[@id='field_page']//table/tbody/tr[2]/td[9]/span[1]/a[2]@href");
523 $selectFieldId = $this->urlArg('fid', $selectFieldURL);
525 // get select field ids
526 // get select field option1
527 $selectFieldOp1URL = $this->getAttribute("xpath=//div[@id='field_page']/table/tbody/tr[1]/td[7]/span[1]/a[1]@href");
528 $selectFieldOp1 = $this->urlArg('oid', $selectFieldOp1URL);
530 // get select field option2
531 $selectFieldOp2URL = $this->getAttribute("xpath=//div[@id='field_page']/table/tbody/tr[2]/td[7]/span[1]/a[1]@href");
532 $selectFieldOp2 = $this->urlArg('oid', $selectFieldOp2URL);
535 $eventTitle = 'Meeting - ' . substr(sha1(rand()), 0, 7);
536 $paramsEvent = array(
537 'title' => $eventTitle,
539 'event_type_id' => 4,
540 'payment_processor' => $processorName,
541 'price_set' => $priceset,
542 'is_multiple_registrations' => TRUE,
545 $infoEvent = $this->_testAddEvent($paramsEvent);
547 // logout to register for event.
548 $this->webtestLogout();
551 // Register Participant 1
552 // visit event info page
553 $this->open($infoEvent);
554 $this->waitForPageToLoad($this->getTimeoutMsec());
556 // register for event
557 $this->click('link=Register Now');
558 $this->waitForElementPresent('_qf_Register_upload-bottom');
560 // select 3 participants ( including current )
561 $this->select('additional_participants', 'value=2');
563 // Check for Participant1
564 // exceed maximun count for text field, check for form rule
565 $this->type("xpath=//input[@id='price_{$textFieldId}']", '7');
567 $this->type('first_name', 'Mary');
568 $this->type('last_name', 'Jane' . substr(sha1(rand()), 0, 5));
569 $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org';
570 $this->type('email-Primary', $email);
572 // fill billing related info
573 $this->_fillRegisterWithBillingInfo();
575 $this->assertStringsPresent(array('Sorry, currently only 6 seats are available for this option.'));
577 // fill correct value for text field
578 $this->type("xpath=//input[@id='price_{$textFieldId}']", '1');
579 $this->select("price_{$selectFieldId}", "value={$selectFieldOp2}");
581 $this->click('_qf_Register_upload-bottom');
582 $this->waitForPageToLoad($this->getTimeoutMsec());
584 // Check for Participant2
585 // exceed maximun count for text field, check for form rule
586 $this->type("xpath=//input[@id='price_{$textFieldId}']", '6');
588 $this->type('first_name', 'Mary Add 2');
589 $this->type('last_name', 'Jane' . substr(sha1(rand()), 0, 5));
590 $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org';
591 $this->type('email-Primary', $email);
593 $this->click('_qf_Participant_1_next-Array');
594 $this->waitForPageToLoad($this->getTimeoutMsec());
596 $this->assertStringsPresent(array('Sorry, currently only 6 seats are available for this option.'));
598 // fill correct value for text field
599 $this->type("xpath=//input[@id='price_{$textFieldId}']", '3');
600 $this->select("price_{$selectFieldId}", "value={$selectFieldOp2}");
602 $this->click('_qf_Participant_1_next-Array');
603 $this->waitForPageToLoad($this->getTimeoutMsec());
605 // Check for Participant3, check and skip
606 // exceed maximun count for text field, check for form rule
607 $this->type("xpath=//input[@id='price_{$textFieldId}']", '3');
609 $this->type('first_name', 'Mary Add 2');
610 $this->type('last_name', 'Jane' . substr(sha1(rand()), 0, 5));
611 $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org';
612 $this->type('email-Primary', $email);
614 $this->click('_qf_Participant_2_next-Array');
615 $this->waitForPageToLoad($this->getTimeoutMsec());
617 $this->assertStringsPresent(array('Sorry, currently only 6 seats are available for this option.'));
619 // fill correct value for text field
620 $this->type("xpath=//input[@id='price_{$textFieldId}']", '1');
623 $this->select("price_{$selectFieldId}", "value={$selectFieldOp2}");
625 $this->click('_qf_Participant_2_next-Array');
626 $this->waitForPageToLoad($this->getTimeoutMsec());
628 $this->assertStringsPresent(array('Sorry, currently only 2 seats are available for this option.'));
630 // Skip participant3 and register
631 $this->click('_qf_Participant_2_next_skip-Array');
632 $this->waitForPageToLoad($this->getTimeoutMsec());
634 $this->_checkConfirmationAndRegister();
637 // Register Participant 1
638 // visit event info page
639 $this->open($infoEvent);
640 $this->waitForPageToLoad($this->getTimeoutMsec());
642 // register for event
643 $this->click('link=Register Now');
644 $this->waitForElementPresent('_qf_Register_upload-bottom');
646 // select 2 participants ( including current )
647 $this->select('additional_participants', 'value=1');
649 // Check for Participant1
650 // exceed maximun count for text field, check for form rule
651 $this->type("xpath=//input[@id='price_{$textFieldId}']", '3');
653 $this->type('first_name', 'Mary');
654 $this->type('last_name', 'Jane' . substr(sha1(rand()), 0, 5));
655 $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org';
656 $this->type('email-Primary', $email);
658 // fill billing related info
659 $this->_fillRegisterWithBillingInfo();
661 $this->assertStringsPresent(array('Sorry, currently only 2 seats are available for this option.'));
663 // fill correct value for text field
664 $this->type("xpath=//input[@id='price_{$textFieldId}']", '1');
666 // check for select field
667 $this->select("price_{$selectFieldId}", "value={$selectFieldOp2}");
669 $this->click('_qf_Register_upload-bottom');
670 $this->waitForPageToLoad($this->getTimeoutMsec());
672 $this->assertStringsPresent(array('Sorry, this option is currently sold out.'));
674 // fill available value for select
675 $this->select("price_{$selectFieldId}", "value={$selectFieldOp1}");
677 $this->click('_qf_Register_upload-bottom');
678 $this->waitForPageToLoad($this->getTimeoutMsec());
680 // Check for Participant2
681 // exceed maximun count for text field, check for form rule
682 $this->type("xpath=//input[@id='price_{$textFieldId}']", '2');
684 $this->type('first_name', 'Mary Add 1');
685 $this->type('last_name', 'Jane' . substr(sha1(rand()), 0, 5));
686 $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org';
687 $this->type('email-Primary', $email);
689 $this->click('_qf_Participant_1_next-Array');
690 $this->waitForPageToLoad($this->getTimeoutMsec());
692 $this->assertStringsPresent(array('Sorry, currently only 2 seats are available for this option.'));
694 // fill correct value for text field
695 $this->type("xpath=//input[@id='price_{$textFieldId}']", '1');
697 // check for select field
698 $this->select("price_{$selectFieldId}", "value={$selectFieldOp2}");
700 $this->click('_qf_Participant_1_next-Array');
701 $this->waitForPageToLoad($this->getTimeoutMsec());
703 $this->assertStringsPresent(array('Sorry, this option is currently sold out.'));
705 // fill available value for select
706 $this->select("price_{$selectFieldId}", "value={$selectFieldOp1}");
708 $this->click('_qf_Participant_1_next-Array');
709 $this->waitForPageToLoad($this->getTimeoutMsec());
711 $this->_checkConfirmationAndRegister();
714 public function testAdditionalParticipantWithFieldCount() {
715 // Log in using webtestLogin() method
716 $this->webtestLogin();
718 // Use default payment processor
719 $processorName = 'Test Processor';
720 $this->webtestAddPaymentProcessor($processorName);
723 $priceset = 'Price - ' . substr(sha1(rand()), 0, 7);
724 $financialType = 'Donation';
725 $this->_testAddSet($priceset, $financialType);
727 // create price fields
729 'Full Conference' => array(
731 'amount' => '525.00',
734 'is_required' => TRUE,
735 'financial_type_id' => 1,
737 'Meal Choice' => array(
741 'label' => 'Chicken',
742 'amount' => '525.00',
745 'financial_type_id' => 1,
748 'label' => 'Vegetarian',
749 'amount' => '200.00',
752 'financial_type_id' => 1,
756 'Pre-conference Meetup?' => array(
764 'financial_type_id' => 1,
771 'financial_type_id' => 1,
775 'Evening Sessions' => array(
776 'type' => 'CheckBox',
779 'label' => 'First Five',
780 'amount' => '100.00',
783 'financial_type_id' => 1,
786 'label' => 'Second Four',
790 'financial_type_id' => 1,
797 $this->_testAddPriceFields($fields);
799 // get price set url.
800 $pricesetLoc = $this->getLocation();
802 // get text field Id.
803 $this->waitForElementPresent("xpath=//div[@id='crm-main-content-wrapper']/div/a[1]");
804 $textFieldIdURL = $this->getAttribute("xpath=//div[@id='field_page']//table/tbody/tr[1]/td[9]/span[1]/a[2]@href");
805 $textFieldId = $this->urlArg('fid', $textFieldIdURL);
807 $this->open($pricesetLoc);
808 $this->waitForPageToLoad($this->getTimeoutMsec());
810 // get select field id
811 $this->click("xpath=//div[@id='field_page']//table/tbody/tr[2]/td[8]/a");
812 $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button[2]/span[2]");
813 $selectFieldLoc = $this->getLocation();
814 $selectFieldURL = $this->getAttribute("xpath=//div[@id='field_page']//table/tbody/tr[2]/td[9]/span[1]/a[2]@href");
815 $selectFieldId = $this->urlArg('fid', $selectFieldURL);
817 // get select field ids
818 // get select field option1
819 $selectFieldOp1URL = $this->getAttribute("xpath=//div[@id='field_page']//table/tbody/tr[1]/td[7]/span[1]/a[1]@href");
820 $selectFieldOp1 = $this->urlArg('oid', $selectFieldOp1URL);
822 // get select field option2
823 $selectFieldOp2URL = $this->getAttribute("xpath=//div[@id='field_page']//table/tbody/tr[2]/td[7]/span[1]/a[1]@href");
824 $selectFieldOp2 = $this->urlArg('oid', $selectFieldOp2URL);
827 $eventTitle = 'Meeting - ' . substr(sha1(rand()), 0, 7);
828 $paramsEvent = array(
829 'title' => $eventTitle,
831 'event_type_id' => 4,
832 'payment_processor' => $processorName,
833 'price_set' => $priceset,
834 'is_multiple_registrations' => TRUE,
837 $infoEvent = $this->_testAddEvent($paramsEvent);
839 // logout to register for event.
840 $this->webtestLogout();
843 // Register Participant 1
844 // visit event info page
845 $this->open($infoEvent);
846 $this->waitForPageToLoad($this->getTimeoutMsec());
848 // register for event
849 $this->click('link=Register Now');
850 $this->waitForElementPresent('_qf_Register_upload-bottom');
852 // select 3 participants ( including current )
853 $this->select('additional_participants', 'value=2');
855 // Check for Participant1
856 // exceed maximun count for text field, check for form rule
857 $this->type("xpath=//input[@id='price_{$textFieldId}']", '7');
859 $this->type('first_name', 'Mary');
860 $this->type('last_name', 'Jane' . substr(sha1(rand()), 0, 5));
861 $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org';
862 $this->type('email-Primary', $email);
864 // fill billing related info
865 $this->_fillRegisterWithBillingInfo();
867 $this->assertStringsPresent(array('Sorry, currently only 12 seats are available for this option.'));
869 // fill correct value for text field
870 $this->type("xpath=//input[@id='price_{$textFieldId}']", '1');
871 $this->select("price_{$selectFieldId}", "value={$selectFieldOp2}");
873 $this->click('_qf_Register_upload-bottom');
874 $this->waitForPageToLoad($this->getTimeoutMsec());
876 // Check for Participant2
877 // exceed maximun count for text field, check for form rule
878 $this->type("xpath=//input[@id='price_{$textFieldId}']", '6');
880 $this->type('first_name', 'Mary Add 1');
881 $this->type('last_name', 'Jane' . substr(sha1(rand()), 0, 5));
882 $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org';
883 $this->type('email-Primary', $email);
885 $this->click('_qf_Participant_1_next-Array');
886 $this->waitForPageToLoad($this->getTimeoutMsec());
888 $this->assertStringsPresent(array('Sorry, currently only 12 seats are available for this option.'));
890 // fill correct value for text field
891 $this->type("xpath=//input[@id='price_{$textFieldId}']", '3');
892 $this->select("price_{$selectFieldId}", "value={$selectFieldOp2}");
894 $this->click('_qf_Participant_1_next-Array');
895 $this->waitForPageToLoad($this->getTimeoutMsec());
897 // Check for Participant3, check and skip
898 // exceed maximun count for text field, check for form rule
899 $this->type("xpath=//input[@id='price_{$textFieldId}']", '3');
901 $this->type('first_name', 'Mary Add 2');
902 $this->type('last_name', 'Jane' . substr(sha1(rand()), 0, 5));
903 $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org';
904 $this->type('email-Primary', $email);
906 $this->click('_qf_Participant_2_next-Array');
907 $this->waitForPageToLoad($this->getTimeoutMsec());
909 $this->assertStringsPresent(array('Sorry, currently only 12 seats are available for this option.'));
911 // fill correct value for text field
912 $this->type("xpath=//input[@id='price_{$textFieldId}']", '1');
915 $this->select("price_{$selectFieldId}", "value={$selectFieldOp2}");
917 $this->click('_qf_Participant_2_next-Array');
918 $this->waitForPageToLoad($this->getTimeoutMsec());
920 $this->assertStringsPresent(array('Sorry, this option is currently sold out.'));
922 // Skip participant3 and register
923 $this->click('_qf_Participant_2_next_skip-Array');
924 $this->waitForPageToLoad($this->getTimeoutMsec());
926 $this->_checkConfirmationAndRegister();
929 // Register Participant 1
930 // visit event info page
931 $this->open($infoEvent);
932 $this->waitForPageToLoad($this->getTimeoutMsec());
934 // register for event
935 $this->click('link=Register Now');
936 $this->waitForElementPresent('_qf_Register_upload-bottom');
938 // select 2 participants ( including current )
939 $this->select('additional_participants', 'value=1');
941 // Check for Participant1
942 // exceed maximun count for text field, check for form rule
943 $this->type("xpath=//input[@id='price_{$textFieldId}']", '3');
945 $this->type('first_name', 'Mary');
946 $this->type('last_name', 'Jane' . substr(sha1(rand()), 0, 5));
947 $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org';
948 $this->type('email-Primary', $email);
950 // fill billing related info
951 $this->_fillRegisterWithBillingInfo();
953 $this->assertStringsPresent(array('Sorry, currently only 4 seats are available for this option.'));
955 // fill correct value for text field
956 $this->type("xpath=//input[@id='price_{$textFieldId}']", '1');
958 // check for select field
959 $this->select("price_{$selectFieldId}", "value={$selectFieldOp2}");
961 $this->click('_qf_Register_upload-bottom');
962 $this->waitForPageToLoad($this->getTimeoutMsec());
964 $this->assertStringsPresent(array('Sorry, this option is currently sold out.'));
966 // fill available value for select
967 $this->select("price_{$selectFieldId}", "value={$selectFieldOp1}");
969 $this->click('_qf_Register_upload-bottom');
970 $this->waitForPageToLoad($this->getTimeoutMsec());
972 // Check for Participant2
973 // exceed maximun count for text field, check for form rule
974 $this->type("xpath=//input[@id='price_{$textFieldId}']", '2');
976 $this->type('first_name', 'Mary Add 1');
977 $this->type('last_name', 'Jane' . substr(sha1(rand()), 0, 5));
978 $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org';
979 $this->type('email-Primary', $email);
981 $this->click('_qf_Participant_1_next-Array');
982 $this->waitForPageToLoad($this->getTimeoutMsec());
984 $this->assertStringsPresent(array('Sorry, currently only 4 seats are available for this option.'));
986 // fill correct value for text field
987 $this->type("xpath=//input[@id='price_{$textFieldId}']", '1');
989 // check for select field
990 $this->select("price_{$selectFieldId}", "value={$selectFieldOp2}");
992 $this->click('_qf_Participant_1_next-Array');
993 $this->waitForPageToLoad($this->getTimeoutMsec());
995 $this->assertStringsPresent(array('Sorry, this option is currently sold out.'));
997 // fill available value for select
998 $this->select("price_{$selectFieldId}", "value={$selectFieldOp1}");
1000 $this->click('_qf_Participant_1_next-Array');
1001 $this->waitForPageToLoad($this->getTimeoutMsec());
1003 $this->_checkConfirmationAndRegister();
1008 * @param null $financialType
1010 public function _testAddSet($setTitle, $financialType = NULL) {
1011 $this->openCiviPage('admin/price', 'reset=1&action=add', '_qf_Set_next-bottom');
1013 // Enter Priceset fields (Title, Used For ...)
1014 $this->type('title', $setTitle);
1015 $this->check('extends_1');
1017 if ($financialType) {
1018 $this->select("css=select.crm-form-select", "label={$financialType}");
1021 $this->click("xpath=//form[@id='Set']/div[3]/table/tbody/tr[4]/td[2]/select");
1022 $this->type('help_pre', 'This is test priceset.');
1024 $this->assertChecked('is_active', 'Verify that Is Active checkbox is set.');
1025 $this->clickLink('_qf_Set_next-bottom');
1031 public function _testAddPriceFields($fields) {
1032 $fieldCount = count($fields);
1034 $this->waitForElementPresent('label');
1035 foreach ($fields as $label => $field) {
1036 $this->waitForElementPresent('label');
1037 $this->type('label', $label);
1038 $this->select('html_type', "value={$field['type']}");
1040 if ($field['type'] == 'Text') {
1041 $this->type('price', $field['amount']);
1043 if (isset($field['count'])) {
1044 $this->waitForElementPresent('count');
1045 $this->type('count', $field['count']);
1048 if (isset($field['count'])) {
1049 $this->waitForElementPresent('count');
1050 $this->type('count', $field['count']);
1053 if (isset($field['max_count'])) {
1054 $this->waitForElementPresent('max_value');
1055 $this->type('max_value', $field['max_count']);
1058 if (isset($field['financial_type_id'])) {
1059 $this->waitForElementPresent('financial_type_id');
1060 $this->select('financial_type_id', "value={$field['financial_type_id']}");
1065 $this->_testAddMultipleChoiceOptions($field['options'], $field['type']);
1068 if (isset($field['is_required']) && $field['is_required']) {
1069 $this->check('is_required');
1072 if ($count < $fieldCount) {
1073 $this->click('_qf_Field_next_new-bottom');
1076 $this->click('_qf_Field_next-bottom');
1078 $this->waitForAjaxContent();
1079 $this->waitForText('crm-notification-container', "Price Field '$label' has been saved.");
1089 public function _testAddMultipleChoiceOptions($options, $fieldType) {
1090 foreach ($options as $oIndex => $oValue) {
1091 $this->type("option_label_{$oIndex}", $oValue['label']);
1092 $this->type("option_amount_{$oIndex}", $oValue['amount']);
1094 if (isset($oValue['count'])) {
1095 $this->waitForElementPresent("option_count_{$oIndex}");
1096 $this->type("option_count_{$oIndex}", $oValue['count']);
1099 if (isset($oValue['max_count'])) {
1100 $this->waitForElementPresent("option_max_value_{$oIndex}");
1101 $this->type("option_max_value_{$oIndex}", $oValue['max_count']);
1104 if (!empty($oValue['financial_type_id'])) {
1105 $this->select("option_financial_type_id_{$oIndex}", "value={$oValue['financial_type_id']}");
1108 $this->click('link=another choice');
1111 // select first element as default
1112 if ($fieldType == 'CheckBox') {
1113 $this->click('default_checkbox_option[1]');
1116 $this->click('CIVICRM_QFID_1_2');
1121 * @param array $params
1125 public function _testAddEvent($params) {
1126 $this->openCiviPage('event/add', 'reset=1&action=add', '_qf_EventInfo_upload-bottom');
1128 $this->select('event_type_id', "value={$params['event_type_id']}");
1130 // Attendee role s/b selected now.
1131 $this->select('default_role_id', 'value=1');
1133 // Enter Event Title, Summary and Description
1134 $this->type('title', $params['title']);
1135 $this->type('summary', 'This is a great conference. Sign up now!');
1136 $this->fillRichTextField('description', 'Here is a description for this event.', 'CKEditor');
1138 // Choose Start and End dates.
1139 // Using helper webtestFillDate function.
1140 $this->webtestFillDateTime('start_date', '+1 week');
1141 $this->webtestFillDateTime('end_date', '+1 week 1 day 8 hours ');
1143 $this->type('max_participants', '50');
1144 $this->click('is_map');
1145 $this->click('_qf_EventInfo_upload-bottom');
1147 // Wait for Location tab form to load
1148 $this->waitForPageToLoad($this->getTimeoutMsec());
1151 $this->click('link=Fees');
1152 $this->waitForElementPresent('_qf_Fee_upload-bottom');
1153 $this->click('xpath=//form[@id="Fee"]/div[2]/table/tbody/tr[2]/td[2]/label[contains(text(), "Yes")]');
1154 $processorName = $params['payment_processor'];
1155 $this->click("xpath=//tr[@class='crm-event-manage-fee-form-block-payment_processor']/td[2]/label[text()='$processorName']");
1156 $this->select('financial_type_id', 'value=4');
1158 if (array_key_exists('price_set', $params)) {
1159 $this->select('price_set_id', 'label=' . $params['price_set']);
1161 if (array_key_exists('fee_level', $params)) {
1163 foreach ($params['fee_level'] as $label => $amount) {
1164 $this->type("label_{$counter}", $label);
1165 $this->type("value_{$counter}", $amount);
1170 $this->clickLink('_qf_Fee_upload-bottom', 'link=Online Registration', FALSE);
1172 // Go to Online Registration tab
1173 $this->click('link=Online Registration');
1174 $this->waitForElementPresent('_qf_Registration_upload-bottom');
1176 $this->check('is_online_registration');
1177 $this->assertChecked('is_online_registration');
1179 if (isset($params['is_multiple_registrations']) && $params['is_multiple_registrations']) {
1180 $this->click('is_multiple_registrations');
1183 $this->click('intro_text-plain');
1184 $this->fillRichTextField('intro_text', 'Fill in all the fields below and click Continue.');
1186 // enable confirmation email
1187 $this->click('CIVICRM_QFID_1_is_email_confirm');
1188 $this->type('confirm_from_name', 'Jane Doe');
1189 $this->type('confirm_from_email', 'jane.doe@example.org');
1191 $this->click('_qf_Registration_upload-bottom');
1192 $this->waitForTextPresent("'Fees' information has been saved.");
1194 // verify event input on info page
1195 // start at Manage Events listing
1196 $this->openCiviPage('event/manage', 'reset=1');
1197 $this->click('link=' . $params['title']);
1199 $this->waitForPageToLoad($this->getTimeoutMsec());
1200 return $this->getLocation();
1203 public function _fillRegisterWithBillingInfo() {
1204 $this->waitForElementPresent('credit_card_type');
1205 $this->select('credit_card_type', 'value=Visa');
1206 $this->type('credit_card_number', '4111111111111111');
1207 $this->type('cvv2', '000');
1208 $this->select('credit_card_exp_date[M]', 'value=1');
1209 $this->select('credit_card_exp_date[Y]', 'value=2020');
1210 $this->type('billing_first_name', 'Jane_' . substr(sha1(rand()), 0, 5));
1211 $this->type('billing_last_name', 'San_' . substr(sha1(rand()), 0, 5));
1212 $this->type('billing_street_address-5', '15 Main St.');
1213 $this->type(' billing_city-5', 'San Jose');
1214 $this->select('billing_country_id-5', 'value=1228');
1215 $this->select('billing_state_province_id-5', 'value=1004');
1216 $this->type('billing_postal_code-5', '94129');
1218 $this->click('_qf_Register_upload-bottom');
1219 $this->waitForPageToLoad($this->getTimeoutMsec());
1222 public function _checkConfirmationAndRegister() {
1223 $confirmStrings = array('Event Fee(s)', 'Billing Name and Address', 'Credit Card Information');
1224 $this->assertStringsPresent($confirmStrings);
1225 $this->waitForElementPresent("_qf_Confirm_next-bottom");
1226 $this->click('_qf_Confirm_next-bottom');
1227 $this->waitForPageToLoad($this->getTimeoutMsec());
1228 $thankStrings = array('Thank You for Registering', 'Event Total', 'Transaction Date');
1229 $this->assertStringsPresent($thankStrings);