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 $this->markTestSkipped('Skipping for now as it works fine locally.');
299 // Log in using webtestLogin() method
300 $this->webtestLogin();
302 $this->openCiviPage("event/add", "reset=1&action=add");
303 $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7);
304 $eventDescription = "Here is a description for this conference.";
305 $this->_testAddEventInfo($eventTitle, $eventDescription);
307 //add fee section with pay later checked
308 $this->_testAddFees(FALSE, FALSE, NULL, FALSE, TRUE);
310 //make the event unpaid
311 $this->waitForElementPresent("_qf_Fee_upload-bottom");
312 $this->assertChecked('is_pay_later');
313 $this->click("CIVICRM_QFID_0_is_monetary");
315 $this->click("_qf_Fee_upload-bottom");
316 $this->waitForText('crm-notification-container', "'Fees' information has been saved.");
317 $this->waitForAjaxContent();
319 //check if pay later option is disabled
320 $this->click('CIVICRM_QFID_1_is_monetary');
321 $this->waitForPageToLoad($this->getTimeoutMsec());
322 $this->waitForElementPresent('is_pay_later');
323 $this->assertNotChecked('is_pay_later');
326 public function testAjaxCustomGroupLoad() {
327 $this->webtestLogin();
329 $triggerElement = array('name' => 'event_type_id', 'type' => 'select');
331 array('entity' => 'Event', 'subEntity' => 'Conference', 'triggerElement' => $triggerElement),
334 $pageUrl = array('url' => 'event/add', 'args' => "reset=1&action=add");
335 $this->customFieldSetLoadOnTheFlyCheck($customSets, $pageUrl);
340 * @param $eventDescription
342 public function _testAddEventInfo($eventTitle, $eventDescription) {
343 $this->waitForElementPresent("_qf_EventInfo_upload-bottom");
345 $this->select("event_type_id", "value=1");
347 // Attendee role s/b selected now.
348 $this->select("default_role_id", "value=1");
350 // Enter Event Title, Summary and Description
351 $this->type("title", $eventTitle);
352 $this->type("summary", "This is a great conference. Sign up now!");
354 // Type description in ckEditor (fieldname, text to type, editor)
355 $this->fillRichTextField("description", $eventDescription, 'CKEditor');
357 // Choose Start and End dates.
358 // Using helper webtestFillDate function.
359 $this->webtestFillDateTime("start_date", "+1 week");
360 $this->webtestFillDateTime("end_date", "+1 week 1 day 8 hours ");
362 $this->type("max_participants", "50");
363 $this->click("is_map");
364 $this->click("is_public");
365 $this->clickLink("_qf_EventInfo_upload-bottom");
370 * @param $eventDescription
371 * @param int $templateID
372 * @param int $eventTypeID
374 public function _testAddEventInfoFromTemplate($eventTitle, $eventDescription, $templateID, $eventTypeID) {
375 $this->waitForElementPresent("_qf_EventInfo_upload-bottom");
377 // Select event template. Use option value, not label - since labels can be translated and test would fail
378 $this->select("template_id", "value={$templateID}");
380 // Wait for event type to be filled in (since page refreshes)
381 $this->waitForAjaxContent();
382 $this->verifySelectedValue("event_type_id", $eventTypeID);
384 // Attendee role s/b selected now.
385 $this->verifySelectedValue("default_role_id", "1");
387 // Enter Event Title, Summary and Description
388 $this->type("title", $eventTitle);
390 $this->type("summary", "This is a great conference. Sign up now!");
392 // Type description in ckEditor (fieldname, text to type, editor)
393 $this->fillRichTextField("description", $eventDescription, 'CKEditor');
395 // Choose Start and End dates.
396 // Using helper webtestFillDate function.
397 $this->webtestFillDateTime("start_date", "+1 week");
398 $this->webtestFillDateTime("end_date", "+1 week 1 day 8 hours ");
400 $this->type("max_participants", "50");
401 $this->click("is_map");
402 $this->clickLink("_qf_EventInfo_upload-bottom");
406 * @param $streetAddress
408 public function _testAddLocation($streetAddress) {
409 // Wait for Location tab form to load
410 $this->waitForAjaxContent();
411 $this->waitForElementPresent("_qf_Location_upload-bottom");
413 // Fill in address fields
414 $streetAddress = "100 Main Street";
415 $this->type("address_1_street_address", $streetAddress);
416 $this->type("address_1_city", "San Francisco");
417 $this->type("address_1_postal_code", "94117");
418 $this->select('address_1_country_id', 'UNITED STATES');
419 $this->select("address_1_state_province_id", "value=1004");
420 $this->type("email_1_email", "info@civicrm.org");
422 $this->click("_qf_Location_upload-bottom");
424 // Wait for "saved" status msg
425 $this->waitForText('crm-notification-container', "'Event Location' information has been saved.");
429 * @param bool $discount
430 * @param bool $priceSet
431 * @param string $processorName
432 * @param bool $double
433 * @param bool $payLater
437 public function _testAddFees($discount = FALSE, $priceSet = FALSE, $processorName = "PP Pro", $double = FALSE, $payLater = FALSE) {
438 $discount1 = "Early-bird" . substr(sha1(rand()), 0, 7);
441 $this->click("link=Fees");
442 $this->waitForElementPresent("_qf_Fee_upload-bottom");
443 $this->click("CIVICRM_QFID_1_is_monetary");
446 $this->click('is_pay_later');
447 $this->fillRichTextField('pay_later_receipt', 'testing later instructions');
450 $this->uncheck('is_pay_later');
453 if ($processorName) {
454 $this->select2('payment_processor', $processorName, TRUE);
456 $this->select("financial_type_id", "value=4");
461 $this->type("label_1", "Member");
462 $this->type("value_1", "225.00");
463 $this->type("label_2", "Non-member");
464 $this->type("value_2", "300.00");
465 $this->click("CIVICRM_QFID_1_6");
469 // enter early bird discount fees
470 $this->click("is_discount");
471 $this->waitForElementPresent("discount_name_1");
472 $this->type("discount_name_1", $discount1);
473 $this->webtestFillDate("discount_start_date_1", "-3 week");
474 $this->webtestFillDate("discount_end_date_1", "-2 week");
475 $this->clickLink("_qf_Fee_submit", "discounted_value_1_1");
477 $this->type("discounted_value_1_1", "225.00");
478 $this->type("discounted_value_2_1", "300.00");
481 $discount2 = "Early-bird" . substr(sha1(rand()), 0, 7);
482 // enter early bird discount fees
483 $this->click("link=another discount set");
484 $this->waitForElementPresent("discount_name_2");
485 $this->type("discount_name_2", $discount2);
486 $this->webtestFillDate("discount_start_date_2", "-1 week");
487 $this->webtestFillDate("discount_end_date_2", "+1 week");
488 $this->clickLink("_qf_Fee_submit", "discounted_value_2_1");
489 $this->type("discounted_value_1_2", "225.00");
490 $this->type("discounted_value_2_2", "300.00");
492 $this->click("xpath=//fieldset[@id='discount']/fieldset/table/tbody/tr[2]/td[3]/input");
494 $this->click("_qf_Fee_upload-bottom");
496 // Wait for "saved" status msg
497 $this->waitForText('crm-notification-container', "'Fees' information has been saved");
498 return array($discount1, $discount2);
502 * @param $registerIntro
503 * @param bool $multipleRegistrations
505 public function _testAddOnlineRegistration($registerIntro, $multipleRegistrations = FALSE) {
506 // Go to Online Registration tab
507 $this->click("link=Online Registration");
508 $this->waitForElementPresent("_qf_Registration_upload-bottom");
510 $isChecked = $this->isChecked('is_online_registration');
512 $this->click("is_online_registration");
514 $this->assertChecked("is_online_registration");
515 if ($multipleRegistrations) {
516 $isChecked = $this->isChecked('is_multiple_registrations');
518 $this->click("is_multiple_registrations");
520 $this->assertChecked("is_multiple_registrations");
523 $this->fillRichTextField("intro_text", $registerIntro, 'CKEditor', TRUE);
525 // enable confirmation email
526 $this->click("CIVICRM_QFID_1_is_email_confirm");
527 $this->type("confirm_from_name", "Jane Doe");
529 $this->type("confirm_from_email", "jane.doe@example.org");
531 $this->click("_qf_Registration_upload-bottom");
532 $this->waitForText('crm-notification-container', "'Online Registration' information has been saved.");
537 * @param $eventInfoStrings
538 * @param null $eventFees
542 public function _testVerifyEventInfo($eventTitle, $eventInfoStrings, $eventFees = NULL) {
543 // verify event input on info page
544 // start at Manage Events listing
545 $this->openCiviPage("event/manage", "reset=1");
546 $this->click("link=$eventTitle");
548 // Look for Register button
549 $this->waitForElementPresent("link=Register Now");
551 // Check for correct event info strings
552 $this->assertStringsPresent($eventInfoStrings);
554 // Optionally verify event fees (especially for discounts)
556 $this->assertStringsPresent($eventFees);
559 return $this->urlArg('id');
563 * @param $registerStrings
567 public function _testVerifyRegisterPage($registerStrings) {
568 // Go to Register page and check for intro text and fee levels
569 $this->click("link=Register Now");
570 $this->waitForElementPresent("_qf_Register_upload-bottom");
571 $this->assertStringsPresent($registerStrings);
572 return $this->getLocation();
576 * @param $registerUrl
577 * @param int $numberRegistrations
578 * @param bool $anonymous
579 * @param bool $isPayLater
580 * @param array $participantEmailInfo
581 * @param null $paymentProcessor
585 public function _testOnlineRegistration($registerUrl, $numberRegistrations = 1, $anonymous = TRUE, $isPayLater = FALSE, $participantEmailInfo = array(), $paymentProcessor = NULL) {
587 if (!empty($participantEmailInfo)) {
591 $this->webtestLogout();
593 $primaryParticipantInfo = array();
594 $this->open($registerUrl);
595 $this->waitForPageToLoad($this->getTimeoutMsec());
597 $this->waitForElementPresent('additional_participants');
599 $this->select("additional_participants", "value=" . $numberRegistrations);
602 $primaryParticipantInfo['first_name'] = $participantEmailInfo[0]['first_name'];
603 $primaryParticipantInfo['last_name'] = $participantEmailInfo[0]['last_name'];
604 $primaryParticipantInfo['email'] = $participantEmailInfo[0]['email'];
607 $primaryParticipantInfo['first_name'] = "Jane";
608 $primaryParticipantInfo['last_name'] = "Smith" . substr(sha1(rand()), 0, 7);
609 $primaryParticipantInfo['email'] = "smith" . substr(sha1(rand()), 0, 7) . "@example.org";
612 $this->type("first_name", $primaryParticipantInfo['first_name']);
613 $this->type("last_name", $primaryParticipantInfo['last_name']);
614 $this->type("email-Primary", $primaryParticipantInfo['email']);
617 if ($paymentProcessor) {
618 $paymentProcessorEle = $this->getAttribute("xpath=//form[@id='Register']//label[contains(text(), '{$paymentProcessor}')]/@for");
619 $this->click($paymentProcessorEle);
621 $this->select("credit_card_type", "value=Visa");
622 $this->type("credit_card_number", "4111111111111111");
623 $this->type("cvv2", "000");
624 $this->select("credit_card_exp_date[M]", "value=1");
625 $this->select("credit_card_exp_date[Y]", "value=2020");
626 $this->type("billing_first_name", $primaryParticipantInfo['first_name']);
627 $this->type("billing_last_name", $primaryParticipantInfo['last_name']);
628 $this->type("billing_street_address-5", "15 Main St.");
629 $this->type(" billing_city-5", "San Jose");
630 $this->select("billing_country_id-5", "value=1228");
631 $this->select("billing_state_province_id-5", "value=1004");
632 $this->type("billing_postal_code-5", "94129");
635 $this->click("_qf_Register_upload-bottom");
637 if ($numberRegistrations > 1) {
638 for ($i = 1; $i <= $numberRegistrations; $i++
) {
639 $this->waitForPageToLoad($this->getTimeoutMsec());
640 // Look for Skip button
641 $this->waitForElementPresent("_qf_Participant_{$i}_next_skip-Array");
644 $this->type("first_name", $participantEmailInfo[$i]['first_name']);
645 $this->type("last_name", $participantEmailInfo[$i]['last_name']);
646 $this->type("email-Primary", $participantEmailInfo[$i]['email']);
649 $this->type("first_name", "Jane Add $i");
650 $this->type("last_name", "Smith" . substr(sha1(rand()), 0, 7));
651 $this->type("email-Primary", "smith" . substr(sha1(rand()), 0, 7) . "@example.org");
654 $this->click("_qf_Participant_{$i}_next");
658 $this->waitForPageToLoad($this->getTimeoutMsec());
659 $this->waitForElementPresent("_qf_Confirm_next-bottom");
660 $confirmStrings = array("Event Fee(s)");
662 $confirmStrings +
= array("Billing Name and Address", "Credit Card Information");
664 $this->assertStringsPresent($confirmStrings);
665 $this->click("_qf_Confirm_next-bottom");
666 $this->waitForPageToLoad($this->getTimeoutMsec());
667 $thankStrings = array("Thank You for Registering", "Event Total");
669 $thankStrings = array("Transaction Date");
672 $thankStrings +
= array("testing later instructions");
674 $this->assertStringsPresent($thankStrings);
675 return $primaryParticipantInfo;
681 public function _testAddReminder($eventTitle) {
682 // Go to Schedule Reminders tab
683 $this->click("link=Schedule Reminders");
684 $this->waitForElementPresent("newScheduleReminder");
685 $this->click("newScheduleReminder");
686 $this->waitForElementPresent("_qf_ScheduleReminders_next-bottom");
687 $this->type("title", "Event Reminder for " . $eventTitle);
688 $this->select('entity', 'label=Registered');
690 $this->select('start_action_offset', 'label=1');
691 $this->select('start_action_condition', 'label=after');
692 $this->click('is_repeat');
693 $this->select('repetition_frequency_interval', 'label=2');
694 $this->select('end_date', 'label=Event End Date');
695 $this->click('recipient');
696 $this->select('recipient', 'label=Participant Role');
697 // $this->select( 'recipient_listing', 'value=1' );
700 $subject = 'subject' . substr(sha1(rand()), 0, 4);
701 $this->type('subject', $subject);
702 $this->fillRichTextField("html_message", "This is the test HTML version here!!!", 'CKEditor');
704 $this->type("text_message", "This is the test text version here!!!");
706 $this->click('_qf_ScheduleReminders_next-bottom');
707 $this->waitForElementPresent("link=Add Reminder");
709 $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[7]/span/a[1]");
712 1 => 'Event Reminder for ' . $eventTitle,
713 3 => '1 hour after Event Start Date',
719 $this->waitForElementPresent("xpath=//form[@id='ScheduleReminders']//div[@id='option11_wrapper']");
720 //verify the fields for Event Reminder selector
721 foreach ($verifyText as $key => $value) {
722 $this->verifyText("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody//tr/td[$key]", $value);
726 public function testEventAddMultipleParticipant() {
727 $this->markTestSkipped('Skipping for now as it works fine locally.');
728 // Log in using webtestLogin() method
729 $this->webtestLogin();
730 $this->openCiviPage("event/add", "reset=1&action=add");
732 $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7);
733 $eventDescription = "Here is a description for this conference.";
734 $this->_testAddEventInfo($eventTitle, $eventDescription);
735 $streetAddress = "100 Main Street";
736 $this->_testAddLocation($streetAddress);
738 $this->_testAddFees(FALSE, FALSE, "Test Processor", FALSE, TRUE);
739 $registerIntro = "Fill in all the fields below and click Continue.";
740 $multipleRegistrations = TRUE;
741 $this->_testAddOnlineRegistration($registerIntro, $multipleRegistrations);
742 $eventInfoStrings = array($eventTitle, $eventDescription, $streetAddress);
743 $eventId = $this->_testVerifyEventInfo($eventTitle, $eventInfoStrings);
745 $registerStrings = array("225.00", "Member", "300.00", "Non-member", $registerIntro);
746 $registerUrl = $this->_testVerifyRegisterPage($registerStrings);
747 $numberRegistrations = 3;
750 // CRM-12615 add additional participants and check email, amount
751 $primaryParticipant = array(
752 'email' => "smith" . substr(sha1(rand()), 0, 7) . "@example.org",
753 'first_name' => "Kate",
754 'last_name' => "Simth" . substr(sha1(rand()), 0, 7),
756 $secParticipant = array(
757 'email' => "smith" . substr(sha1(rand()), 0, 7) . "@example.org",
758 'first_name' => "Kate Add 1",
759 'last_name' => "Simth" . substr(sha1(rand()), 0, 7),
761 $thirdParticipant = array(
762 'email' => "smith" . substr(sha1(rand()), 0, 7) . "@example.org",
763 'first_name' => "Kate Add 2",
764 'last_name' => "Simth" . substr(sha1(rand()), 0, 7),
767 $participantEmails = array($primaryParticipant, $secParticipant, $thirdParticipant);
768 $addtlPart = array($secParticipant, $thirdParticipant);
769 $primaryParticipantInfo = $this->_testOnlineRegistration($registerUrl, 2, $anonymous, FALSE, $participantEmails, "Test Processor");
770 $primaryDisplayName = "{$primaryParticipantInfo['first_name']} {$primaryParticipantInfo['last_name']}";
771 $this->webtestLogin();
772 $this->openCiviPage("event/search", "reset=1");
773 $this->select2("event_id", $eventTitle, FALSE);
774 $this->clickLink('_qf_Search_refresh');
775 $this->waitForElementPresent("xpath=//div[@id='participantSearch']/table/tbody//tr/td[3]/a");
776 $this->verifyText("xpath=//div[@id='participantSearch']/table/tbody//tr/td[@class='crm-participant-sort_name']/a[contains(text(),
777 '{$secParticipant['last_name']}, {$secParticipant['first_name']}')]/../../td[6]", preg_quote('225.00'));
778 $this->verifyText("xpath=//div[@id='participantSearch']/table/tbody//tr/td[@class='crm-participant-sort_name']/a[contains(text(),
779 '{$thirdParticipant['last_name']}, {$thirdParticipant['first_name']}')]/../../td[6]", preg_quote('225.00'));
781 //CRM-12618 check edit screen of additional participant and ensuring record_contribution not present
782 foreach ($addtlPart as $value) {
783 $this->clickAjaxLink("xpath=//div[@id='participantSearch']/table/tbody//tr/td[3]/a[contains(text(),
784 '{$value['last_name']}, {$value['first_name']}')]/../../td[11]/span/a[2][contains(text(), 'Edit')]",
785 '_qf_Participant_upload-bottom');
787 $this->isElementPresent("xpath=//tr[@class='crm-participant-form-block-registered-by']/td[2]/a[contains(text(),
788 '$primaryDisplayName')]"), 'Registered By info is wrong on additional participant edit form');
790 $this->isElementPresent(
791 "xpath=//table/tbody/tr[@class='crm-participant-form-block-displayName']/td[2][contains(text(),
792 '{$value['first_name']} {$value['last_name']}')]"),
793 'Wrong Participant edit form'
795 $this->assertFalse($this->isElementPresent('record_contribution'),
796 'Record Payment checkbox showed up wrongly for additional participant edit screen');
797 $this->click("_qf_Participant_cancel-top");
800 //unselect the payment processor configured
801 $this->openCiviPage("event/manage/fee", "reset=1&action=update&id={$eventId}", '_qf_Fee_upload-bottom');
802 $this->click("_qf_Fee_upload-bottom");
803 $this->waitForText('crm-notification-container', "'Fees' information has been saved.");
805 // add participant and 3 additional participant and change status of participant from edit participant
806 $this->_testOnlineRegistration($registerUrl, $numberRegistrations, $anonymous, TRUE);
807 $this->webtestLogin();
809 $this->openCiviPage("event/search?reset=1", "reset=1");
810 $this->select2("event_id", $eventTitle, FALSE);
811 $this->multiselect2('participant_status_id', array('Pending (pay later)'));
812 $this->clickLink('_qf_Search_refresh');
813 $this->waitForElementPresent("xpath=//div[@id='participantSearch']/table/tbody//tr/td[11]/span/a[2][text()='Edit']");
815 $uRL = $this->getAttribute("xpath=//div[@id='participantSearch']/table/tbody//tr/td[11]/span/a[2][text()='Edit']@href");
816 $this->click("xpath=//div[@id='participantSearch']/table/tbody//tr/td[11]/span/a[2][text()='Edit']");
817 $this->waitForElementPresent("status_id");
818 $this->select('status_id', 'label=Registered');
819 $this->waitForElementPresent("record_contribution");
820 $this->click('record_contribution');
821 $this->waitForElementPresent("contribution_status_id");
822 $this->select('contribution_status_id', 'label=Completed');
823 $pID = $this->urlArg('id', $uRL);
824 $contributionID = CRM_Core_DAO
::getFieldValue('CRM_Event_DAO_ParticipantPayment', $pID, 'contribution_id', 'participant_id');
825 $this->click('_qf_Participant_upload-top');
826 $this->waitForElementPresent("xpath=//div[@id='participantSearch']/table/tbody//tr/td[11]/span/a[text()='Edit']");
827 $this->waitForElementPresent("xpath=//div[@id='participantSearch']/table/tbody//tr/td[11]/span/a[text()='View']");
828 $this->click("xpath=//div[@id='participantSearch']/table/tbody//tr/td[11]/span/a[text()='View']");
829 $this->waitForElementPresent("css=.ui-dialog");
830 $this->waitForAjaxContent();
831 $this->verifyFinancialRecords($contributionID);
833 // add participant and 3 additional participant and change status of participant from edit contribution
834 $this->_testOnlineRegistration($registerUrl, $numberRegistrations, $anonymous, TRUE);
835 $this->webtestLogin();
837 $this->openCiviPage("event/search?reset=1", "reset=1");
838 $this->select2("event_id", $eventTitle, FALSE);
839 $this->multiselect2('participant_status_id', array('Pending (pay later)'));
840 $this->clickLink('_qf_Search_refresh');
841 $this->waitForElementPresent("xpath=//div[@id='participantSearch']/table/tbody//tr/td[11]/span/a[text()='View']");
842 $uRL = $this->getAttribute("xpath=//div[@id='participantSearch']/table/tbody//tr/td[11]/span/a[text()='View']@href");
843 $this->click("xpath=//div[@id='participantSearch']/table/tbody//tr/td[11]/span/a[text()='View']");
844 $pID = $this->urlArg('id', $uRL);
845 $contributionID = CRM_Core_DAO
::getFieldValue('CRM_Event_DAO_ParticipantPayment', $pID, 'contribution_id', 'participant_id');
846 $this->waitForElementPresent("xpath=//tr[@id='rowid$contributionID']/td[8]/span//a[text()='Edit']");
847 $this->click("xpath=//tr[@id='rowid$contributionID']/td[8]/span//a[text()='Edit']");
848 $this->waitForElementPresent("_qf_Contribution_upload-bottom");
849 $this->select('contribution_status_id', 'label=Completed');
850 $this->clickLink('_qf_Contribution_upload-bottom', '_qf_ParticipantView_cancel-bottom', FALSE);
851 $this->waitForAjaxContent();
852 $this->verifyFinancialRecords($contributionID);
856 * @param int $contributionID
858 public function verifyFinancialRecords($contributionID) {
859 // check count for civicrm_contribution and civicrm_financial_item in civicrm_entity_financial_trxn
860 $query = "SELECT COUNT(DISTINCT(c1.id)) civicrm_contribution, COUNT(c2.id) civicrm_financial_item FROM civicrm_entity_financial_trxn c1
861 LEFT JOIN civicrm_entity_financial_trxn c2 ON c1.financial_trxn_id = c2.financial_trxn_id AND c2.entity_table ='civicrm_financial_item'
862 LEFT JOIN civicrm_financial_item cfi ON cfi.id = c2.entity_id
863 WHERE c1.entity_table = 'civicrm_contribution' AND c1.entity_id = %1 AND cfi.status_id = 1";
864 $params = array(1 => array($contributionID, 'Integer'));
865 $dao = CRM_Core_DAO
::executeQuery($query, $params);
867 $this->assertEquals('2', $dao->civicrm_contribution
, 'civicrm_financial_trxn count does not match');
868 $this->assertEquals('8', $dao->civicrm_financial_item
, 'civicrm_financial_item count does not match');
869 $query = "SELECT COUNT(cft.id) civicrm_financial_trxn FROM civicrm_entity_financial_trxn ceft
870 INNER JOIN civicrm_financial_trxn cft ON ceft.financial_trxn_id = cft.id
871 WHERE ceft.entity_id = %1 AND ceft.entity_table = 'civicrm_contribution'";
872 $dao = CRM_Core_DAO
::executeQuery($query, $params);
874 $this->assertEquals('2', $dao->civicrm_financial_trxn
, 'civicrm_financial_trxn count does not match');
877 public function testEventApprovalRegistration() {
878 $this->webtestLogin();
881 $this->openCiviPage("admin/participant_status", "reset=1&action=browse");
882 foreach (array('Awaiting approval', 'Pending from approval', 'Rejected') as $label) {
883 $status = $this->webtest_civicrm_api("ParticipantStatusType", "getsingle", array('label' => $label));
884 $this->_testEnableParticipantStatuses($status['id']);
885 $this->isElementPresent("xpath=//tr[@id='participant_status_type-{$status['id']}']/td[9]/span/a[2][text()='Disable']");
890 $this->openCiviPage('event/add', 'reset=1&action=add', '_qf_EventInfo_upload-bottom');
891 $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7);
892 $email = 'Smith' . substr(sha1(rand()), 0, 7) . '@example.com';
893 $eventDescription = 'Here is a description for this conference.';
894 $this->select('event_type_id', 'value=1');
896 // Attendee role s/b selected now.
897 $this->select('default_role_id', 'value=1');
898 // Enter Event Title, Summary and Description
899 $this->type('title', $eventTitle);
900 $this->type('summary', 'This is a great conference. Sign up now!');
902 // Type description in ckEditor (fieldname, text to type, editor)
903 $this->fillRichTextField('description', $eventDescription);
904 $this->type('max_participants', '50');
905 $this->click('is_map');
906 $this->click('_qf_EventInfo_upload-bottom');
908 // Wait for Location tab form to load
909 $this->waitForPageToLoad($this->getTimeoutMsec());
912 $this->click('link=Fees');
913 $id = $this->urlArg('id');
914 $this->waitForElementPresent('_qf_Fee_upload-bottom');
915 $this->click('CIVICRM_QFID_1_is_monetary');
916 $processorName = 'Test Processor';
917 $this->select2('payment_processor', $processorName, TRUE);
919 $this->select('financial_type_id', 'label=Event Fee');
920 $this->type("label[1]", 'Junior Stars');
921 $this->type("value[1]", '500.00');
922 $this->type("label[2]", 'Super Stars');
923 $this->type("value[2]", '1000.00');
924 $this->check('default');
925 $this->click('_qf_Fee_upload-bottom');
926 $this->waitForText('crm-notification-container', "'Fees' information has been saved.");
928 // intro text for registration page
929 $registerIntro = 'Fill in all the fields below and click Continue.';
931 // Go to Online Registration tab
932 $this->click('link=Online Registration');
933 $this->waitForElementPresent('_qf_Registration_upload-bottom');
934 $this->click('is_online_registration');
935 $this->assertChecked('is_online_registration');
938 $this->click('requires_approval');
939 $this->assertChecked('requires_approval');
940 $this->click('_qf_Registration_upload-bottom');
941 $this->waitForText('crm-notification-container', "'Online Registration' information has been saved.");
943 // verify event input on info page
944 // start at Manage Events listing
945 $this->openCiviPage('event/manage', 'reset=1');
946 $this->click("link=$eventTitle");
947 $this->waitForPageToLoad($this->getTimeoutMsec());
948 $firstName = substr(sha1(rand()), 0, 7);
949 $this->webtestAddContact($firstName, 'Anderson', TRUE);
950 $contactName = "Anderson, $firstName";
951 $displayName = "$firstName Anderson";
952 $this->openCiviPage("event/register", "reset=1&id=$id&action=preview", '_qf_Register_upload-bottom');
953 $this->type('first_name', $firstName);
956 $lastName = 'Recuron' . substr(sha1(rand()), 0, 7);
957 $this->type('last_name', $contactName);
958 $email = $firstName . '@example.com';
959 $this->type('email-Primary', $email);
960 $this->click('_qf_Register_upload');
961 $this->waitForElementPresent("_qf_Confirm_next");
962 $this->click('_qf_Confirm_next');
963 $this->waitForPageToLoad($this->getTimeoutMsec());
964 $this->waitForElementPresent("xpath=//div[@class='crm-group participant_info-group']");
965 $this->assertTextPresent("Thank You for Registering");
970 * Test enabling participant statuses.
972 * @param int $statusId
974 public function _testEnableParticipantStatuses($statusId) {
975 // enable participant status
976 if ($this->isElementPresent("xpath=//tr[@id='participant_status_type-{$statusId}']/td[9]/span/a[2][text()='Enable']")) {
977 $this->click("xpath=//tr[@id='participant_status_type-{$statusId}']/td[9]/span/a[2][text()='Enable']");
978 $this->waitForElementPresent("xpath=//tr[@id='participant_status_type-{$statusId}']/td[9]/span/a[2][text()='Disable']");
983 * CRM-16777: Allow to add schedule reminder for event with 'edit all event' permission
985 public function testConfigureScheduleReminder() {
986 // Log in using webtestLogin() method
987 $this->webtestLogin('admin');
989 //Details for TestUser1
990 $role1 = 'role1' . substr(sha1(rand()), 0, 7);
991 $TestUser1 = "TestUser1" . substr(sha1(rand()), 0, 4);
992 $emailId1 = substr(sha1(rand()), 0, 7) . '@web.com';
994 //create Role1 with permission 'Access CiviCRM', 'edit all events' and 'Access CiviEvent' permissions.
995 $this->open($this->sboxPath
. "admin/people/permissions/roles");
996 $this->type("edit-name", $role1);
997 $this->waitForElementPresent("edit-add");
998 $this->click("edit-add");
999 $this->waitForPageToLoad($this->getTimeoutMsec());
1000 $this->open($this->sboxPath
. "admin/people/permissions/roles");
1001 $this->waitForElementPresent("xpath=//table[@id='user-roles']/tbody//tr/td[1][text()='{$role1}']");
1002 $roleId = explode('/', $this->getAttribute("xpath=//table[@id='user-roles']/tbody//tr/td[1][text()='{$role1}']/../td[4]/a[text()='edit permissions']/@href"));
1003 $permissions = array(
1004 "edit-{$roleId[5]}-access-civicrm",
1005 "edit-{$roleId[5]}-edit-all-events",
1006 "edit-{$roleId[5]}-access-civievent",
1008 $this->changePermissions($permissions);
1011 $this->open($this->sboxPath
. "admin/people/create");
1012 $this->waitForElementPresent("edit-submit");
1013 $this->type("edit-name", $TestUser1);
1014 $this->type("edit-mail", $emailId1);
1015 $this->type("edit-pass-pass1", "Test12345");
1016 $this->type("edit-pass-pass2", "Test12345");
1017 $this->click("xpath=//div[@class='form-item form-type-checkboxes form-item-roles']/div//div/label[contains(text(), '{$role1}')]");
1018 $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
1019 $lastName = 'An' . substr(sha1(rand()), 0, 7);
1020 $this->type("first_name", $firstName);
1021 $this->type("last_name", $lastName);
1022 $this->type("street_address-1", "902C El Camino Way SW");
1023 $this->type("city-1", "Dumfries");
1024 $this->type("postal_code-1", "1234");
1025 $this->select("state_province-1", "value=1019");
1026 $this->click("edit-submit");
1027 $this->waitForPageToLoad($this->getTimeoutMsec());
1030 $this->openCiviPage("event/add", "reset=1&action=add");
1031 $eventName = 'My Event - ' . substr(sha1(rand()), 0, 7);
1032 $eventDescription = "Here is a description for this conference.";
1033 $this->_testAddEventInfo($eventName, $eventDescription);
1036 $this->webtestLogout();
1038 //Login with TestUser1
1039 $this->webtestLogin($TestUser1, 'Test12345');
1040 $this->openCiviPage("event/manage", "reset=1");
1041 $this->type("title", $eventName);
1042 $this->click("_qf_SearchEvent_refresh");
1043 $this->waitForAjaxContent();
1044 $this->_testAddReminder($eventName);
1045 $this->webtestLogout();
1047 //Details for TestUser2
1048 $role2 = 'role2' . substr(sha1(rand()), 0, 5);
1049 $TestUser2 = "TestUser2" . substr(sha1(rand()), 0, 5);
1050 $emailId2 = substr(sha1(rand()), 0, 7) . '@web.com';
1052 //create Role2 with only 'Access CiviCRM' and 'Access CiviEvent' permissions
1053 $this->webtestLogin('admin');
1054 $this->open($this->sboxPath
. "admin/people/permissions/roles");
1055 $this->type("edit-name", $role2);
1056 $this->waitForElementPresent("edit-add");
1057 $this->click("edit-add");
1058 $this->waitForPageToLoad($this->getTimeoutMsec());
1059 $this->open($this->sboxPath
. "admin/people/permissions/roles");
1060 $this->waitForElementPresent("xpath=//table[@id='user-roles']/tbody//tr/td[1][text()='{$role2}']");
1061 $roleId = explode('/', $this->getAttribute("xpath=//table[@id='user-roles']/tbody//tr/td[1][text()='{$role2}']/../td[4]/a[text()='edit permissions']/@href"));
1062 $permissions = array(
1063 "edit-{$roleId[5]}-access-civicrm",
1064 "edit-{$roleId[5]}-access-civievent",
1066 $this->changePermissions($permissions);
1069 $this->open($this->sboxPath
. "admin/people/create");
1070 $this->waitForElementPresent("edit-submit");
1071 $this->type("edit-name", $TestUser2);
1072 $this->type("edit-mail", $emailId2);
1073 $this->type("edit-pass-pass1", "Test123");
1074 $this->type("edit-pass-pass2", "Test123");
1075 $this->click("xpath=//div[@class='form-item form-type-checkboxes form-item-roles']/div//div/label[contains(text(), '{$role2}')]");
1076 $firstName = 'Smith' . substr(sha1(rand()), 0, 4);
1077 $lastName = 'John' . substr(sha1(rand()), 0, 5);
1078 $this->type("first_name", $firstName);
1079 $this->type("last_name", $lastName);
1080 $this->type("street_address-1", "902C El Camino Way SW");
1081 $this->type("city-1", "Dumfries");
1082 $this->type("postal_code-1", "1234");
1083 $this->select("state_province-1", "value=1019");
1084 $this->click("edit-submit");
1085 $this->waitForPageToLoad($this->getTimeoutMsec());
1088 $this->webtestLogout();
1090 //Login with TestUser2
1091 $this->webtestLogin($TestUser2, 'Test123');
1092 $this->openCiviPage("event/manage", "reset=1");
1093 $this->waitForElementPresent("xpath=//div[@id='event_status_id']/div[@class='dataTables_wrapper no-footer']");
1094 $this->verifyText("xpath=//div[@id='event_status_id']/div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td", "None found.");
1095 $this->webtestLogout();