3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
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->assertElementContainsText("xpath=//select[@id='price_{$selectFieldId}']//option[@value='crm_disabled_opt-{$selectFieldOp1}']", "(Sold out)");
216 // fill correct available option for select field
217 $this->select("price_{$selectFieldId}", "value={$selectFieldOp2}");
219 $this->click("css=input[data-amount=10]");
220 $this->click('_qf_Register_upload-bottom');
221 $this->waitForPageToLoad($this->getTimeoutMsec());
223 $this->_checkConfirmationAndRegister();
226 public function testWithFieldCount() {
227 // Log in using webtestLogin() method
228 $this->webtestLogin();
230 // Use default payment processor
231 $processorName = 'Test Processor';
232 $this->webtestAddPaymentProcessor($processorName);
235 $priceset = 'Price - ' . substr(sha1(rand()), 0, 7);
236 $financialType = 'Donation';
237 $this->_testAddSet($priceset, $financialType);
239 // create price fields
241 'Full Conference' => array(
243 'amount' => '525.00',
246 'is_required' => TRUE,
247 'financial_type_id' => 1,
249 'Meal Choice' => array(
253 'label' => 'Chicken',
254 'amount' => '525.00',
257 'financial_type_id' => 1,
260 'label' => 'Vegetarian',
261 'amount' => '200.00',
264 'financial_type_id' => 1,
268 'Pre-conference Meetup?' => array(
276 'financial_type_id' => 1,
283 'financial_type_id' => 1,
287 'Evening Sessions' => array(
288 'type' => 'CheckBox',
291 'label' => 'First Five',
292 'amount' => '100.00',
295 'financial_type_id' => 1,
298 'label' => 'Second Four',
302 'financial_type_id' => 1,
309 $this->_testAddPriceFields($fields);
311 // get price set url.
312 $pricesetLoc = $this->getLocation();
314 // get text field Id.
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);
319 $this->open($pricesetLoc);
320 $this->waitForPageToLoad($this->getTimeoutMsec());
322 // get select field id
323 $this->click("xpath=//div[@id='field_page']//table/tbody/tr[2]/td[8]/a");
324 $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button[2]/span[2]");
325 $selectFieldLoc = $this->getLocation();
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);
329 // get select field ids
330 // get select field option1
331 $selectFieldOp1URL = $this->getAttribute("xpath=//div[@id='field_page']//table/tbody/tr[1]/td[7]/span[1]/a[1]@href");
332 $selectFieldOp1 = $this->urlArg('oid', $selectFieldOp1URL);
334 // get select field option2
335 $selectFieldOp2URL = $this->getAttribute("xpath=//div[@id='field_page']//table/tbody/tr[2]/td[7]/span[1]/a[1]@href");
336 $selectFieldOp2 = $this->urlArg('oid', $selectFieldOp2URL);
339 $eventTitle = 'Meeting - ' . substr(sha1(rand()), 0, 7);
340 $paramsEvent = array(
341 'title' => $eventTitle,
343 'event_type_id' => 4,
344 'payment_processor' => $processorName,
345 'price_set' => $priceset,
348 $infoEvent = $this->_testAddEvent($paramsEvent);
350 // logout to register for event.
351 $this->webtestLogout();
353 // Register Participant 1
354 // visit event info page
355 $this->open($infoEvent);
356 $this->waitForPageToLoad($this->getTimeoutMsec());
358 // register for event
359 $this->click('link=Register Now');
360 $this->waitForElementPresent('_qf_Register_upload-bottom');
362 // check for form rule
363 $this->type("xpath=//input[@id='price_{$textFieldId}']", '3');
365 $this->type('first_name', 'Mary');
366 $this->type('last_name', 'Jane' . substr(sha1(rand()), 0, 5));
367 $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org';
368 $this->type('email-Primary', $email);
370 // fill billing related info
371 $this->_fillRegisterWithBillingInfo();
373 $this->assertStringsPresent(array('Sorry, currently only 4 seats are available for this option.'));
375 $this->select("price_{$selectFieldId}", "value={$selectFieldOp1}");
377 // fill correct value and register
378 $this->type("xpath=//input[@id='price_{$textFieldId}']", '1');
380 $this->click('_qf_Register_upload-bottom');
381 $this->waitForPageToLoad($this->getTimeoutMsec());
383 $this->_checkConfirmationAndRegister();
385 // Register Participant 2
386 // visit event info page
387 $this->open($infoEvent);
388 $this->waitForPageToLoad($this->getTimeoutMsec());
390 $this->click('link=Register Now');
391 $this->waitForElementPresent('_qf_Register_upload-bottom');
393 // check for form rule
394 $this->type("xpath=//input[@id='price_{$textFieldId}']", '2');
395 $this->type('first_name', 'Mary');
396 $this->type('last_name', 'Jane' . substr(sha1(rand()), 0, 5));
397 $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org';
398 $this->type('email-Primary', $email);
400 // fill billing related info and register
401 $this->_fillRegisterWithBillingInfo();
403 $this->assertStringsPresent(array('Sorry, currently only 2 seats are available for this option.'));
405 // fill correct value and register
406 $this->type("xpath=//input[@id='price_{$textFieldId}']", '1');
408 // check for sold option for select field
409 $this->assertElementContainsText("xpath=//select[@id='price_{$selectFieldId}']//option[@value='crm_disabled_opt-{$selectFieldOp1}']", "(Sold out)");
411 // check for sold option for select field
412 $this->select("price_{$selectFieldId}", "value={$selectFieldOp2}");
414 $this->click('_qf_Register_upload-bottom');
415 $this->waitForPageToLoad($this->getTimeoutMsec());
417 $this->_checkConfirmationAndRegister();
420 public function testAdditionalParticipantWithoutFieldCount() {
421 // Log in using webtestLogin() method
422 $this->webtestLogin();
424 // Use default payment processor
425 $processorName = 'Test Processor';
426 $this->webtestAddPaymentProcessor($processorName);
429 $priceset = 'Price - ' . substr(sha1(rand()), 0, 7);
430 $financialType = 'Donation';
431 $this->_testAddSet($priceset, $financialType);
433 // create price fields
435 'Full Conference' => array(
437 'amount' => '525.00',
439 'is_required' => TRUE,
440 'financial_type_id' => 1,
442 'Meal Choice' => array(
446 'label' => 'Chicken',
447 'amount' => '525.00',
449 'financial_type_id' => 1,
452 'label' => 'Vegetarian',
453 'amount' => '200.00',
455 'financial_type_id' => 1,
459 'Pre-conference Meetup?' => array(
466 'financial_type_id' => 1,
472 'financial_type_id' => 1,
476 'Evening Sessions' => array(
477 'type' => 'CheckBox',
480 'label' => 'First Five',
481 'amount' => '100.00',
483 'financial_type_id' => 1,
486 'label' => 'Second Four',
489 'financial_type_id' => 1,
496 $this->_testAddPriceFields($fields);
498 // get price set url.
499 $pricesetLoc = $this->getLocation();
501 // get text field Id.
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);
506 $this->open($pricesetLoc);
507 $this->waitForPageToLoad($this->getTimeoutMsec());
509 // get select field id
510 $this->click("xpath=//div[@id='field_page']//table/tbody/tr[2]/td[8]/a");
511 $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button[2]/span[2]");
512 $selectFieldLoc = $this->getLocation();
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);
516 // get select field ids
517 // get select field option1
518 $selectFieldOp1URL = $this->getAttribute("xpath=//div[@id='field_page']/table/tbody/tr[1]/td[7]/span[1]/a[1]@href");
519 $selectFieldOp1 = $this->urlArg('oid', $selectFieldOp1URL);
521 // get select field option2
522 $selectFieldOp2URL = $this->getAttribute("xpath=//div[@id='field_page']/table/tbody/tr[2]/td[7]/span[1]/a[1]@href");
523 $selectFieldOp2 = $this->urlArg('oid', $selectFieldOp2URL);
526 $eventTitle = 'Meeting - ' . substr(sha1(rand()), 0, 7);
527 $paramsEvent = array(
528 'title' => $eventTitle,
530 'event_type_id' => 4,
531 'payment_processor' => $processorName,
532 'price_set' => $priceset,
533 'is_multiple_registrations' => TRUE,
536 $infoEvent = $this->_testAddEvent($paramsEvent);
538 // logout to register for event.
539 $this->webtestLogout();
542 // Register Participant 1
543 // visit event info page
544 $this->open($infoEvent);
545 $this->waitForPageToLoad($this->getTimeoutMsec());
547 // register for event
548 $this->click('link=Register Now');
549 $this->waitForElementPresent('_qf_Register_upload-bottom');
551 // select 3 participants ( including current )
552 $this->select('additional_participants', 'value=2');
554 // Check for Participant1
555 // exceed maximun count for text field, check for form rule
556 $this->type("xpath=//input[@id='price_{$textFieldId}']", '7');
558 $this->type('first_name', 'Mary');
559 $this->type('last_name', 'Jane' . substr(sha1(rand()), 0, 5));
560 $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org';
561 $this->type('email-Primary', $email);
563 // fill billing related info
564 $this->_fillRegisterWithBillingInfo();
566 $this->assertStringsPresent(array('Sorry, currently only 6 seats are available for this option.'));
568 // fill correct value for text field
569 $this->type("xpath=//input[@id='price_{$textFieldId}']", '1');
570 $this->select("price_{$selectFieldId}", "value={$selectFieldOp2}");
572 $this->click('_qf_Register_upload-bottom');
573 $this->waitForPageToLoad($this->getTimeoutMsec());
575 // Check for Participant2
576 // exceed maximun count for text field, check for form rule
577 $this->type("xpath=//input[@id='price_{$textFieldId}']", '6');
579 $this->type('first_name', 'Mary Add 2');
580 $this->type('last_name', 'Jane' . substr(sha1(rand()), 0, 5));
581 $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org';
582 $this->type('email-Primary', $email);
584 $this->click('_qf_Participant_1_next-Array');
585 $this->waitForPageToLoad($this->getTimeoutMsec());
587 $this->assertStringsPresent(array('Sorry, currently only 6 seats are available for this option.'));
589 // fill correct value for text field
590 $this->type("xpath=//input[@id='price_{$textFieldId}']", '3');
591 $this->select("price_{$selectFieldId}", "value={$selectFieldOp2}");
593 $this->click('_qf_Participant_1_next-Array');
594 $this->waitForPageToLoad($this->getTimeoutMsec());
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');
600 $this->type('first_name', 'Mary Add 2');
601 $this->type('last_name', 'Jane' . substr(sha1(rand()), 0, 5));
602 $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org';
603 $this->type('email-Primary', $email);
605 $this->click('_qf_Participant_2_next-Array');
606 $this->waitForPageToLoad($this->getTimeoutMsec());
608 $this->assertStringsPresent(array('Sorry, currently only 6 seats are available for this option.'));
610 // fill correct value for text field
611 $this->type("xpath=//input[@id='price_{$textFieldId}']", '1');
614 $this->assertElementContainsText("xpath=//select[@id='price_{$selectFieldId}']//option[@value='crm_disabled_opt-{$selectFieldOp2}']", "(Sold out)");
616 // Skip participant3 and register
617 $this->click('_qf_Participant_2_next_skip-Array');
618 $this->waitForPageToLoad($this->getTimeoutMsec());
620 $this->_checkConfirmationAndRegister();
623 // Register Participant 1
624 // visit event info page
625 $this->open($infoEvent);
626 $this->waitForPageToLoad($this->getTimeoutMsec());
628 // register for event
629 $this->click('link=Register Now');
630 $this->waitForElementPresent('_qf_Register_upload-bottom');
632 // select 2 participants ( including current )
633 $this->select('additional_participants', 'value=1');
635 // Check for Participant1
636 // exceed maximun count for text field, check for form rule
637 $this->type("xpath=//input[@id='price_{$textFieldId}']", '3');
639 $this->type('first_name', 'Mary');
640 $this->type('last_name', 'Jane' . substr(sha1(rand()), 0, 5));
641 $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org';
642 $this->type('email-Primary', $email);
644 // fill billing related info
645 $this->_fillRegisterWithBillingInfo();
647 $this->assertStringsPresent(array('Sorry, currently only 2 seats are available for this option.'));
649 // fill correct value for text field
650 $this->type("xpath=//input[@id='price_{$textFieldId}']", '1');
652 // check for select field
653 $this->assertElementContainsText("xpath=//select[@id='price_{$selectFieldId}']//option[@value='crm_disabled_opt-{$selectFieldOp2}']", "(Sold out)");
655 // fill available value for select
656 $this->select("price_{$selectFieldId}", "value={$selectFieldOp1}");
658 $this->click('_qf_Register_upload-bottom');
659 $this->waitForPageToLoad($this->getTimeoutMsec());
661 // Check for Participant2
662 // exceed maximun count for text field, check for form rule
663 $this->type("xpath=//input[@id='price_{$textFieldId}']", '2');
665 $this->type('first_name', 'Mary Add 1');
666 $this->type('last_name', 'Jane' . substr(sha1(rand()), 0, 5));
667 $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org';
668 $this->type('email-Primary', $email);
670 $this->click('_qf_Participant_1_next-Array');
671 $this->waitForPageToLoad($this->getTimeoutMsec());
673 $this->assertStringsPresent(array('Sorry, currently only 2 seats are available for this option.'));
675 // fill correct value for text field
676 $this->type("xpath=//input[@id='price_{$textFieldId}']", '1');
678 // check for select field
679 $this->assertElementContainsText("xpath=//select[@id='price_{$selectFieldId}']//option[@value='crm_disabled_opt-{$selectFieldOp2}']", "(Sold out)");
681 // fill available value for select
682 $this->select("price_{$selectFieldId}", "value={$selectFieldOp1}");
684 $this->click('_qf_Participant_1_next-Array');
685 $this->waitForPageToLoad($this->getTimeoutMsec());
687 $this->_checkConfirmationAndRegister();
690 public function testAdditionalParticipantWithFieldCount() {
691 // Log in using webtestLogin() method
692 $this->webtestLogin();
694 // Use default payment processor
695 $processorName = 'Test Processor';
696 $this->webtestAddPaymentProcessor($processorName);
699 $priceset = 'Price - ' . substr(sha1(rand()), 0, 7);
700 $financialType = 'Donation';
701 $this->_testAddSet($priceset, $financialType);
703 // create price fields
705 'Full Conference' => array(
707 'amount' => '525.00',
710 'is_required' => TRUE,
711 'financial_type_id' => 1,
713 'Meal Choice' => array(
717 'label' => 'Chicken',
718 'amount' => '525.00',
721 'financial_type_id' => 1,
724 'label' => 'Vegetarian',
725 'amount' => '200.00',
728 'financial_type_id' => 1,
732 'Pre-conference Meetup?' => array(
740 'financial_type_id' => 1,
747 'financial_type_id' => 1,
751 'Evening Sessions' => array(
752 'type' => 'CheckBox',
755 'label' => 'First Five',
756 'amount' => '100.00',
759 'financial_type_id' => 1,
762 'label' => 'Second Four',
766 'financial_type_id' => 1,
773 $this->_testAddPriceFields($fields);
775 // get price set url.
776 $pricesetLoc = $this->getLocation();
778 // get text field Id.
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);
783 $this->open($pricesetLoc);
784 $this->waitForPageToLoad($this->getTimeoutMsec());
786 // get select field id
787 $this->click("xpath=//div[@id='field_page']//table/tbody/tr[2]/td[8]/a");
788 $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button[2]/span[2]");
789 $selectFieldLoc = $this->getLocation();
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);
793 // get select field ids
794 // get select field option1
795 $selectFieldOp1URL = $this->getAttribute("xpath=//div[@id='field_page']//table/tbody/tr[1]/td[7]/span[1]/a[1]@href");
796 $selectFieldOp1 = $this->urlArg('oid', $selectFieldOp1URL);
798 // get select field option2
799 $selectFieldOp2URL = $this->getAttribute("xpath=//div[@id='field_page']//table/tbody/tr[2]/td[7]/span[1]/a[1]@href");
800 $selectFieldOp2 = $this->urlArg('oid', $selectFieldOp2URL);
803 $eventTitle = 'Meeting - ' . substr(sha1(rand()), 0, 7);
804 $paramsEvent = array(
805 'title' => $eventTitle,
807 'event_type_id' => 4,
808 'payment_processor' => $processorName,
809 'price_set' => $priceset,
810 'is_multiple_registrations' => TRUE,
813 $infoEvent = $this->_testAddEvent($paramsEvent);
815 // logout to register for event.
816 $this->webtestLogout();
819 // Register Participant 1
820 // visit event info page
821 $this->open($infoEvent);
822 $this->waitForPageToLoad($this->getTimeoutMsec());
824 // register for event
825 $this->click('link=Register Now');
826 $this->waitForElementPresent('_qf_Register_upload-bottom');
828 // select 3 participants ( including current )
829 $this->select('additional_participants', 'value=2');
831 // Check for Participant1
832 // exceed maximun count for text field, check for form rule
833 $this->type("xpath=//input[@id='price_{$textFieldId}']", '7');
835 $this->type('first_name', 'Mary');
836 $this->type('last_name', 'Jane' . substr(sha1(rand()), 0, 5));
837 $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org';
838 $this->type('email-Primary', $email);
840 // fill billing related info
841 $this->_fillRegisterWithBillingInfo();
843 $this->assertStringsPresent(array('Sorry, currently only 12 seats are available for this option.'));
845 // fill correct value for text field
846 $this->type("xpath=//input[@id='price_{$textFieldId}']", '1');
847 $this->select("price_{$selectFieldId}", "value={$selectFieldOp2}");
849 $this->click('_qf_Register_upload-bottom');
850 $this->waitForPageToLoad($this->getTimeoutMsec());
852 // Check for Participant2
853 // exceed maximun count for text field, check for form rule
854 $this->type("xpath=//input[@id='price_{$textFieldId}']", '6');
856 $this->type('first_name', 'Mary Add 1');
857 $this->type('last_name', 'Jane' . substr(sha1(rand()), 0, 5));
858 $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org';
859 $this->type('email-Primary', $email);
861 $this->click('_qf_Participant_1_next-Array');
862 $this->waitForPageToLoad($this->getTimeoutMsec());
864 $this->assertStringsPresent(array('Sorry, currently only 12 seats are available for this option.'));
866 // fill correct value for text field
867 $this->type("xpath=//input[@id='price_{$textFieldId}']", '3');
868 $this->select("price_{$selectFieldId}", "value={$selectFieldOp2}");
870 $this->click('_qf_Participant_1_next-Array');
871 $this->waitForPageToLoad($this->getTimeoutMsec());
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');
877 $this->type('first_name', 'Mary Add 2');
878 $this->type('last_name', 'Jane' . substr(sha1(rand()), 0, 5));
879 $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org';
880 $this->type('email-Primary', $email);
882 $this->click('_qf_Participant_2_next-Array');
883 $this->waitForPageToLoad($this->getTimeoutMsec());
885 $this->assertStringsPresent(array('Sorry, currently only 12 seats are available for this option.'));
887 // fill correct value for text field
888 $this->type("xpath=//input[@id='price_{$textFieldId}']", '1');
891 $this->assertElementContainsText("xpath=//select[@id='price_{$selectFieldId}']//option[@value='crm_disabled_opt-{$selectFieldOp2}']", "(Sold out)");
893 // Skip participant3 and register
894 $this->click('_qf_Participant_2_next_skip-Array');
895 $this->waitForPageToLoad($this->getTimeoutMsec());
897 $this->_checkConfirmationAndRegister();
900 // Register Participant 1
901 // visit event info page
902 $this->open($infoEvent);
903 $this->waitForPageToLoad($this->getTimeoutMsec());
905 // register for event
906 $this->click('link=Register Now');
907 $this->waitForElementPresent('_qf_Register_upload-bottom');
909 // select 2 participants ( including current )
910 $this->select('additional_participants', 'value=1');
912 // Check for Participant1
913 // exceed maximun count for text field, check for form rule
914 $this->type("xpath=//input[@id='price_{$textFieldId}']", '3');
916 $this->type('first_name', 'Mary');
917 $this->type('last_name', 'Jane' . substr(sha1(rand()), 0, 5));
918 $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org';
919 $this->type('email-Primary', $email);
921 // fill billing related info
922 $this->_fillRegisterWithBillingInfo();
924 $this->assertStringsPresent(array('Sorry, currently only 4 seats are available for this option.'));
926 // fill correct value for text field
927 $this->type("xpath=//input[@id='price_{$textFieldId}']", '1');
929 // check for select field
930 $this->assertElementContainsText("xpath=//select[@id='price_{$selectFieldId}']//option[@value='crm_disabled_opt-{$selectFieldOp2}']", "(Sold out)");
932 // fill available value for select
933 $this->select("price_{$selectFieldId}", "value={$selectFieldOp1}");
935 $this->click('_qf_Register_upload-bottom');
936 $this->waitForPageToLoad($this->getTimeoutMsec());
938 // Check for Participant2
939 // exceed maximun count for text field, check for form rule
940 $this->type("xpath=//input[@id='price_{$textFieldId}']", '2');
942 $this->type('first_name', 'Mary Add 1');
943 $this->type('last_name', 'Jane' . substr(sha1(rand()), 0, 5));
944 $email = 'jane_' . substr(sha1(rand()), 0, 5) . '@example.org';
945 $this->type('email-Primary', $email);
947 $this->click('_qf_Participant_1_next-Array');
948 $this->waitForPageToLoad($this->getTimeoutMsec());
950 $this->assertStringsPresent(array('Sorry, currently only 4 seats are available for this option.'));
952 // fill correct value for text field
953 $this->type("xpath=//input[@id='price_{$textFieldId}']", '1');
955 // check for select field
956 $this->assertElementContainsText("xpath=//select[@id='price_{$selectFieldId}']//option[@value='crm_disabled_opt-{$selectFieldOp2}']", "(Sold out)");
958 // fill available value for select
959 $this->select("price_{$selectFieldId}", "value={$selectFieldOp1}");
961 $this->click('_qf_Participant_1_next-Array');
962 $this->waitForPageToLoad($this->getTimeoutMsec());
964 $this->_checkConfirmationAndRegister();
969 * @param null $financialType
971 public function _testAddSet($setTitle, $financialType = NULL) {
972 $this->openCiviPage('admin/price', 'reset=1&action=add', '_qf_Set_next-bottom');
974 // Enter Priceset fields (Title, Used For ...)
975 $this->type('title', $setTitle);
976 $this->check('extends_1');
978 if ($financialType) {
979 $this->select("css=select.crm-form-select", "label={$financialType}");
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.');
985 $this->assertChecked('is_active', 'Verify that Is Active checkbox is set.');
986 $this->clickLink('_qf_Set_next-bottom');
992 public function _testAddPriceFields($fields) {
993 $fieldCount = count($fields);
995 $this->waitForElementPresent('label');
996 foreach ($fields as $label => $field) {
997 $this->waitForElementPresent('label');
998 $this->type('label', $label);
999 $this->select('html_type', "value={$field['type']}");
1001 if ($field['type'] == 'Text') {
1002 $this->type('price', $field['amount']);
1004 if (isset($field['count'])) {
1005 $this->waitForElementPresent('count');
1006 $this->type('count', $field['count']);
1009 if (isset($field['count'])) {
1010 $this->waitForElementPresent('count');
1011 $this->type('count', $field['count']);
1014 if (isset($field['max_count'])) {
1015 $this->waitForElementPresent('max_value');
1016 $this->type('max_value', $field['max_count']);
1019 if (isset($field['financial_type_id'])) {
1020 $this->waitForElementPresent('financial_type_id');
1021 $this->select('financial_type_id', "value={$field['financial_type_id']}");
1026 $this->_testAddMultipleChoiceOptions($field['options'], $field['type']);
1029 if (isset($field['is_required']) && $field['is_required']) {
1030 $this->check('is_required');
1033 if ($count < $fieldCount) {
1034 $this->click('_qf_Field_next_new-bottom');
1037 $this->click('_qf_Field_next-bottom');
1039 $this->waitForAjaxContent();
1040 $this->waitForText('crm-notification-container', "Price Field '$label' has been saved.");
1050 public function _testAddMultipleChoiceOptions($options, $fieldType) {
1051 foreach ($options as $oIndex => $oValue) {
1052 $this->type("option_label_{$oIndex}", $oValue['label']);
1053 $this->type("option_amount_{$oIndex}", $oValue['amount']);
1055 if (isset($oValue['count'])) {
1056 $this->waitForElementPresent("option_count_{$oIndex}");
1057 $this->type("option_count_{$oIndex}", $oValue['count']);
1060 if (isset($oValue['max_count'])) {
1061 $this->waitForElementPresent("option_max_value_{$oIndex}");
1062 $this->type("option_max_value_{$oIndex}", $oValue['max_count']);
1065 if (!empty($oValue['financial_type_id'])) {
1066 $this->select("option_financial_type_id_{$oIndex}", "value={$oValue['financial_type_id']}");
1069 $this->click('link=another choice');
1072 // select first element as default
1073 if ($fieldType == 'CheckBox') {
1074 $this->click('default_checkbox_option[1]');
1077 $this->click('CIVICRM_QFID_1_2');
1082 * @param array $params
1086 public function _testAddEvent($params) {
1087 $this->openCiviPage('event/add', 'reset=1&action=add', '_qf_EventInfo_upload-bottom');
1089 $this->select('event_type_id', "value={$params['event_type_id']}");
1091 // Attendee role s/b selected now.
1092 $this->select('default_role_id', 'value=1');
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');
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 ');
1104 $this->type('max_participants', '50');
1105 $this->click('is_map');
1106 $this->click('_qf_EventInfo_upload-bottom');
1108 // Wait for Location tab form to load
1109 $this->waitForPageToLoad($this->getTimeoutMsec());
1112 $this->click('link=Fees');
1113 $this->waitForElementPresent('_qf_Fee_upload-bottom');
1114 $this->click('xpath=//form[@id="Fee"]//div/table/tbody//tr//td/label[contains(text(), "Yes")]');
1115 $processorName = $params['payment_processor'];
1116 $this->click("xpath=//tr[@class='crm-event-manage-fee-form-block-payment_processor']/td[2]/label[text()='$processorName']");
1117 $this->select('financial_type_id', 'value=4');
1119 if (array_key_exists('price_set', $params)) {
1120 $this->select('price_set_id', 'label=' . $params['price_set']);
1122 if (array_key_exists('fee_level', $params)) {
1124 foreach ($params['fee_level'] as $label => $amount) {
1125 $this->type("label_{$counter}", $label);
1126 $this->type("value_{$counter}", $amount);
1131 $this->clickLink('_qf_Fee_upload-bottom', 'link=Online Registration', FALSE);
1133 // Go to Online Registration tab
1134 $this->click('link=Online Registration');
1135 $this->waitForElementPresent('_qf_Registration_upload-bottom');
1137 $this->check('is_online_registration');
1138 $this->assertChecked('is_online_registration');
1140 if (isset($params['is_multiple_registrations']) && $params['is_multiple_registrations']) {
1141 $this->click('is_multiple_registrations');
1144 $this->fillRichTextField('intro_text', 'Fill in all the fields below and click Continue.', 'CKEditor', TRUE);
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');
1151 $this->click('_qf_Registration_upload-bottom');
1152 $this->waitForTextPresent("'Fees' information has been saved.");
1154 // verify event input on info page
1155 // start at Manage Events listing
1156 $this->openCiviPage('event/manage', 'reset=1');
1157 $this->click('link=' . $params['title']);
1159 $this->waitForPageToLoad($this->getTimeoutMsec());
1160 return $this->getLocation();
1163 public function _fillRegisterWithBillingInfo() {
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');
1178 $this->click('_qf_Register_upload-bottom');
1179 $this->waitForPageToLoad($this->getTimeoutMsec());
1182 public function _checkConfirmationAndRegister() {
1183 $confirmStrings = array('Event Fee(s)', 'Billing Name and Address', 'Credit Card Information');
1184 $this->assertStringsPresent($confirmStrings);
1185 $this->waitForElementPresent("_qf_Confirm_next-bottom");
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);