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_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->waitForPageToLoad($this->getTimeoutMsec());
321 $this->waitForElementPresent('is_pay_later');
322 $this->assertNotChecked('is_pay_later');
325 public function testAjaxCustomGroupLoad() {
326 $this->webtestLogin();
328 $triggerElement = array('name' => 'event_type_id', 'type' => 'select');
330 array('entity' => 'Event', 'subEntity' => 'Conference', 'triggerElement' => $triggerElement),
333 $pageUrl = array('url' => 'event/add', 'args' => "reset=1&action=add");
334 $this->customFieldSetLoadOnTheFlyCheck($customSets, $pageUrl);
339 * @param $eventDescription
341 public function _testAddEventInfo($eventTitle, $eventDescription) {
342 $this->waitForElementPresent("_qf_EventInfo_upload-bottom");
344 $this->select("event_type_id", "value=1");
346 // Attendee role s/b selected now.
347 $this->select("default_role_id", "value=1");
349 // Enter Event Title, Summary and Description
350 $this->type("title", $eventTitle);
351 $this->type("summary", "This is a great conference. Sign up now!");
353 // Type description in ckEditor (fieldname, text to type, editor)
354 $this->fillRichTextField("description", $eventDescription, 'CKEditor');
356 // Choose Start and End dates.
357 // Using helper webtestFillDate function.
358 $this->webtestFillDateTime("start_date", "+1 week");
359 $this->webtestFillDateTime("end_date", "+1 week 1 day 8 hours ");
361 $this->type("max_participants", "50");
362 $this->click("is_map");
363 $this->click("is_public");
364 $this->clickLink("_qf_EventInfo_upload-bottom");
369 * @param $eventDescription
370 * @param int $templateID
371 * @param int $eventTypeID
373 public function _testAddEventInfoFromTemplate($eventTitle, $eventDescription, $templateID, $eventTypeID) {
374 $this->waitForElementPresent("_qf_EventInfo_upload-bottom");
376 // Select event template. Use option value, not label - since labels can be translated and test would fail
377 $this->select("template_id", "value={$templateID}");
379 // Wait for event type to be filled in (since page refreshes)
380 $this->waitForAjaxContent();
381 $this->verifySelectedValue("event_type_id", $eventTypeID);
383 // Attendee role s/b selected now.
384 $this->verifySelectedValue("default_role_id", "1");
386 // Enter Event Title, Summary and Description
387 $this->type("title", $eventTitle);
389 $this->type("summary", "This is a great conference. Sign up now!");
391 // Type description in ckEditor (fieldname, text to type, editor)
392 $this->fillRichTextField("description", $eventDescription, 'CKEditor');
394 // Choose Start and End dates.
395 // Using helper webtestFillDate function.
396 $this->webtestFillDateTime("start_date", "+1 week");
397 $this->webtestFillDateTime("end_date", "+1 week 1 day 8 hours ");
399 $this->type("max_participants", "50");
400 $this->click("is_map");
401 $this->clickLink("_qf_EventInfo_upload-bottom");
405 * @param $streetAddress
407 public function _testAddLocation($streetAddress) {
408 // Wait for Location tab form to load
409 $this->waitForAjaxContent();
410 $this->waitForElementPresent("_qf_Location_upload-bottom");
412 // Fill in address fields
413 $streetAddress = "100 Main Street";
414 $this->type("address_1_street_address", $streetAddress);
415 $this->type("address_1_city", "San Francisco");
416 $this->type("address_1_postal_code", "94117");
417 $this->select('address_1_country_id', 'UNITED STATES');
418 $this->select("address_1_state_province_id", "value=1004");
419 $this->type("email_1_email", "info@civicrm.org");
421 $this->click("_qf_Location_upload-bottom");
423 // Wait for "saved" status msg
424 $this->waitForText('crm-notification-container', "'Event Location' information has been saved.");
428 * @param bool $discount
429 * @param bool $priceSet
430 * @param string $processorName
431 * @param bool $double
432 * @param bool $payLater
436 public function _testAddFees($discount = FALSE, $priceSet = FALSE, $processorName = "PP Pro", $double = FALSE, $payLater = FALSE) {
437 $discount1 = "Early-bird" . substr(sha1(rand()), 0, 7);
440 $this->click("link=Fees");
441 $this->waitForElementPresent("_qf_Fee_upload-bottom");
442 $this->click("CIVICRM_QFID_1_is_monetary");
445 $this->click('is_pay_later');
446 $this->fillRichTextField('pay_later_receipt', 'testing later instructions');
449 $this->uncheck('is_pay_later');
452 if ($processorName) {
453 $this->select2('payment_processor', $processorName, TRUE);
455 $this->select("financial_type_id", "value=4");
460 $this->type("label_1", "Member");
461 $this->type("value_1", "225.00");
462 $this->type("label_2", "Non-member");
463 $this->type("value_2", "300.00");
464 $this->click("CIVICRM_QFID_1_6");
468 // enter early bird discount fees
469 $this->click("is_discount");
470 $this->waitForElementPresent("discount_name_1");
471 $this->type("discount_name_1", $discount1);
472 $this->webtestFillDate("discount_start_date_1", "-3 week");
473 $this->webtestFillDate("discount_end_date_1", "-2 week");
474 $this->clickLink("_qf_Fee_submit", "discounted_value_1_1");
476 $this->type("discounted_value_1_1", "225.00");
477 $this->type("discounted_value_2_1", "300.00");
480 $discount2 = "Early-bird" . substr(sha1(rand()), 0, 7);
481 // enter early bird discount fees
482 $this->click("link=another discount set");
483 $this->waitForElementPresent("discount_name_2");
484 $this->type("discount_name_2", $discount2);
485 $this->webtestFillDate("discount_start_date_2", "-1 week");
486 $this->webtestFillDate("discount_end_date_2", "+1 week");
487 $this->clickLink("_qf_Fee_submit", "discounted_value_2_1");
488 $this->type("discounted_value_1_2", "225.00");
489 $this->type("discounted_value_2_2", "300.00");
491 $this->click("xpath=//fieldset[@id='discount']/fieldset/table/tbody/tr[2]/td[3]/input");
493 $this->click("_qf_Fee_upload-bottom");
495 // Wait for "saved" status msg
496 $this->waitForText('crm-notification-container', "'Fees' information has been saved");
497 return array($discount1, $discount2);
501 * @param $registerIntro
502 * @param bool $multipleRegistrations
504 public function _testAddOnlineRegistration($registerIntro, $multipleRegistrations = FALSE) {
505 // Go to Online Registration tab
506 $this->click("link=Online Registration");
507 $this->waitForElementPresent("_qf_Registration_upload-bottom");
509 $isChecked = $this->isChecked('is_online_registration');
511 $this->click("is_online_registration");
513 $this->assertChecked("is_online_registration");
514 if ($multipleRegistrations) {
515 $isChecked = $this->isChecked('is_multiple_registrations');
517 $this->click("is_multiple_registrations");
519 $this->assertChecked("is_multiple_registrations");
522 $this->fillRichTextField("intro_text", $registerIntro, 'CKEditor', TRUE);
524 // enable confirmation email
525 $this->click("CIVICRM_QFID_1_is_email_confirm");
526 $this->type("confirm_from_name", "Jane Doe");
528 $this->type("confirm_from_email", "jane.doe@example.org");
530 $this->click("_qf_Registration_upload-bottom");
531 $this->waitForText('crm-notification-container', "'Online Registration' information has been saved.");
536 * @param $eventInfoStrings
537 * @param null $eventFees
541 public function _testVerifyEventInfo($eventTitle, $eventInfoStrings, $eventFees = NULL) {
542 // verify event input on info page
543 // start at Manage Events listing
544 $this->openCiviPage("event/manage", "reset=1");
545 $this->click("link=$eventTitle");
547 // Look for Register button
548 $this->waitForElementPresent("link=Register Now");
550 // Check for correct event info strings
551 $this->assertStringsPresent($eventInfoStrings);
553 // Optionally verify event fees (especially for discounts)
555 $this->assertStringsPresent($eventFees);
558 return $this->urlArg('id');
562 * @param $registerStrings
566 public function _testVerifyRegisterPage($registerStrings) {
567 // Go to Register page and check for intro text and fee levels
568 $this->click("link=Register Now");
569 $this->waitForElementPresent("_qf_Register_upload-bottom");
570 $this->assertStringsPresent($registerStrings);
571 return $this->getLocation();
575 * @param $registerUrl
576 * @param int $numberRegistrations
577 * @param bool $anonymous
578 * @param bool $isPayLater
579 * @param array $participantEmailInfo
580 * @param null $paymentProcessor
584 public function _testOnlineRegistration($registerUrl, $numberRegistrations = 1, $anonymous = TRUE, $isPayLater = FALSE, $participantEmailInfo = array(), $paymentProcessor = NULL) {
586 if (!empty($participantEmailInfo)) {
590 $this->webtestLogout();
592 $primaryParticipantInfo = array();
593 $this->open($registerUrl);
594 $this->waitForPageToLoad($this->getTimeoutMsec());
596 $this->waitForElementPresent('additional_participants');
598 $this->select("additional_participants", "value=" . $numberRegistrations);
601 $primaryParticipantInfo['first_name'] = $participantEmailInfo[0]['first_name'];
602 $primaryParticipantInfo['last_name'] = $participantEmailInfo[0]['last_name'];
603 $primaryParticipantInfo['email'] = $participantEmailInfo[0]['email'];
606 $primaryParticipantInfo['first_name'] = "Jane";
607 $primaryParticipantInfo['last_name'] = "Smith" . substr(sha1(rand()), 0, 7);
608 $primaryParticipantInfo['email'] = "smith" . substr(sha1(rand()), 0, 7) . "@example.org";
611 $this->type("first_name", $primaryParticipantInfo['first_name']);
612 $this->type("last_name", $primaryParticipantInfo['last_name']);
613 $this->type("email-Primary", $primaryParticipantInfo['email']);
616 if ($paymentProcessor) {
617 $paymentProcessorEle = $this->getAttribute("xpath=//form[@id='Register']//label[contains(text(), '{$paymentProcessor}')]/@for");
618 $this->click($paymentProcessorEle);
620 $this->select("credit_card_type", "value=Visa");
621 $this->type("credit_card_number", "4111111111111111");
622 $this->type("cvv2", "000");
623 $this->select("credit_card_exp_date[M]", "value=1");
624 $this->select("credit_card_exp_date[Y]", "value=2020");
625 $this->type("billing_first_name", $primaryParticipantInfo['first_name']);
626 $this->type("billing_last_name", $primaryParticipantInfo['last_name']);
627 $this->type("billing_street_address-5", "15 Main St.");
628 $this->type(" billing_city-5", "San Jose");
629 $this->select("billing_country_id-5", "value=1228");
630 $this->select("billing_state_province_id-5", "value=1004");
631 $this->type("billing_postal_code-5", "94129");
634 $this->click("_qf_Register_upload-bottom");
636 if ($numberRegistrations > 1) {
637 for ($i = 1; $i <= $numberRegistrations; $i++
) {
638 $this->waitForPageToLoad($this->getTimeoutMsec());
639 // Look for Skip button
640 $this->waitForElementPresent("_qf_Participant_{$i}_next_skip-Array");
643 $this->type("first_name", $participantEmailInfo[$i]['first_name']);
644 $this->type("last_name", $participantEmailInfo[$i]['last_name']);
645 $this->type("email-Primary", $participantEmailInfo[$i]['email']);
648 $this->type("first_name", "Jane Add $i");
649 $this->type("last_name", "Smith" . substr(sha1(rand()), 0, 7));
650 $this->type("email-Primary", "smith" . substr(sha1(rand()), 0, 7) . "@example.org");
653 $this->click("_qf_Participant_{$i}_next");
657 $this->waitForPageToLoad($this->getTimeoutMsec());
658 $this->waitForElementPresent("_qf_Confirm_next-bottom");
659 $confirmStrings = array("Event Fee(s)");
661 $confirmStrings +
= array("Billing Name and Address", "Credit Card Information");
663 $this->assertStringsPresent($confirmStrings);
664 $this->click("_qf_Confirm_next-bottom");
665 $this->waitForPageToLoad($this->getTimeoutMsec());
666 $thankStrings = array("Thank You for Registering", "Event Total");
668 $thankStrings = array("Transaction Date");
671 $thankStrings +
= array("testing later instructions");
673 $this->assertStringsPresent($thankStrings);
674 return $primaryParticipantInfo;
680 public function _testAddReminder($eventTitle) {
681 // Go to Schedule Reminders tab
682 $this->click("link=Schedule Reminders");
683 $this->waitForElementPresent("newScheduleReminder");
684 $this->click("newScheduleReminder");
685 $this->waitForElementPresent("_qf_ScheduleReminders_next-bottom");
686 $this->type("title", "Event Reminder for " . $eventTitle);
687 $this->select('entity', 'label=Registered');
689 $this->select('start_action_offset', 'label=1');
690 $this->select('start_action_condition', 'label=after');
691 $this->click('is_repeat');
692 $this->select('repetition_frequency_interval', 'label=2');
693 $this->select('end_date', 'label=Event End Date');
694 $this->click('recipient');
695 $this->select('recipient', 'label=Participant Role');
696 // $this->select( 'recipient_listing', 'value=1' );
699 $subject = 'subject' . substr(sha1(rand()), 0, 4);
700 $this->type('subject', $subject);
701 $this->fillRichTextField("html_message", "This is the test HTML version here!!!", 'CKEditor');
703 $this->type("text_message", "This is the test text version here!!!");
705 $this->click('_qf_ScheduleReminders_next-bottom');
706 $this->waitForElementPresent("link=Add Reminder");
708 $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[7]/span/a[1]");
711 1 => 'Event Reminder for ' . $eventTitle,
712 3 => '1 hour after Event Start Date',
718 $this->waitForElementPresent("xpath=//form[@id='ScheduleReminders']//div[@id='option11_wrapper']");
719 //verify the fields for Event Reminder selector
720 foreach ($verifyText as $key => $value) {
721 $this->verifyText("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody//tr/td[$key]", $value);
725 public function testEventAddMultipleParticipant() {
726 $this->markTestSkipped('Skipping for now as it works fine locally.');
727 // Log in using webtestLogin() method
728 $this->webtestLogin();
729 $this->openCiviPage("event/add", "reset=1&action=add");
731 $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7);
732 $eventDescription = "Here is a description for this conference.";
733 $this->_testAddEventInfo($eventTitle, $eventDescription);
734 $streetAddress = "100 Main Street";
735 $this->_testAddLocation($streetAddress);
737 $this->_testAddFees(FALSE, FALSE, "Test Processor", FALSE, TRUE);
738 $registerIntro = "Fill in all the fields below and click Continue.";
739 $multipleRegistrations = TRUE;
740 $this->_testAddOnlineRegistration($registerIntro, $multipleRegistrations);
741 $eventInfoStrings = array($eventTitle, $eventDescription, $streetAddress);
742 $eventId = $this->_testVerifyEventInfo($eventTitle, $eventInfoStrings);
744 $registerStrings = array("225.00", "Member", "300.00", "Non-member", $registerIntro);
745 $registerUrl = $this->_testVerifyRegisterPage($registerStrings);
746 $numberRegistrations = 3;
749 // CRM-12615 add additional participants and check email, amount
750 $primaryParticipant = array(
751 'email' => "smith" . substr(sha1(rand()), 0, 7) . "@example.org",
752 'first_name' => "Kate",
753 'last_name' => "Simth" . substr(sha1(rand()), 0, 7),
755 $secParticipant = array(
756 'email' => "smith" . substr(sha1(rand()), 0, 7) . "@example.org",
757 'first_name' => "Kate Add 1",
758 'last_name' => "Simth" . substr(sha1(rand()), 0, 7),
760 $thirdParticipant = array(
761 'email' => "smith" . substr(sha1(rand()), 0, 7) . "@example.org",
762 'first_name' => "Kate Add 2",
763 'last_name' => "Simth" . substr(sha1(rand()), 0, 7),
766 $participantEmails = array($primaryParticipant, $secParticipant, $thirdParticipant);
767 $addtlPart = array($secParticipant, $thirdParticipant);
768 $primaryParticipantInfo = $this->_testOnlineRegistration($registerUrl, 2, $anonymous, FALSE, $participantEmails, "Test Processor");
769 $primaryDisplayName = "{$primaryParticipantInfo['first_name']} {$primaryParticipantInfo['last_name']}";
770 $this->webtestLogin();
771 $this->openCiviPage("event/search", "reset=1");
772 $this->select2("event_id", $eventTitle, FALSE);
773 $this->clickLink('_qf_Search_refresh');
774 $this->waitForElementPresent("xpath=//div[@id='participantSearch']/table/tbody//tr/td[3]/a");
775 $this->verifyText("xpath=//div[@id='participantSearch']/table/tbody//tr/td[@class='crm-participant-sort_name']/a[contains(text(),
776 '{$secParticipant['last_name']}, {$secParticipant['first_name']}')]/../../td[6]", preg_quote('225.00'));
777 $this->verifyText("xpath=//div[@id='participantSearch']/table/tbody//tr/td[@class='crm-participant-sort_name']/a[contains(text(),
778 '{$thirdParticipant['last_name']}, {$thirdParticipant['first_name']}')]/../../td[6]", preg_quote('225.00'));
780 //CRM-12618 check edit screen of additional participant and ensuring record_contribution not present
781 foreach ($addtlPart as $value) {
782 $this->clickAjaxLink("xpath=//div[@id='participantSearch']/table/tbody//tr/td[3]/a[contains(text(),
783 '{$value['last_name']}, {$value['first_name']}')]/../../td[11]/span/a[2][contains(text(), 'Edit')]",
784 '_qf_Participant_upload-bottom');
786 $this->isElementPresent("xpath=//tr[@class='crm-participant-form-block-registered-by']/td[2]/a[contains(text(),
787 '$primaryDisplayName')]"), 'Registered By info is wrong on additional participant edit form');
789 $this->isElementPresent(
790 "xpath=//table/tbody/tr[@class='crm-participant-form-block-displayName']/td[2][contains(text(),
791 '{$value['first_name']} {$value['last_name']}')]"),
792 'Wrong Participant edit form'
794 $this->assertFalse($this->isElementPresent('record_contribution'),
795 'Record Payment checkbox showed up wrongly for additional participant edit screen');
796 $this->click("_qf_Participant_cancel-top");
799 //unselect the payment processor configured
800 $this->openCiviPage("event/manage/fee", "reset=1&action=update&id={$eventId}", '_qf_Fee_upload-bottom');
801 $this->click("_qf_Fee_upload-bottom");
802 $this->waitForText('crm-notification-container', "'Fees' information has been saved.");
804 // add participant and 3 additional participant and change status of participant from edit participant
805 $this->_testOnlineRegistration($registerUrl, $numberRegistrations, $anonymous, TRUE);
806 $this->webtestLogin();
808 $this->openCiviPage("event/search?reset=1", "reset=1");
809 $this->select2("event_id", $eventTitle, FALSE);
810 $this->multiselect2('participant_status_id', array('Pending (pay later)'));
811 $this->clickLink('_qf_Search_refresh');
812 $this->waitForElementPresent("xpath=//div[@id='participantSearch']/table/tbody//tr/td[11]/span/a[2][text()='Edit']");
814 $uRL = $this->getAttribute("xpath=//div[@id='participantSearch']/table/tbody//tr/td[11]/span/a[2][text()='Edit']@href");
815 $this->click("xpath=//div[@id='participantSearch']/table/tbody//tr/td[11]/span/a[2][text()='Edit']");
816 $this->waitForElementPresent("status_id");
817 $this->select('status_id', 'label=Registered');
818 $this->waitForElementPresent("record_contribution");
819 $this->click('record_contribution');
820 $this->waitForElementPresent("contribution_status_id");
821 $this->select('contribution_status_id', 'label=Completed');
822 $pID = $this->urlArg('id', $uRL);
823 $contributionID = CRM_Core_DAO
::getFieldValue('CRM_Event_DAO_ParticipantPayment', $pID, 'contribution_id', 'participant_id');
824 $this->click('_qf_Participant_upload-top');
825 $this->waitForElementPresent("xpath=//div[@id='participantSearch']/table/tbody//tr/td[11]/span/a[text()='Edit']");
826 $this->waitForElementPresent("xpath=//div[@id='participantSearch']/table/tbody//tr/td[11]/span/a[text()='View']");
827 $this->click("xpath=//div[@id='participantSearch']/table/tbody//tr/td[11]/span/a[text()='View']");
828 $this->waitForElementPresent("css=.ui-dialog");
829 $this->waitForAjaxContent();
830 $this->verifyFinancialRecords($contributionID);
832 // add participant and 3 additional participant and change status of participant from edit contribution
833 $this->_testOnlineRegistration($registerUrl, $numberRegistrations, $anonymous, TRUE);
834 $this->webtestLogin();
836 $this->openCiviPage("event/search?reset=1", "reset=1");
837 $this->select2("event_id", $eventTitle, FALSE);
838 $this->multiselect2('participant_status_id', array('Pending (pay later)'));
839 $this->clickLink('_qf_Search_refresh');
840 $this->waitForElementPresent("xpath=//div[@id='participantSearch']/table/tbody//tr/td[11]/span/a[text()='View']");
841 $uRL = $this->getAttribute("xpath=//div[@id='participantSearch']/table/tbody//tr/td[11]/span/a[text()='View']@href");
842 $this->click("xpath=//div[@id='participantSearch']/table/tbody//tr/td[11]/span/a[text()='View']");
843 $pID = $this->urlArg('id', $uRL);
844 $contributionID = CRM_Core_DAO
::getFieldValue('CRM_Event_DAO_ParticipantPayment', $pID, 'contribution_id', 'participant_id');
845 $this->waitForElementPresent("xpath=//tr[@id='rowid$contributionID']/td[8]/span//a[text()='Edit']");
846 $this->click("xpath=//tr[@id='rowid$contributionID']/td[8]/span//a[text()='Edit']");
847 $this->waitForElementPresent("_qf_Contribution_upload-bottom");
848 $this->select('contribution_status_id', 'label=Completed');
849 $this->clickLink('_qf_Contribution_upload-bottom', '_qf_ParticipantView_cancel-bottom', FALSE);
850 $this->waitForAjaxContent();
851 $this->verifyFinancialRecords($contributionID);
855 * @param int $contributionID
857 public function verifyFinancialRecords($contributionID) {
858 // check count for civicrm_contribution and civicrm_financial_item in civicrm_entity_financial_trxn
859 $query = "SELECT COUNT(DISTINCT(c1.id)) civicrm_contribution, COUNT(c2.id) civicrm_financial_item FROM civicrm_entity_financial_trxn c1
860 LEFT JOIN civicrm_entity_financial_trxn c2 ON c1.financial_trxn_id = c2.financial_trxn_id AND c2.entity_table ='civicrm_financial_item'
861 LEFT JOIN civicrm_financial_item cfi ON cfi.id = c2.entity_id
862 WHERE c1.entity_table = 'civicrm_contribution' AND c1.entity_id = %1 AND cfi.status_id = 1";
863 $params = array(1 => array($contributionID, 'Integer'));
864 $dao = CRM_Core_DAO
::executeQuery($query, $params);
866 $this->assertEquals('2', $dao->civicrm_contribution
, 'civicrm_financial_trxn count does not match');
867 $this->assertEquals('8', $dao->civicrm_financial_item
, 'civicrm_financial_item count does not match');
868 $query = "SELECT COUNT(cft.id) civicrm_financial_trxn FROM civicrm_entity_financial_trxn ceft
869 INNER JOIN civicrm_financial_trxn cft ON ceft.financial_trxn_id = cft.id
870 WHERE ceft.entity_id = %1 AND ceft.entity_table = 'civicrm_contribution'";
871 $dao = CRM_Core_DAO
::executeQuery($query, $params);
873 $this->assertEquals('2', $dao->civicrm_financial_trxn
, 'civicrm_financial_trxn count does not match');
876 public function testEventApprovalRegistration() {
877 $this->webtestLogin();
880 $this->openCiviPage("admin/participant_status", "reset=1&action=browse");
881 foreach (array('Awaiting approval', 'Pending from approval', 'Rejected') as $label) {
882 $status = $this->webtest_civicrm_api("ParticipantStatusType", "getsingle", array('label' => $label));
883 $this->_testEnableParticipantStatuses($status['id']);
884 $this->isElementPresent("xpath=//tr[@id='participant_status_type-{$status['id']}']/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->select2('payment_processor', $processorName, TRUE);
918 $this->select('financial_type_id', 'label=Event Fee');
919 $this->type("label[1]", 'Junior Stars');
920 $this->type("value[1]", '500.00');
921 $this->type("label[2]", 'Super Stars');
922 $this->type("value[2]", '1000.00');
923 $this->check('default');
924 $this->click('_qf_Fee_upload-bottom');
925 $this->waitForText('crm-notification-container', "'Fees' information has been saved.");
927 // intro text for registration page
928 $registerIntro = 'Fill in all the fields below and click Continue.';
930 // Go to Online Registration tab
931 $this->click('link=Online Registration');
932 $this->waitForElementPresent('_qf_Registration_upload-bottom');
933 $this->click('is_online_registration');
934 $this->assertChecked('is_online_registration');
937 $this->click('requires_approval');
938 $this->assertChecked('requires_approval');
939 $this->click('_qf_Registration_upload-bottom');
940 $this->waitForText('crm-notification-container', "'Online Registration' information has been saved.");
942 // verify event input on info page
943 // start at Manage Events listing
944 $this->openCiviPage('event/manage', 'reset=1');
945 $this->click("link=$eventTitle");
946 $this->waitForPageToLoad($this->getTimeoutMsec());
947 $firstName = substr(sha1(rand()), 0, 7);
948 $this->webtestAddContact($firstName, 'Anderson', TRUE);
949 $contactName = "Anderson, $firstName";
950 $displayName = "$firstName Anderson";
951 $this->openCiviPage("event/register", "reset=1&id=$id&action=preview", '_qf_Register_upload-bottom');
952 $this->type('first_name', $firstName);
955 $lastName = 'Recuron' . substr(sha1(rand()), 0, 7);
956 $this->type('last_name', $contactName);
957 $email = $firstName . '@example.com';
958 $this->type('email-Primary', $email);
959 $this->click('_qf_Register_upload');
960 $this->waitForElementPresent("_qf_Confirm_next");
961 $this->click('_qf_Confirm_next');
962 $this->waitForPageToLoad($this->getTimeoutMsec());
963 $this->waitForElementPresent("xpath=//div[@class='crm-group participant_info-group']");
964 $this->assertTextPresent("Thank You for Registering");
969 * Test enabling participant statuses.
971 * @param int $statusId
973 public function _testEnableParticipantStatuses($statusId) {
974 // enable participant status
975 if ($this->isElementPresent("xpath=//tr[@id='participant_status_type-{$statusId}']/td[9]/span/a[2][text()='Enable']")) {
976 $this->click("xpath=//tr[@id='participant_status_type-{$statusId}']/td[9]/span/a[2][text()='Enable']");
977 $this->waitForElementPresent("xpath=//tr[@id='participant_status_type-{$statusId}']/td[9]/span/a[2][text()='Disable']");
982 * CRM-16777: Allow to add schedule reminder for event with 'edit all event' permission
984 public function testConfigureScheduleReminder() {
985 // Log in using webtestLogin() method
986 $this->webtestLogin('admin');
988 //Details for TestUser1
989 $role1 = 'role1' . substr(sha1(rand()), 0, 7);
990 $TestUser1 = "TestUser1" . substr(sha1(rand()), 0, 4);
991 $emailId1 = substr(sha1(rand()), 0, 7) . '@web.com';
993 //create Role1 with permission 'Access CiviCRM', 'edit all events' and 'Access CiviEvent' permissions.
994 $this->open($this->sboxPath
. "admin/people/permissions/roles");
995 $this->type("edit-name", $role1);
996 $this->waitForElementPresent("edit-add");
997 $this->click("edit-add");
998 $this->waitForPageToLoad($this->getTimeoutMsec());
999 $this->open($this->sboxPath
. "admin/people/permissions/roles");
1000 $this->waitForElementPresent("xpath=//table[@id='user-roles']/tbody//tr/td[1][text()='{$role1}']");
1001 $roleId = explode('/', $this->getAttribute("xpath=//table[@id='user-roles']/tbody//tr/td[1][text()='{$role1}']/../td[4]/a[text()='edit permissions']/@href"));
1002 $permissions = array(
1003 "edit-{$roleId[5]}-access-civicrm",
1004 "edit-{$roleId[5]}-edit-all-events",
1005 "edit-{$roleId[5]}-access-civievent",
1007 $this->changePermissions($permissions);
1010 $this->open($this->sboxPath
. "admin/people/create");
1011 $this->waitForElementPresent("edit-submit");
1012 $this->type("edit-name", $TestUser1);
1013 $this->type("edit-mail", $emailId1);
1014 $this->type("edit-pass-pass1", "Test12345");
1015 $this->type("edit-pass-pass2", "Test12345");
1016 $this->click("xpath=//div[@class='form-item form-type-checkboxes form-item-roles']/div//div/label[contains(text(), '{$role1}')]");
1017 $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
1018 $lastName = 'An' . substr(sha1(rand()), 0, 7);
1019 $this->type("first_name", $firstName);
1020 $this->type("last_name", $lastName);
1021 $this->type("street_address-1", "902C El Camino Way SW");
1022 $this->type("city-1", "Dumfries");
1023 $this->type("postal_code-1", "1234");
1024 $this->select("state_province-1", "value=1019");
1025 $this->click("edit-submit");
1026 $this->waitForPageToLoad($this->getTimeoutMsec());
1029 $this->openCiviPage("event/add", "reset=1&action=add");
1030 $eventName = 'My Event - ' . substr(sha1(rand()), 0, 7);
1031 $eventDescription = "Here is a description for this conference.";
1032 $this->_testAddEventInfo($eventName, $eventDescription);
1035 $this->webtestLogout();
1037 //Login with TestUser1
1038 $this->webtestLogin($TestUser1, 'Test12345');
1039 $this->openCiviPage("event/manage", "reset=1");
1040 $this->type("title", $eventName);
1041 $this->click("_qf_SearchEvent_refresh");
1042 $this->waitForAjaxContent();
1043 $this->_testAddReminder($eventName);
1044 $this->webtestLogout();
1046 //Details for TestUser2
1047 $role2 = 'role2' . substr(sha1(rand()), 0, 5);
1048 $TestUser2 = "TestUser2" . substr(sha1(rand()), 0, 5);
1049 $emailId2 = substr(sha1(rand()), 0, 7) . '@web.com';
1051 //create Role2 with only 'Access CiviCRM' and 'Access CiviEvent' permissions
1052 $this->webtestLogin('admin');
1053 $this->open($this->sboxPath
. "admin/people/permissions/roles");
1054 $this->type("edit-name", $role2);
1055 $this->waitForElementPresent("edit-add");
1056 $this->click("edit-add");
1057 $this->waitForPageToLoad($this->getTimeoutMsec());
1058 $this->open($this->sboxPath
. "admin/people/permissions/roles");
1059 $this->waitForElementPresent("xpath=//table[@id='user-roles']/tbody//tr/td[1][text()='{$role2}']");
1060 $roleId = explode('/', $this->getAttribute("xpath=//table[@id='user-roles']/tbody//tr/td[1][text()='{$role2}']/../td[4]/a[text()='edit permissions']/@href"));
1061 $permissions = array(
1062 "edit-{$roleId[5]}-access-civicrm",
1063 "edit-{$roleId[5]}-access-civievent",
1065 $this->changePermissions($permissions);
1068 $this->open($this->sboxPath
. "admin/people/create");
1069 $this->waitForElementPresent("edit-submit");
1070 $this->type("edit-name", $TestUser2);
1071 $this->type("edit-mail", $emailId2);
1072 $this->type("edit-pass-pass1", "Test123");
1073 $this->type("edit-pass-pass2", "Test123");
1074 $this->click("xpath=//div[@class='form-item form-type-checkboxes form-item-roles']/div//div/label[contains(text(), '{$role2}')]");
1075 $firstName = 'Smith' . substr(sha1(rand()), 0, 4);
1076 $lastName = 'John' . substr(sha1(rand()), 0, 5);
1077 $this->type("first_name", $firstName);
1078 $this->type("last_name", $lastName);
1079 $this->type("street_address-1", "902C El Camino Way SW");
1080 $this->type("city-1", "Dumfries");
1081 $this->type("postal_code-1", "1234");
1082 $this->select("state_province-1", "value=1019");
1083 $this->click("edit-submit");
1084 $this->waitForPageToLoad($this->getTimeoutMsec());
1087 $this->webtestLogout();
1089 //Login with TestUser2
1090 $this->webtestLogin($TestUser2, 'Test123');
1091 $this->openCiviPage("event/manage", "reset=1");
1092 $this->waitForElementPresent("xpath=//div[@id='event_status_id']/div[@class='dataTables_wrapper no-footer']");
1093 $this->verifyText("xpath=//div[@id='event_status_id']/div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td", "None found.");
1094 $this->webtestLogout();