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_AddEventTest
32 class WebTest_Event_AddEventTest
extends CiviSeleniumTestCase
{
34 protected function setUp() {
38 public function testAddPaidEventNoTemplate() {
39 // Log in using webtestLogin() method
40 $this->webtestLogin();
42 // Use default payment processor
43 $processorName = 'Test Processor';
44 $this->webtestAddPaymentProcessor($processorName);
46 $this->openCiviPage("event/add", "reset=1&action=add");
48 $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7);
49 $eventDescription = "Here is a description for this conference.";
50 $this->_testAddEventInfo($eventTitle, $eventDescription);
52 $streetAddress = "100 Main Street";
53 $this->_testAddLocation($streetAddress);
55 $this->_testAddReminder($eventTitle);
57 $this->_testAddFees(FALSE, FALSE, $processorName);
59 // intro text for registration page
60 $registerIntro = "Fill in all the fields below and click Continue.";
61 $multipleRegistrations = TRUE;
62 $this->_testAddOnlineRegistration($registerIntro, $multipleRegistrations);
64 $eventInfoStrings = array($eventTitle, $eventDescription, $streetAddress);
65 $eventId = $this->_testVerifyEventInfo($eventTitle, $eventInfoStrings);
67 $registerStrings = array("225.00", "Member", "300.00", "Non-member", $registerIntro);
68 $registerUrl = $this->_testVerifyRegisterPage($registerStrings);
70 $numberRegistrations = 3;
72 $this->_testOnlineRegistration($registerUrl, $numberRegistrations, $anonymous);
74 // Now test making a copy of the event
75 $this->webtestLogin();
76 $this->openCiviPage("event/manage", "reset=1&action=copy&id=$eventId");
77 $this->_testVerifyEventInfo('Copy of ' . $eventTitle, $eventInfoStrings);
78 $this->_testVerifyRegisterPage($registerStrings);
81 public function testAddPaidEventDiscount() {
83 // Log in using webtestLogin() method
84 $this->webtestLogin();
86 // Use default payment processor
87 $processorName = 'Test Processor';
88 $this->webtestAddPaymentProcessor($processorName);
90 $this->openCiviPage("event/add", "reset=1&action=add");
92 $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7);
93 $eventDescription = "Here is a description for this conference.";
94 $this->_testAddEventInfo($eventTitle, $eventDescription);
96 $streetAddress = "100 Main Street";
97 $this->_testAddLocation($streetAddress);
99 $this->_testAddReminder($eventTitle);
101 $this->_testAddFees(TRUE, FALSE, $processorName);
103 // intro text for registration page
104 $registerIntro = "Fill in all the fields below and click Continue.";
105 $multipleRegistrations = TRUE;
106 $this->_testAddOnlineRegistration($registerIntro, $multipleRegistrations);
108 $discountFees = array("225.00", "300.00");
110 $eventInfoStrings = array($eventTitle, $eventDescription, $streetAddress);
111 $this->_testVerifyEventInfo($eventTitle, $eventInfoStrings, $discountFees);
113 $registerStrings = array_push($discountFees, "Member", "Non-member", $registerIntro);
114 $registerUrl = $this->_testVerifyRegisterPage($registerStrings);
116 $numberRegistrations = 3;
118 $this->_testOnlineRegistration($registerUrl, $numberRegistrations, $anonymous);
121 public function testDeletePriceSetDiscount() {
123 // Log in using webtestLogin() method
124 $this->webtestLogin();
126 // Use default payment processor
127 $processorName = 'Test Processor';
128 $this->webtestAddPaymentProcessor($processorName);
130 $this->openCiviPage("event/add", "reset=1&action=add");
132 $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7);
133 $eventDescription = "Here is a description for this conference.";
134 $this->_testAddEventInfo($eventTitle, $eventDescription);
136 $streetAddress = "100 Main Street";
137 $this->_testAddLocation($streetAddress);
140 $discount = $this->_testAddFees(TRUE, FALSE, $processorName, TRUE);
142 // intro text for registration page
143 $registerIntro = "Fill in all the fields below and click Continue.";
144 $multipleRegistrations = TRUE;
145 $this->_testAddOnlineRegistration($registerIntro, $multipleRegistrations);
147 $discountFees = array("225.00", "300.00");
149 $eventInfoStrings = array($eventTitle, $eventDescription, $streetAddress);
150 $id = $this->_testVerifyEventInfo($eventTitle, $eventInfoStrings, $discountFees);
152 $registerStrings = array_push($discountFees, "Member", "Non-member", $registerIntro);
153 $registerUrl = $this->_testVerifyRegisterPage($registerStrings);
156 $this->openCiviPage("event/manage/fee", "reset=1&action=update&id=$id", "_qf_Fee_upload-bottom");
157 $this->click("xpath=//a[@id='quickconfig']");
158 $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']");
159 $this->click("xpath=//div[@class='ui-dialog-buttonset']//button/span[text()='Continue']");
161 //Assert quick config change and discount deletion
162 $this->openCiviPage("admin/price", "reset=1");
163 foreach ($discount as $key => $val) {
164 $this->waitForTextPresent($val);
168 public function testAddDeleteEventDiscount() {
170 // Log in using webtestLogin() method
171 $this->webtestLogin();
173 // Use default payment processor
174 $processorName = 'Test Processor';
175 $this->webtestAddPaymentProcessor($processorName);
177 $this->openCiviPage("event/add", "reset=1&action=add");
179 $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7);
180 $eventDescription = "Here is a description for this conference.";
181 $this->_testAddEventInfo($eventTitle, $eventDescription);
183 $streetAddress = "100 Main Street";
184 $this->_testAddLocation($streetAddress);
187 $discount = $this->_testAddFees(TRUE, FALSE, $processorName, TRUE);
189 // intro text for registration page
190 $registerIntro = "Fill in all the fields below and click Continue.";
191 $multipleRegistrations = TRUE;
192 $this->_testAddOnlineRegistration($registerIntro, $multipleRegistrations);
194 $discountFees = array("225.00", "300.00");
196 $eventInfoStrings = array($eventTitle, $eventDescription, $streetAddress);
197 $id = $this->_testVerifyEventInfo($eventTitle, $eventInfoStrings, $discountFees);
199 $registerStrings = array_push($discountFees, "Member", "Non-member", $registerIntro);
200 $registerUrl = $this->_testVerifyRegisterPage($registerStrings);
201 //Delete the discount
202 $this->_deleteDiscount($id, $eventTitle, $discount);
210 public function _deleteDiscount($id, $eventTitle, $discount) {
211 $this->openCiviPage("event/manage/fee", "reset=1&action=update&id=$id", "_qf_Fee_upload-bottom");
212 $this->type("discount_name_2", "");
213 $this->click("xpath=//tr[@id='discount_2']/td[3]/a");
214 $this->click("xpath=//tr[@id='discount_2']/td[4]/a");
215 $this->type("discounted_value_1_2", "");
216 $this->type("discounted_value_2_2", "");
217 $this->click("_qf_Fee_upload-bottom");
218 $this->waitForText('crm-notification-container', "'Fees' information has been saved.");
220 $this->openCiviPage("admin/price", "reset=1");
221 $this->assertStringsPresent($discount[1]);
224 public function testAddPaidEventWithTemplate() {
226 // Log in using webtestLogin() method
227 $this->webtestLogin();
229 // Use default payment processor
230 $processorName = 'Test Processor';
231 $this->webtestAddPaymentProcessor($processorName);
233 $this->openCiviPage("event/add", "reset=1&action=add");
235 $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7);
236 $eventDescription = "Here is a description for this conference.";
237 // Select paid online registration template.
240 $this->_testAddEventInfoFromTemplate($eventTitle, $eventDescription, $templateID, $eventTypeID);
242 $streetAddress = "100 Main Street";
243 $this->_testAddLocation($streetAddress);
245 $this->_testAddFees(FALSE, FALSE, $processorName);
247 // intro text for registration page
248 $registerIntro = "Fill in all the fields below and click Continue.";
249 $this->_testAddOnlineRegistration($registerIntro);
251 // $eventInfoStrings = array( $eventTitle, $eventDescription, $streetAddress );
252 $eventInfoStrings = array($eventTitle, $streetAddress);
253 $this->_testVerifyEventInfo($eventTitle, $eventInfoStrings);
255 $registerStrings = array("225.00", "Member", "300.00", "Non-member", $registerIntro);
256 $this->_testVerifyRegisterPage($registerStrings);
259 public function testAddFreeEventWithTemplate() {
261 // Log in using webtestLogin() method
262 $this->webtestLogin();
264 $this->openCiviPage("event/add", "reset=1&action=add");
266 $eventTitle = 'My Free Meeting - ' . substr(sha1(rand()), 0, 7);
267 $eventDescription = "Here is a description for this free meeting.";
268 // Select "Free Meeting with Online Registration" template (id = 5).
272 $this->_testAddEventInfoFromTemplate($eventTitle, $eventDescription, $templateID, $eventTypeID);
274 $streetAddress = "100 Main Street";
276 $this->_testAddLocation($streetAddress);
278 // Go to Fees tab and check that Paid Event is false (No)
279 $this->click("link=Fees");
280 $this->waitForElementPresent("_qf_Fee_upload-bottom");
281 $this->verifyChecked("CIVICRM_QFID_0_is_monetary");
283 // intro text for registration page
284 $registerIntro = "Fill in all the fields below and click Continue.";
285 $this->_testAddOnlineRegistration($registerIntro);
287 // $eventInfoStrings = array( $eventTitle, $eventDescription, $streetAddress );
288 $eventInfoStrings = array($eventTitle, $streetAddress);
289 $this->_testVerifyEventInfo($eventTitle, $eventInfoStrings);
291 $registerStrings = array($registerIntro);
292 $this->_testVerifyRegisterPage($registerStrings);
293 // make sure paid_event div is NOT present since this is a free event
294 $this->verifyElementNotPresent("css=div.paid_event-section");
297 public function testUnpaidPaid() {
298 // Log in using webtestLogin() method
299 $this->webtestLogin();
301 $this->openCiviPage("event/add", "reset=1&action=add");
302 $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7);
303 $eventDescription = "Here is a description for this conference.";
304 $this->_testAddEventInfo($eventTitle, $eventDescription);
306 //add fee section with pay later checked
307 $this->_testAddFees(FALSE, FALSE, NULL, FALSE, TRUE);
309 //make the event unpaid
310 $this->waitForElementPresent("_qf_Fee_upload-bottom");
311 $this->assertChecked('is_pay_later');
312 $this->click("CIVICRM_QFID_0_is_monetary");
314 $this->click("_qf_Fee_upload-bottom");
315 $this->waitForText('crm-notification-container', "'Fees' information has been saved.");
316 $this->waitForAjaxContent();
318 //check if pay later option is disabled
319 $this->click('CIVICRM_QFID_1_is_monetary');
320 $this->waitForElementPresent('is_pay_later');
321 $this->assertNotChecked('is_pay_later');
324 public function testAjaxCustomGroupLoad() {
325 $this->webtestLogin();
327 $triggerElement = array('name' => 'event_type_id', 'type' => 'select');
329 array('entity' => 'Event', 'subEntity' => 'Conference', 'triggerElement' => $triggerElement),
332 $pageUrl = array('url' => 'event/add', 'args' => "reset=1&action=add");
333 $this->customFieldSetLoadOnTheFlyCheck($customSets, $pageUrl);
338 * @param $eventDescription
340 public function _testAddEventInfo($eventTitle, $eventDescription) {
341 $this->waitForElementPresent("_qf_EventInfo_upload-bottom");
343 $this->select("event_type_id", "value=1");
345 // Attendee role s/b selected now.
346 $this->select("default_role_id", "value=1");
348 // Enter Event Title, Summary and Description
349 $this->type("title", $eventTitle);
350 $this->type("summary", "This is a great conference. Sign up now!");
352 // Type description in ckEditor (fieldname, text to type, editor)
353 $this->fillRichTextField("description", $eventDescription, 'CKEditor');
355 // Choose Start and End dates.
356 // Using helper webtestFillDate function.
357 $this->webtestFillDateTime("start_date", "+1 week");
358 $this->webtestFillDateTime("end_date", "+1 week 1 day 8 hours ");
360 $this->type("max_participants", "50");
361 $this->click("is_map");
362 $this->click("is_public");
363 $this->clickLink("_qf_EventInfo_upload-bottom");
368 * @param $eventDescription
369 * @param int $templateID
370 * @param int $eventTypeID
372 public function _testAddEventInfoFromTemplate($eventTitle, $eventDescription, $templateID, $eventTypeID) {
373 $this->waitForElementPresent("_qf_EventInfo_upload-bottom");
375 // Select event template. Use option value, not label - since labels can be translated and test would fail
376 $this->select("template_id", "value={$templateID}");
378 // Wait for event type to be filled in (since page refreshes)
379 $this->waitForAjaxContent();
380 $this->verifySelectedValue("event_type_id", $eventTypeID);
382 // Attendee role s/b selected now.
383 $this->verifySelectedValue("default_role_id", "1");
385 // Enter Event Title, Summary and Description
386 $this->type("title", $eventTitle);
388 $this->type("summary", "This is a great conference. Sign up now!");
390 // Type description in ckEditor (fieldname, text to type, editor)
391 $this->fillRichTextField("description", $eventDescription, 'CKEditor');
393 // Choose Start and End dates.
394 // Using helper webtestFillDate function.
395 $this->webtestFillDateTime("start_date", "+1 week");
396 $this->webtestFillDateTime("end_date", "+1 week 1 day 8 hours ");
398 $this->type("max_participants", "50");
399 $this->click("is_map");
400 $this->clickLink("_qf_EventInfo_upload-bottom");
404 * @param $streetAddress
406 public function _testAddLocation($streetAddress) {
407 // Wait for Location tab form to load
408 $this->waitForAjaxContent();
409 $this->waitForElementPresent("_qf_Location_upload-bottom");
411 // Fill in address fields
412 $streetAddress = "100 Main Street";
413 $this->type("address_1_street_address", $streetAddress);
414 $this->type("address_1_city", "San Francisco");
415 $this->type("address_1_postal_code", "94117");
416 $this->select('address_1_country_id', 'United States');
417 $this->select("address_1_state_province_id", "value=1004");
418 $this->type("email_1_email", "info@civicrm.org");
420 $this->click("_qf_Location_upload-bottom");
422 // Wait for "saved" status msg
423 $this->waitForText('crm-notification-container', "'Event Location' information has been saved.");
427 * @param bool $discount
428 * @param bool $priceSet
429 * @param string $processorName
430 * @param bool $double
431 * @param bool $payLater
435 public function _testAddFees($discount = FALSE, $priceSet = FALSE, $processorName = "PP Pro", $double = FALSE, $payLater = FALSE) {
436 $discount1 = "Early-bird" . substr(sha1(rand()), 0, 7);
439 $this->click("link=Fees");
440 $this->waitForElementPresent("_qf_Fee_upload-bottom");
441 $this->click("CIVICRM_QFID_1_is_monetary");
444 $this->click('is_pay_later');
445 $this->fillRichTextField('pay_later_receipt', 'testing later instructions');
448 $this->uncheck('is_pay_later');
451 if ($processorName) {
452 $this->check("xpath=//tr[@class='crm-event-manage-fee-form-block-payment_processor']/td[2]/label[text()='$processorName']/../input");
454 $this->select("financial_type_id", "value=4");
459 $this->type("label_1", "Member");
460 $this->type("value_1", "225.00");
461 $this->type("label_2", "Non-member");
462 $this->type("value_2", "300.00");
463 $this->click("CIVICRM_QFID_1_6");
467 // enter early bird discount fees
468 $this->click("is_discount");
469 $this->waitForElementPresent("discount_name_1");
470 $this->type("discount_name_1", $discount1);
471 $this->webtestFillDate("discount_start_date_1", "-3 week");
472 $this->webtestFillDate("discount_end_date_1", "-2 week");
473 $this->clickLink("_qf_Fee_submit", "discounted_value_1_1");
475 $this->type("discounted_value_1_1", "225.00");
476 $this->type("discounted_value_2_1", "300.00");
479 $discount2 = "Early-bird" . substr(sha1(rand()), 0, 7);
480 // enter early bird discount fees
481 $this->click("link=another discount set");
482 $this->waitForElementPresent("discount_name_2");
483 $this->type("discount_name_2", $discount2);
484 $this->webtestFillDate("discount_start_date_2", "-1 week");
485 $this->webtestFillDate("discount_end_date_2", "+1 week");
486 $this->clickLink("_qf_Fee_submit", "discounted_value_2_1");
487 $this->type("discounted_value_1_2", "225.00");
488 $this->type("discounted_value_2_2", "300.00");
490 $this->click("xpath=//fieldset[@id='discount']/fieldset/table/tbody/tr[2]/td[3]/input");
492 $this->click("_qf_Fee_upload-bottom");
494 // Wait for "saved" status msg
495 $this->waitForText('crm-notification-container', "'Fees' information has been saved");
496 return array($discount1, $discount2);
500 * @param $registerIntro
501 * @param bool $multipleRegistrations
503 public function _testAddOnlineRegistration($registerIntro, $multipleRegistrations = FALSE) {
504 // Go to Online Registration tab
505 $this->click("link=Online Registration");
506 $this->waitForElementPresent("_qf_Registration_upload-bottom");
508 $isChecked = $this->isChecked('is_online_registration');
510 $this->click("is_online_registration");
512 $this->assertChecked("is_online_registration");
513 if ($multipleRegistrations) {
514 $isChecked = $this->isChecked('is_multiple_registrations');
516 $this->click("is_multiple_registrations");
518 $this->assertChecked("is_multiple_registrations");
521 $this->fillRichTextField("intro_text", $registerIntro, 'CKEditor', TRUE);
523 // enable confirmation email
524 $this->click("CIVICRM_QFID_1_is_email_confirm");
525 $this->type("confirm_from_name", "Jane Doe");
527 $this->type("confirm_from_email", "jane.doe@example.org");
529 $this->click("_qf_Registration_upload-bottom");
530 $this->waitForText('crm-notification-container', "'Online Registration' information has been saved.");
535 * @param $eventInfoStrings
536 * @param null $eventFees
540 public function _testVerifyEventInfo($eventTitle, $eventInfoStrings, $eventFees = NULL) {
541 // verify event input on info page
542 // start at Manage Events listing
543 $this->openCiviPage("event/manage", "reset=1");
544 $this->click("link=$eventTitle");
546 // Look for Register button
547 $this->waitForElementPresent("link=Register Now");
549 // Check for correct event info strings
550 $this->assertStringsPresent($eventInfoStrings);
552 // Optionally verify event fees (especially for discounts)
554 $this->assertStringsPresent($eventFees);
557 return $this->urlArg('id');
561 * @param $registerStrings
565 public function _testVerifyRegisterPage($registerStrings) {
566 // Go to Register page and check for intro text and fee levels
567 $this->click("link=Register Now");
568 $this->waitForElementPresent("_qf_Register_upload-bottom");
569 $this->assertStringsPresent($registerStrings);
570 return $this->getLocation();
574 * @param $registerUrl
575 * @param int $numberRegistrations
576 * @param bool $anonymous
577 * @param bool $isPayLater
578 * @param array $participantEmailInfo
579 * @param null $paymentProcessor
583 public function _testOnlineRegistration($registerUrl, $numberRegistrations = 1, $anonymous = TRUE, $isPayLater = FALSE, $participantEmailInfo = array(), $paymentProcessor = NULL) {
585 if (!empty($participantEmailInfo)) {
589 $this->webtestLogout();
591 $primaryParticipantInfo = array();
592 $this->open($registerUrl);
593 $this->waitForPageToLoad($this->getTimeoutMsec());
595 $this->waitForElementPresent('additional_participants');
597 $this->select("additional_participants", "value=" . $numberRegistrations);
600 $primaryParticipantInfo['first_name'] = $participantEmailInfo[0]['first_name'];
601 $primaryParticipantInfo['last_name'] = $participantEmailInfo[0]['last_name'];
602 $primaryParticipantInfo['email'] = $participantEmailInfo[0]['email'];
605 $primaryParticipantInfo['first_name'] = "Jane";
606 $primaryParticipantInfo['last_name'] = "Smith" . substr(sha1(rand()), 0, 7);
607 $primaryParticipantInfo['email'] = "smith" . substr(sha1(rand()), 0, 7) . "@example.org";
610 $this->type("first_name", $primaryParticipantInfo['first_name']);
611 $this->type("last_name", $primaryParticipantInfo['last_name']);
612 $this->type("email-Primary", $primaryParticipantInfo['email']);
615 if ($paymentProcessor) {
616 $paymentProcessorEle = $this->getAttribute("xpath=//form[@id='Register']//label[contains(text(), '{$paymentProcessor}')]/@for");
617 $this->click($paymentProcessorEle);
619 $this->select("credit_card_type", "value=Visa");
620 $this->type("credit_card_number", "4111111111111111");
621 $this->type("cvv2", "000");
622 $this->select("credit_card_exp_date[M]", "value=1");
623 $this->select("credit_card_exp_date[Y]", "value=2020");
624 $this->type("billing_first_name", $primaryParticipantInfo['first_name']);
625 $this->type("billing_last_name", $primaryParticipantInfo['last_name']);
626 $this->type("billing_street_address-5", "15 Main St.");
627 $this->type(" billing_city-5", "San Jose");
628 $this->select("billing_country_id-5", "value=1228");
629 $this->select("billing_state_province_id-5", "value=1004");
630 $this->type("billing_postal_code-5", "94129");
633 $this->click("_qf_Register_upload-bottom");
635 if ($numberRegistrations > 1) {
636 for ($i = 1; $i <= $numberRegistrations; $i++
) {
637 $this->waitForPageToLoad($this->getTimeoutMsec());
638 // Look for Skip button
639 $this->waitForElementPresent("_qf_Participant_{$i}_next_skip-Array");
642 $this->type("first_name", $participantEmailInfo[$i]['first_name']);
643 $this->type("last_name", $participantEmailInfo[$i]['last_name']);
644 $this->type("email-Primary", $participantEmailInfo[$i]['email']);
647 $this->type("first_name", "Jane Add $i");
648 $this->type("last_name", "Smith" . substr(sha1(rand()), 0, 7));
649 $this->type("email-Primary", "smith" . substr(sha1(rand()), 0, 7) . "@example.org");
652 $this->click("_qf_Participant_{$i}_next");
656 $this->waitForPageToLoad($this->getTimeoutMsec());
657 $this->waitForElementPresent("_qf_Confirm_next-bottom");
658 $confirmStrings = array("Event Fee(s)");
660 $confirmStrings +
= array("Billing Name and Address", "Credit Card Information");
662 $this->assertStringsPresent($confirmStrings);
663 $this->click("_qf_Confirm_next-bottom");
664 $this->waitForPageToLoad($this->getTimeoutMsec());
665 $thankStrings = array("Thank You for Registering", "Event Total");
667 $thankStrings = array("Transaction Date");
670 $thankStrings +
= array("testing later instructions");
672 $this->assertStringsPresent($thankStrings);
673 return $primaryParticipantInfo;
679 public function _testAddReminder($eventTitle) {
680 // Go to Schedule Reminders tab
681 $this->click('css=li#tab_reminder a');
682 $this->waitForElementPresent("newScheduleReminder");
683 $this->click("newScheduleReminder");
684 $this->waitForElementPresent("_qf_ScheduleReminders_next-bottom");
685 $this->type("title", "Event Reminder for " . $eventTitle);
686 $this->select('entity', 'label=Registered');
688 $this->select('start_action_offset', 'label=1');
689 $this->select('start_action_condition', 'label=after');
690 $this->click('is_repeat');
691 $this->select('repetition_frequency_interval', 'label=2');
692 $this->select('end_date', 'label=Event End Date');
693 $this->click('recipient');
694 $this->select('recipient', 'label=Participant Role');
695 // $this->select( 'recipient_listing', 'value=1' );
698 $subject = 'subject' . substr(sha1(rand()), 0, 4);
699 $this->type('subject', $subject);
700 $this->fillRichTextField("html_message", "This is the test HTML version here!!!", 'CKEditor');
702 $this->type("text_message", "This is the test text version here!!!");
704 $this->click('_qf_ScheduleReminders_next-bottom');
705 $this->waitForElementPresent("link=Add Reminder");
707 $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[7]/span/a[1]");
710 1 => 'Event Reminder for ' . $eventTitle,
711 3 => '1 hour after Event Start Date',
717 $this->waitForElementPresent("xpath=//form[@id='ScheduleReminders']//div[@id='option11_wrapper']");
718 //verify the fields for Event Reminder selector
719 foreach ($verifyText as $key => $value) {
720 $this->verifyText("xpath=//form[@id='ScheduleReminders']//div['option11_wrapper']/table/tbody/tr/td[$key]", $value);
724 public function testEventAddMultipleParticipant() {
725 // Log in using webtestLogin() method
726 $this->webtestLogin();
727 $this->openCiviPage("event/add", "reset=1&action=add");
729 $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7);
730 $eventDescription = "Here is a description for this conference.";
731 $this->_testAddEventInfo($eventTitle, $eventDescription);
732 $streetAddress = "100 Main Street";
733 $this->_testAddLocation($streetAddress);
735 $this->_testAddFees(FALSE, FALSE, "Test Processor", FALSE, TRUE);
736 $registerIntro = "Fill in all the fields below and click Continue.";
737 $multipleRegistrations = TRUE;
738 $this->_testAddOnlineRegistration($registerIntro, $multipleRegistrations);
739 $eventInfoStrings = array($eventTitle, $eventDescription, $streetAddress);
740 $eventId = $this->_testVerifyEventInfo($eventTitle, $eventInfoStrings);
742 $registerStrings = array("225.00", "Member", "300.00", "Non-member", $registerIntro);
743 $registerUrl = $this->_testVerifyRegisterPage($registerStrings);
744 $numberRegistrations = 3;
747 // CRM-12615 add additional participants and check email, amount
748 $primaryParticipant = array(
749 'email' => "smith" . substr(sha1(rand()), 0, 7) . "@example.org",
750 'first_name' => "Kate",
751 'last_name' => "Simth" . substr(sha1(rand()), 0, 7),
753 $secParticipant = array(
754 'email' => "smith" . substr(sha1(rand()), 0, 7) . "@example.org",
755 'first_name' => "Kate Add 1",
756 'last_name' => "Simth" . substr(sha1(rand()), 0, 7),
758 $thirdParticipant = array(
759 'email' => "smith" . substr(sha1(rand()), 0, 7) . "@example.org",
760 'first_name' => "Kate Add 2",
761 'last_name' => "Simth" . substr(sha1(rand()), 0, 7),
764 $participantEmails = array($primaryParticipant, $secParticipant, $thirdParticipant);
765 $addtlPart = array($secParticipant, $thirdParticipant);
766 $primaryParticipantInfo = $this->_testOnlineRegistration($registerUrl, 2, $anonymous, FALSE, $participantEmails, "Test Processor");
767 $primaryDisplayName = "{$primaryParticipantInfo['first_name']} {$primaryParticipantInfo['last_name']}";
768 $this->webtestLogin();
769 $this->openCiviPage("event/search", "reset=1");
770 $this->select2("event_id", $eventTitle, FALSE);
771 $this->clickLink('_qf_Search_refresh');
772 $this->waitForElementPresent("xpath=//div[@id='participantSearch']/table/tbody//tr/td[3]/a");
773 $this->verifyText("xpath=//div[@id='participantSearch']/table/tbody//tr/td[3]/a[contains(text(),
774 '{$secParticipant['last_name']}, {$secParticipant['first_name']}')]/../../td[6]", preg_quote('225.00'));
775 $this->verifyText("xpath=//div[@id='participantSearch']/table/tbody//tr/td[3]/a[contains(text(),
776 '{$thirdParticipant['last_name']}, {$thirdParticipant['first_name']}')]/../../td[6]", preg_quote('225.00'));
778 //CRM-12618 check edit screen of additional participant and ensuring record_contribution not present
779 foreach ($addtlPart as $value) {
780 $this->clickAjaxLink("xpath=//div[@id='participantSearch']/table/tbody//tr/td[3]/a[contains(text(),
781 '{$value['last_name']}, {$value['first_name']}')]/../../td[11]/span/a[2][contains(text(), 'Edit')]",
782 '_qf_Participant_upload-bottom');
784 $this->isElementPresent("xpath=//tr[@class='crm-participant-form-block-registered-by']/td[2]/a[contains(text(),
785 '$primaryDisplayName')]"), 'Registered By info is wrong on additional participant edit form');
787 $this->isElementPresent(
788 "xpath=//table/tbody/tr[@class='crm-participant-form-block-displayName']/td[2][contains(text(),
789 '{$value['first_name']} {$value['last_name']}')]"),
790 'Wrong Participant edit form'
792 $this->assertFalse($this->isElementPresent('record_contribution'),
793 'Record Payment checkbox showed up wrongly for additional participant edit screen');
794 $this->click("_qf_Participant_cancel-top");
797 //unselect the payment processor configured
798 $this->openCiviPage("event/manage/fee", "reset=1&action=update&id={$eventId}", '_qf_Fee_upload-bottom');
799 $this->click("xpath=//tr[@class='crm-event-manage-fee-form-block-payment_processor']/td[2]/label[text()='Test Processor']");
800 $this->click("_qf_Fee_upload-bottom");
801 $this->waitForText('crm-notification-container', "'Fees' information has been saved.");
803 // add participant and 3 additional participant and change status of participant from edit participant
804 $this->_testOnlineRegistration($registerUrl, $numberRegistrations, $anonymous, TRUE);
805 $this->webtestLogin();
807 $this->openCiviPage("event/search?reset=1", "reset=1");
808 $this->select2("event_id", $eventTitle, FALSE);
809 $this->click("xpath=//div[@id='searchForm']/table/tbody/tr[5]/td[1]/div//div/label[text()='Pending from pay later']");
810 $this->clickLink('_qf_Search_refresh');
811 $this->waitForElementPresent("xpath=//div[@id='participantSearch']/table/tbody//tr/td[11]/span/a[2][text()='Edit']");
813 $uRL = $this->getAttribute("xpath=//div[@id='participantSearch']/table/tbody//tr/td[11]/span/a[2][text()='Edit']@href");
814 $this->click("xpath=//div[@id='participantSearch']/table/tbody//tr/td[11]/span/a[2][text()='Edit']");
815 $this->waitForElementPresent("status_id");
816 $this->select('status_id', 'label=Registered');
817 $this->waitForElementPresent("record_contribution");
818 $this->click('record_contribution');
819 $this->waitForElementPresent("contribution_status_id");
820 $this->select('contribution_status_id', 'label=Completed');
821 $pID = $this->urlArg('id', $uRL);
822 $contributionID = CRM_Core_DAO
::getFieldValue('CRM_Event_DAO_ParticipantPayment', $pID, 'contribution_id', 'participant_id');
823 $this->click('_qf_Participant_upload-top');
824 $this->waitForElementPresent("xpath=//div[@id='participantSearch']/table/tbody//tr/td[11]/span/a[text()='Edit']");
825 $this->waitForElementPresent("xpath=//div[@id='participantSearch']/table/tbody//tr/td[11]/span/a[text()='View']");
826 $this->click("xpath=//div[@id='participantSearch']/table/tbody//tr/td[11]/span/a[text()='View']");
827 $this->waitForElementPresent("css=.ui-dialog");
828 $this->waitForAjaxContent();
829 $this->verifyFinancialRecords($contributionID);
831 // add participant and 3 additional participant and change status of participant from edit contribution
832 $this->_testOnlineRegistration($registerUrl, $numberRegistrations, $anonymous, TRUE);
833 $this->webtestLogin();
835 $this->openCiviPage("event/search?reset=1", "reset=1");
836 $this->select2("event_id", $eventTitle, FALSE);
837 $this->click("xpath=//td[@class='crm-event-form-block-participant_status']/div[@class='listing-box']//div/label[text()='Pending from pay later']");
838 $this->clickLink('_qf_Search_refresh');
839 $this->waitForElementPresent("xpath=//div[@id='participantSearch']/table/tbody//tr/td[11]/span/a[text()='View']");
840 $uRL = $this->getAttribute("xpath=//div[@id='participantSearch']/table/tbody//tr/td[11]/span/a[text()='View']@href");
841 $this->click("xpath=//div[@id='participantSearch']/table/tbody//tr/td[11]/span/a[text()='View']");
842 $pID = $this->urlArg('id', $uRL);
843 $contributionID = CRM_Core_DAO
::getFieldValue('CRM_Event_DAO_ParticipantPayment', $pID, 'contribution_id', 'participant_id');
844 $this->waitForElementPresent("xpath=//tr[@id='rowid$contributionID']/td[8]/span//a[text()='Edit']");
845 $this->click("xpath=//tr[@id='rowid$contributionID']/td[8]/span//a[text()='Edit']");
846 $this->waitForElementPresent("_qf_Contribution_upload-bottom");
847 $this->select('contribution_status_id', 'label=Completed');
848 $this->clickLink('_qf_Contribution_upload-bottom', '_qf_ParticipantView_cancel-bottom', FALSE);
849 $this->waitForAjaxContent();
850 $this->verifyFinancialRecords($contributionID);
854 * @param int $contributionID
856 public function verifyFinancialRecords($contributionID) {
857 // check count for civicrm_contribution and civicrm_financial_item in civicrm_entity_financial_trxn
858 $query = "SELECT COUNT(DISTINCT(c1.id)) civicrm_contribution, COUNT(c2.id) civicrm_financial_item FROM civicrm_entity_financial_trxn c1
859 LEFT JOIN civicrm_entity_financial_trxn c2 ON c1.financial_trxn_id = c2.financial_trxn_id AND c2.entity_table ='civicrm_financial_item'
860 LEFT JOIN civicrm_financial_item cfi ON cfi.id = c2.entity_id
861 WHERE c1.entity_table = 'civicrm_contribution' AND c1.entity_id = %1 AND cfi.status_id = 1";
862 $params = array(1 => array($contributionID, 'Integer'));
863 $dao = CRM_Core_DAO
::executeQuery($query, $params);
865 $this->assertEquals('2', $dao->civicrm_contribution
, 'civicrm_financial_trxn count does not match');
866 $this->assertEquals('8', $dao->civicrm_financial_item
, 'civicrm_financial_item count does not match');
867 $query = "SELECT COUNT(cft.id) civicrm_financial_trxn FROM civicrm_entity_financial_trxn ceft
868 INNER JOIN civicrm_financial_trxn cft ON ceft.financial_trxn_id = cft.id
869 WHERE ceft.entity_id = %1 AND ceft.entity_table = 'civicrm_contribution'";
870 $dao = CRM_Core_DAO
::executeQuery($query, $params);
872 $this->assertEquals('2', $dao->civicrm_financial_trxn
, 'civicrm_financial_trxn count does not match');
875 public function testEventApprovalRegistration() {
876 $this->webtestLogin();
879 $this->openCiviPage("admin/participant_status", "reset=1&action=browse");
880 $this->_testEnableParticipantStatuses('Awaiting approval');
881 $this->isElementPresent("xpath=//td[@class='crm-particpant-label'][contains(text(), 'Awaiting approval')]/../td[9]/span/a[2][text()='Disable']");
882 $this->_testEnableParticipantStatuses('Pending from approval');
883 $this->isElementPresent("xpath=//td[@class='crm-particpant-label'][contains(text(), 'Pending from approval')]/../td[9]/span/a[2][text()='Disable']");
884 $this->_testEnableParticipantStatuses('Rejected');
885 $this->isElementPresent("xpath=//td[@class='crm-particpant-label'][contains(text(), 'Rejected')]/../td[9]/span/a[2][text()='Disable']");
889 $this->openCiviPage('event/add', 'reset=1&action=add', '_qf_EventInfo_upload-bottom');
890 $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7);
891 $email = 'Smith' . substr(sha1(rand()), 0, 7) . '@example.com';
892 $eventDescription = 'Here is a description for this conference.';
893 $this->select('event_type_id', 'value=1');
895 // Attendee role s/b selected now.
896 $this->select('default_role_id', 'value=1');
897 // Enter Event Title, Summary and Description
898 $this->type('title', $eventTitle);
899 $this->type('summary', 'This is a great conference. Sign up now!');
901 // Type description in ckEditor (fieldname, text to type, editor)
902 $this->fillRichTextField('description', $eventDescription);
903 $this->type('max_participants', '50');
904 $this->click('is_map');
905 $this->click('_qf_EventInfo_upload-bottom');
907 // Wait for Location tab form to load
908 $this->waitForPageToLoad($this->getTimeoutMsec());
911 $this->click('link=Fees');
912 $id = $this->urlArg('id');
913 $this->waitForElementPresent('_qf_Fee_upload-bottom');
914 $this->click('CIVICRM_QFID_1_is_monetary');
915 $processorName = 'Test Processor';
916 $this->click("xpath=//tr[@class='crm-event-manage-fee-form-block-payment_processor']/td[2]/label[text()='$processorName']");
917 $this->select('financial_type_id', 'label=Event Fee');
918 $this->type("label[1]", 'Junior Stars');
919 $this->type("value[1]", '500.00');
920 $this->type("label[2]", 'Super Stars');
921 $this->type("value[2]", '1000.00');
922 $this->check('default');
923 $this->click('_qf_Fee_upload-bottom');
924 $this->waitForText('crm-notification-container', "'Fees' information has been saved.");
926 // intro text for registration page
927 $registerIntro = 'Fill in all the fields below and click Continue.';
929 // Go to Online Registration tab
930 $this->click('link=Online Registration');
931 $this->waitForElementPresent('_qf_Registration_upload-bottom');
932 $this->click('is_online_registration');
933 $this->assertChecked('is_online_registration');
936 $this->click('requires_approval');
937 $this->assertChecked('requires_approval');
938 $this->click('_qf_Registration_upload-bottom');
939 $this->waitForText('crm-notification-container', "'Online Registration' information has been saved.");
941 // verify event input on info page
942 // start at Manage Events listing
943 $this->openCiviPage('event/manage', 'reset=1');
944 $this->click("link=$eventTitle");
945 $this->waitForPageToLoad($this->getTimeoutMsec());
946 $firstName = substr(sha1(rand()), 0, 7);
947 $this->webtestAddContact($firstName, 'Anderson', TRUE);
948 $contactName = "Anderson, $firstName";
949 $displayName = "$firstName Anderson";
950 $this->openCiviPage("event/register", "reset=1&id=$id", '_qf_Register_upload-bottom');
951 $this->type('first_name', $firstName);
954 $lastName = 'Recuron' . substr(sha1(rand()), 0, 7);
955 $this->type('last_name', $contactName);
956 $email = $firstName . '@example.com';
957 $this->type('email-Primary', $email);
958 $this->click('_qf_Register_upload');
959 $this->waitForElementPresent("_qf_Confirm_next");
960 $this->click('_qf_Confirm_next');
961 $this->waitForPageToLoad($this->getTimeoutMsec());
962 $this->waitForElementPresent("xpath=//div[@class='section']");
963 $this->assertTextPresent("Thank You for Registering");
970 public function _testEnableParticipantStatuses($status) {
971 // enable participant status
972 if ($this->isElementPresent("xpath=//td[@class='crm-participant-label crm-editable crm-editable-enabled'][contains(text(), '{$status}')]/../td[9]/span/a[2][text()='Enable']")) {
973 $this->click("xpath=//td[@class='crm-participant-label crm-editable crm-editable-enabled'][contains(text(), '{$status}')]/../td[9]/span/a[2][text()='Enable']");
974 $this->waitForElementPresent("xpath=//td[@class='crm-participant-label crm-editable crm-editable-enabled'][contains(text(), '{$status}')]/../td[9]/span/a[2][text()='Disable']");