3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.3 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
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';
28 class WebTest_Event_AddEventTest
extends CiviSeleniumTestCase
{
30 protected function setUp() {
34 function testAddPaidEventNoTemplate() {
35 // Log in using webtestLogin() method
36 $this->webtestLogin();
38 // We need a payment processor
39 $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7);
40 $this->webtestAddPaymentProcessor($processorName);
42 $this->openCiviPage("event/add", "reset=1&action=add");
44 $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7);
45 $eventDescription = "Here is a description for this conference.";
46 $this->_testAddEventInfo($eventTitle, $eventDescription);
48 $streetAddress = "100 Main Street";
49 $this->_testAddLocation($streetAddress);
51 $this->_testAddReminder($eventTitle);
53 $this->_testAddFees(FALSE, FALSE, $processorName);
55 // intro text for registration page
56 $registerIntro = "Fill in all the fields below and click Continue.";
57 $multipleRegistrations = TRUE;
58 $this->_testAddOnlineRegistration($registerIntro, $multipleRegistrations);
60 $eventInfoStrings = array($eventTitle, $eventDescription, $streetAddress);
61 $this->_testVerifyEventInfo($eventTitle, $eventInfoStrings);
63 $registerStrings = array("225.00", "Member", "300.00", "Non-member", $registerIntro);
64 $registerUrl = $this->_testVerifyRegisterPage($registerStrings);
66 $numberRegistrations = 3;
68 $this->_testOnlineRegistration($registerUrl, $numberRegistrations, $anonymous);
71 function testAddPaidEventDiscount() {
73 // Log in using webtestLogin() method
74 $this->webtestLogin();
76 // We need a payment processor
77 $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7);
78 $this->webtestAddPaymentProcessor($processorName);
80 $this->openCiviPage("event/add", "reset=1&action=add");
82 $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7);
83 $eventDescription = "Here is a description for this conference.";
84 $this->_testAddEventInfo($eventTitle, $eventDescription);
86 $streetAddress = "100 Main Street";
87 $this->_testAddLocation($streetAddress);
89 $this->_testAddReminder($eventTitle);
91 $this->_testAddFees(TRUE, FALSE, $processorName);
93 // intro text for registration page
94 $registerIntro = "Fill in all the fields below and click Continue.";
95 $multipleRegistrations = TRUE;
96 $this->_testAddOnlineRegistration($registerIntro, $multipleRegistrations);
98 $discountFees = array("225.00", "300.00");
100 $eventInfoStrings = array($eventTitle, $eventDescription, $streetAddress);
101 $this->_testVerifyEventInfo($eventTitle, $eventInfoStrings, $discountFees);
103 $registerStrings = array_push($discountFees, "Member", "Non-member", $registerIntro);
104 $registerUrl = $this->_testVerifyRegisterPage($registerStrings);
106 $numberRegistrations = 3;
108 $this->_testOnlineRegistration($registerUrl, $numberRegistrations, $anonymous);
111 function testDeletePriceSetDiscount() {
113 // Log in using webtestLogin() method
114 $this->webtestLogin();
116 // We need a payment processor
117 $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7);
118 $this->webtestAddPaymentProcessor($processorName);
120 $this->openCiviPage("event/add", "reset=1&action=add");
122 $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7);
123 $eventDescription = "Here is a description for this conference.";
124 $this->_testAddEventInfo($eventTitle, $eventDescription);
126 $streetAddress = "100 Main Street";
127 $this->_testAddLocation($streetAddress);
130 $discount = $this->_testAddFees(TRUE, FALSE, $processorName, TRUE);
132 // intro text for registration page
133 $registerIntro = "Fill in all the fields below and click Continue.";
134 $multipleRegistrations = TRUE;
135 $this->_testAddOnlineRegistration($registerIntro, $multipleRegistrations);
137 $discountFees = array("225.00", "300.00");
139 $eventInfoStrings = array($eventTitle, $eventDescription, $streetAddress);
140 $id = $this->_testVerifyEventInfo($eventTitle, $eventInfoStrings, $discountFees);
142 $registerStrings = array_push($discountFees, "Member", "Non-member", $registerIntro);
143 $registerUrl = $this->_testVerifyRegisterPage($registerStrings);
146 $this->openCiviPage("event/manage/fee", "reset=1&action=update&id=$id", "_qf_Fee_upload-bottom");
147 $this->click("xpath=//a[@id='quickconfig']");
148 $this->waitForElementPresent('popupContainer');
149 // Because it tends to cause problems, all uses of sleep() must be justified in comments
150 // Sleep should never be used for wait for anything to load from the server
151 // Justification for this instance: FIXME
153 $this->click("xpath=//div[@class='ui-dialog-buttonset']/button[1]");
154 // Because it tends to cause problems, all uses of sleep() must be justified in comments
155 // Sleep should never be used for wait for anything to load from the server
156 // Justification for this instance: FIXME
159 //Assert quick config change and discount deletion
160 $this->openCiviPage("admin/price", "reset=1");
161 $this->assertStringsPresent($discount);
164 function testAddDeleteEventDiscount() {
166 // Log in using webtestLogin() method
167 $this->webtestLogin();
169 // We need a payment processor
170 $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7);
171 $this->webtestAddPaymentProcessor($processorName);
173 $this->openCiviPage("event/add", "reset=1&action=add");
175 $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7);
176 $eventDescription = "Here is a description for this conference.";
177 $this->_testAddEventInfo($eventTitle, $eventDescription);
179 $streetAddress = "100 Main Street";
180 $this->_testAddLocation($streetAddress);
183 $discount = $this->_testAddFees(TRUE, FALSE, $processorName, TRUE);
185 // intro text for registration page
186 $registerIntro = "Fill in all the fields below and click Continue.";
187 $multipleRegistrations = TRUE;
188 $this->_testAddOnlineRegistration($registerIntro, $multipleRegistrations);
190 $discountFees = array("225.00", "300.00");
192 $eventInfoStrings = array($eventTitle, $eventDescription, $streetAddress);
193 $id = $this->_testVerifyEventInfo($eventTitle, $eventInfoStrings, $discountFees);
195 $registerStrings = array_push($discountFees, "Member", "Non-member", $registerIntro);
196 $registerUrl = $this->_testVerifyRegisterPage($registerStrings);
197 //Delete the discount
198 $this->_deleteDiscount($id, $eventTitle, $discount);
201 function _deleteDiscount($id, $eventTitle, $discount) {
202 $this->openCiviPage("event/manage/fee", "reset=1&action=update&id=$id", "_qf_Fee_upload-bottom");
203 $this->type("discount_name_2", "");
204 $this->click("xpath=//tr[@id='discount_2']/td[3]/span/a");
205 $this->click("xpath=//tr[@id='discount_2']/td[4]/span/a");
206 $this->type("discounted_value_1_2", "");
207 $this->type("discounted_value_2_2", "");
208 $this->click("_qf_Fee_upload-bottom");
209 $this->waitForPageToLoad();
211 $this->openCiviPage("admin/price", "reset=1");
212 $this->assertStringsPresent($discount[1]);
215 function testAddPaidEventWithTemplate() {
217 // Log in using webtestLogin() method
218 $this->webtestLogin();
220 // We need a payment processor
221 $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7);
222 $this->webtestAddPaymentProcessor($processorName);
224 $this->openCiviPage("event/add", "reset=1&action=add");
226 $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7);
227 $eventDescription = "Here is a description for this conference.";
228 // Select paid online registration template.
231 $this->_testAddEventInfoFromTemplate($eventTitle, $eventDescription, $templateID, $eventTypeID);
233 $streetAddress = "100 Main Street";
234 $this->_testAddLocation($streetAddress);
236 $this->_testAddFees(FALSE, FALSE, $processorName);
238 // intro text for registration page
239 $registerIntro = "Fill in all the fields below and click Continue.";
240 $this->_testAddOnlineRegistration($registerIntro);
242 // $eventInfoStrings = array( $eventTitle, $eventDescription, $streetAddress );
243 $eventInfoStrings = array($eventTitle, $streetAddress);
244 $this->_testVerifyEventInfo($eventTitle, $eventInfoStrings);
246 $registerStrings = array("225.00", "Member", "300.00", "Non-member", $registerIntro);
247 $this->_testVerifyRegisterPage($registerStrings);
250 function testAddFreeEventWithTemplate() {
252 // Log in using webtestLogin() method
253 $this->webtestLogin();
255 $this->openCiviPage("event/add", "reset=1&action=add");
257 $eventTitle = 'My Free Meeting - ' . substr(sha1(rand()), 0, 7);
258 $eventDescription = "Here is a description for this free meeting.";
259 // Select "Free Meeting with Online Registration" template (id = 5).
263 $this->_testAddEventInfoFromTemplate($eventTitle, $eventDescription, $templateID, $eventTypeID);
265 $streetAddress = "100 Main Street";
267 $this->_testAddLocation($streetAddress);
269 // Go to Fees tab and check that Paid Event is false (No)
270 $this->click("link=Fees");
271 $this->waitForElementPresent("_qf_Fee_upload-bottom");
272 $this->verifyChecked("CIVICRM_QFID_0_is_monetary");
274 // intro text for registration page
275 $registerIntro = "Fill in all the fields below and click Continue.";
276 $this->_testAddOnlineRegistration($registerIntro);
278 // $eventInfoStrings = array( $eventTitle, $eventDescription, $streetAddress );
279 $eventInfoStrings = array($eventTitle, $streetAddress);
280 $this->_testVerifyEventInfo($eventTitle, $eventInfoStrings);
282 $registerStrings = array($registerIntro);
283 $this->_testVerifyRegisterPage($registerStrings);
284 // make sure paid_event div is NOT present since this is a free event
285 $this->verifyElementNotPresent("css=div.paid_event-section");
288 function testUnpaidPaid() {
290 // Log in using webtestLogin() method
291 $this->webtestLogin();
293 $this->openCiviPage("event/add", "reset=1&action=add");
294 $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7);
295 $eventDescription = "Here is a description for this conference.";
296 $this->_testAddEventInfo($eventTitle, $eventDescription);
298 //add fee section with pay later checked
299 $this->_testAddFees(FALSE, FALSE, NULL, FALSE, TRUE);
301 //make the event unpaid
302 $this->waitForElementPresent("_qf_Fee_upload-bottom");
303 $this->assertChecked('is_pay_later');
304 $this->click("CIVICRM_QFID_0_is_monetary");
305 $this->clickLink("_qf_Fee_upload-bottom", "_qf_Fee_upload-bottom");
307 //check if pay later option is disabled
308 $this->click('CIVICRM_QFID_1_is_monetary');
309 $this->waitForElementPresent('is_pay_later');
310 $this->assertNotChecked('is_pay_later');
313 function testAjaxCustomGroupLoad() {
314 $this->webtestLogin();
316 $triggerElement = array('name' => 'event_type_id', 'type' => 'select');
318 array('entity' => 'Event', 'subEntity' => 'Conference', 'triggerElement' => $triggerElement),
321 $pageUrl = array('url' => 'event/add', 'args' => "reset=1&action=add");
322 $this->customFieldSetLoadOnTheFlyCheck($customSets, $pageUrl);
325 function _testAddEventInfo($eventTitle, $eventDescription) {
326 $this->waitForElementPresent("_qf_EventInfo_upload-bottom");
328 $this->select("event_type_id", "value=1");
330 // Attendee role s/b selected now.
331 $this->select("default_role_id", "value=1");
333 // Enter Event Title, Summary and Description
334 $this->type("title", $eventTitle);
335 $this->type("summary", "This is a great conference. Sign up now!");
337 // Type description in ckEditor (fieldname, text to type, editor)
338 $this->fillRichTextField("description", $eventDescription, 'CKEditor');
340 // Choose Start and End dates.
341 // Using helper webtestFillDate function.
342 $this->webtestFillDateTime("start_date", "+1 week");
343 $this->webtestFillDateTime("end_date", "+1 week 1 day 8 hours ");
345 $this->type("max_participants", "50");
346 $this->click("is_map");
347 $this->click("is_public");
348 $this->click("_qf_EventInfo_upload-bottom");
349 $this->waitForPageToLoad($this->getTimeoutMsec());
352 function _testAddEventInfoFromTemplate($eventTitle, $eventDescription, $templateID, $eventTypeID) {
353 $this->waitForElementPresent("_qf_EventInfo_upload-bottom");
355 // Select event template. Use option value, not label - since labels can be translated and test would fail
356 $this->select("template_id", "value={$templateID}");
358 // Wait for event type to be filled in (since page reloads)
359 $this->waitForPageToLoad($this->getTimeoutMsec());
360 $this->verifySelectedValue("event_type_id", $eventTypeID);
362 // Attendee role s/b selected now.
363 $this->verifySelectedValue("default_role_id", "1");
365 // Enter Event Title, Summary and Description
366 $this->type("title", $eventTitle);
368 $this->type("summary", "This is a great conference. Sign up now!");
370 // Type description in ckEditor (fieldname, text to type, editor)
371 $this->fillRichTextField("description", $eventDescription, 'CKEditor');
373 // Choose Start and End dates.
374 // Using helper webtestFillDate function.
375 $this->webtestFillDateTime("start_date", "+1 week");
376 $this->webtestFillDateTime("end_date", "+1 week 1 day 8 hours ");
378 $this->type("max_participants", "50");
379 $this->click("is_map");
380 $this->click("_qf_EventInfo_upload-bottom");
384 function _testAddLocation($streetAddress) {
385 // Wait for Location tab form to load
386 $this->waitForPageToLoad($this->getTimeoutMsec());
387 $this->waitForElementPresent("_qf_Location_upload-bottom");
389 // Fill in address fields
390 $streetAddress = "100 Main Street";
391 $this->type("address_1_street_address", $streetAddress);
392 $this->type("address_1_city", "San Francisco");
393 $this->type("address_1_postal_code", "94117");
394 $this->select("address_1_state_province_id", "value=1004");
395 $this->type("email_1_email", "info@civicrm.org");
397 $this->click("_qf_Location_upload-bottom");
399 // Wait for "saved" status msg
400 $this->waitForPageToLoad($this->getTimeoutMsec());
401 $this->waitForTextPresent("'Location' information has been saved.");
404 function _testAddFees($discount = FALSE, $priceSet = FALSE, $processorName = "PP Pro", $double = FALSE, $payLater = FALSE) {
405 $discount1 = "Early-bird" . substr(sha1(rand()), 0, 7);
408 $this->click("link=Fees");
409 $this->waitForElementPresent("_qf_Fee_upload-bottom");
410 $this->click("CIVICRM_QFID_1_is_monetary");
413 $this->check('is_pay_later');
414 $this->type('pay_later_receipt', 'testing later instructions');
417 $this->uncheck('is_pay_later');
420 if ($processorName) {
421 $this->click("xpath=//tr[@class='crm-event-manage-fee-form-block-payment_processor']/td[2]/label[text()='$processorName']");
423 $this->select("financial_type_id", "value=4");
428 $this->type("label_1", "Member");
429 $this->type("value_1", "225.00");
430 $this->type("label_2", "Non-member");
431 $this->type("value_2", "300.00");
432 $this->click("CIVICRM_QFID_1_4");
436 // enter early bird discount fees
437 $this->click("is_discount");
438 $this->waitForElementPresent("discount_name_1");
439 $this->type("discount_name_1", $discount1);
440 $this->webtestFillDate("discount_start_date_1", "-3 week");
441 $this->webtestFillDate("discount_end_date_1", "-2 week");
442 $this->clickLink("_qf_Fee_submit", "discounted_value_1_1");
444 $this->type("discounted_value_1_1","225.00");
445 $this->type("discounted_value_2_1","300.00");
448 $discount2 = "Early-bird" . substr(sha1(rand()), 0, 7);
449 // enter early bird discount fees
450 $this->click("link=another discount set");
451 $this->waitForElementPresent("discount_name_2");
452 $this->type("discount_name_2", $discount2);
453 $this->webtestFillDate("discount_start_date_2", "-1 week");
454 $this->webtestFillDate("discount_end_date_2", "+1 week");
455 $this->clickLink("_qf_Fee_submit", "discounted_value_2_1");
456 $this->type("discounted_value_1_2","225.00");
457 $this->type("discounted_value_2_2","300.00");
459 $this->click("xpath=//fieldset[@id='discount']/fieldset/table/tbody/tr[2]/td[3]/input");
461 $this->click("_qf_Fee_upload-bottom");
463 // Wait for "saved" status msg
464 $this->waitForPageToLoad($this->getTimeoutMsec());
465 $this->waitForText('crm-notification-container', "'Fee' information has been saved");
466 return array($discount1, $discount2);
469 function _testAddOnlineRegistration($registerIntro, $multipleRegistrations = FALSE) {
470 // Go to Online Registration tab
471 $this->click("link=Online Registration");
472 $this->waitForElementPresent("_qf_Registration_upload-bottom");
474 $this->check("is_online_registration");
475 $this->assertChecked("is_online_registration");
476 if ($multipleRegistrations) {
477 $this->check("is_multiple_registrations");
478 $this->assertChecked("is_multiple_registrations");
481 $this->fillRichTextField("intro_text", $registerIntro);
483 // enable confirmation email
484 $this->click("CIVICRM_QFID_1_is_email_confirm");
485 $this->type("confirm_from_name", "Jane Doe");
487 $this->type("confirm_from_email", "jane.doe@example.org");
489 $this->click("_qf_Registration_upload-bottom");
490 $this->waitForPageToLoad($this->getTimeoutMsec());
491 $this->waitForTextPresent("'Registration' information has been saved.");
494 function _testVerifyEventInfo($eventTitle, $eventInfoStrings, $eventFees = NULL) {
495 // verify event input on info page
496 // start at Manage Events listing
497 $this->openCiviPage("event/manage", "reset=1");
498 $this->click("link=$eventTitle");
500 // Look for Register button
501 $this->waitForElementPresent("link=Register Now");
503 // Check for correct event info strings
504 $this->assertStringsPresent($eventInfoStrings);
506 // Optionally verify event fees (especially for discounts)
508 $this->assertStringsPresent($eventFees);
511 return $this->urlArg('id');
514 function _testVerifyRegisterPage($registerStrings) {
515 // Go to Register page and check for intro text and fee levels
516 $this->click("link=Register Now");
517 $this->waitForElementPresent("_qf_Register_upload-bottom");
518 $this->assertStringsPresent($registerStrings);
519 return $this->getLocation();
522 function _testOnlineRegistration($registerUrl, $numberRegistrations = 1, $anonymous = TRUE, $isPayLater = FALSE) {
524 $this->webtestLogout();
526 $this->open($registerUrl);
527 $this->waitForPageToLoad($this->getTimeoutMsec());
528 $this->select("additional_participants", "value=" . $numberRegistrations);
529 $this->type("email-Primary", "smith" . substr(sha1(rand()), 0, 7) . "@example.org");
531 $this->select("credit_card_type", "value=Visa");
532 $this->type("credit_card_number", "4111111111111111");
533 $this->type("cvv2", "000");
534 $this->select("credit_card_exp_date[M]", "value=1");
535 $this->select("credit_card_exp_date[Y]", "value=2020");
536 $this->type("billing_first_name", "Jane");
537 $this->type("billing_last_name", "Smith" . substr(sha1(rand()), 0, 7));
538 $this->type("billing_street_address-5", "15 Main St.");
539 $this->type(" billing_city-5", "San Jose");
540 $this->select("billing_country_id-5", "value=1228");
541 $this->select("billing_state_province_id-5", "value=1004");
542 $this->type("billing_postal_code-5", "94129");
545 $this->click("_qf_Register_upload-bottom");
547 if ($numberRegistrations > 1) {
548 for ($i = 1; $i <= $numberRegistrations; $i++
) {
549 $this->waitForPageToLoad($this->getTimeoutMsec());
550 // Look for Skip button
551 $this->waitForElementPresent("_qf_Participant_{$i}_next_skip-Array");
552 $this->type("email-Primary", "smith" . substr(sha1(rand()), 0, 7) . "@example.org");
553 $this->click("_qf_Participant_{$i}_next");
557 $this->waitForPageToLoad($this->getTimeoutMsec());
558 $this->waitForElementPresent("_qf_Confirm_next-bottom");
559 $confirmStrings = array("Event Fee(s)");
561 $confirmStrings +
= array("Billing Name and Address", "Credit Card Information");
563 $this->assertStringsPresent($confirmStrings);
564 $this->click("_qf_Confirm_next-bottom");
565 $this->waitForPageToLoad($this->getTimeoutMsec());
566 $thankStrings = array("Thank You for Registering", "Event Total");
568 $thankStrings = array("Transaction Date");
571 $thankStrings +
= array("testing later instructions");
573 $this->assertStringsPresent($thankStrings);
576 function _testAddReminder($eventTitle) {
577 // Go to Schedule Reminders tab
578 $this->click('css=li#tab_reminder a');
579 $this->waitForElementPresent("_qf_ScheduleReminders_upload-bottom");
580 $this->type("title", "Event Reminder for " . $eventTitle);
581 $this->select('entity', 'label=Registered');
583 $this->select('start_action_offset', 'label=1');
584 $this->select('start_action_condition', 'label=after');
585 $this->click('is_repeat');
586 $this->select('repetition_frequency_interval', 'label=2');
587 $this->select('end_date', 'label=Event End Date');
588 $this->click('recipient');
589 $this->select('recipient', 'label=Participant Role');
590 // $this->select( 'recipient_listing', 'value=1' );
593 $subject = 'subject' . substr(sha1(rand()), 0, 4);
594 $this->type('subject', $subject);
595 $this->fillRichTextField("html_message", "This is the test HTML version here!!!", 'CKEditor');
597 $this->type("text_message", "This is the test text version here!!!");
599 $this->click('_qf_ScheduleReminders_upload-bottom');
600 $this->waitForElementPresent("link=Add Reminder");
602 $this->waitForElementPresent("link=Edit");
605 1 => 'Event Reminder for ' . $eventTitle,
606 3 => '1 hour after Event Start Date',
612 //verify the fields for Event Reminder selector
613 foreach ($verifyText as $key => $value) {
614 $this->verifyText("xpath=//table[@class='display']/tbody/tr/td[$key]", $value);
618 function testEventAddMultipleParticipant() {
619 // Log in using webtestLogin() method
620 $this->webtestLogin();
621 $this->openCiviPage("event/add", "reset=1&action=add");
623 $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7);
624 $eventDescription = "Here is a description for this conference.";
625 $this->_testAddEventInfo($eventTitle, $eventDescription);
626 $streetAddress = "100 Main Street";
627 $this->_testAddLocation($streetAddress);
629 $this->_testAddFees(FALSE, FALSE, NULL, FALSE, TRUE);
630 $registerIntro = "Fill in all the fields below and click Continue.";
631 $multipleRegistrations = TRUE;
632 $this->_testAddOnlineRegistration($registerIntro, $multipleRegistrations);
633 $eventInfoStrings = array($eventTitle, $eventDescription, $streetAddress);
634 $this->_testVerifyEventInfo($eventTitle, $eventInfoStrings);
636 $registerStrings = array("225.00", "Member", "300.00", "Non-member", $registerIntro);
637 $registerUrl = $this->_testVerifyRegisterPage($registerStrings);
639 $numberRegistrations = 3;
641 // add participant and 3 additional participant and change status of participant from edit participant
642 $this->_testOnlineRegistration($registerUrl, $numberRegistrations, $anonymous, TRUE);
643 $this->webtestLogin();
645 $this->openCiviPage("event/search?reset=1", "reset=1");
646 $this->type('event_name', $eventTitle);
647 $this->click("event_name");
648 $this->waitForElementPresent("css=div.ac_results-inner li");
649 $this->click("css=div.ac_results-inner li");
650 $this->click("xpath=//td[@class='crm-event-form-block-participant_status']/div[@class='listing-box']//div/label[text()='Pending from pay later']");
651 $this->click('_qf_Search_refresh');
652 $this->waitForPageToLoad($this->getTimeoutMsec());
653 $this->click("xpath=//div[@id='participantSearch']/table/tbody//tr/td[11]/span/a[text()='Edit']");
654 $this->waitForPageToLoad($this->getTimeoutMsec());
655 $this->select('status_id', 'label=Registered');
656 $this->click('record_contribution');
657 $this->select('contribution_status_id', 'label=Completed');
658 $pID = $this->urlArg('id');
659 $contributionID = CRM_Core_DAO
::getFieldValue('CRM_Event_DAO_ParticipantPayment', $pID, 'contribution_id', 'participant_id');
660 $this->click('_qf_Participant_upload-top');
661 $this->waitForPageToLoad($this->getTimeoutMsec());
662 $this->verifyFinancialRecords($contributionID);
664 // add participant and 3 additional participant and change status of participant from edit contribution
665 $this->_testOnlineRegistration($registerUrl, $numberRegistrations, $anonymous, TRUE);
666 $this->webtestLogin();
668 $this->openCiviPage("event/search?reset=1", "reset=1"); $this->type('event_name', $eventTitle);
669 $this->click("event_name");
670 $this->waitForElementPresent("css=div.ac_results-inner li");
671 $this->click("css=div.ac_results-inner li");
672 $this->click("xpath=//td[@class='crm-event-form-block-participant_status']/div[@class='listing-box']//div/label[text()='Pending from pay later']");
673 $this->click('_qf_Search_refresh');
674 $this->waitForPageToLoad($this->getTimeoutMsec());
675 $this->click("xpath=//div[@id='participantSearch']/table/tbody//tr/td[11]/span/a[text()='View']");
676 $this->waitForPageToLoad($this->getTimeoutMsec());
677 $pID = $this->urlArg('id');
678 $contributionID = CRM_Core_DAO
::getFieldValue('CRM_Event_DAO_ParticipantPayment', $pID, 'contribution_id', 'participant_id');
679 $this->click("xpath=//tr[@id='rowid$contributionID']/td[8]/span//a[text()='Edit']");
680 $this->waitForPageToLoad($this->getTimeoutMsec());
681 $this->select('contribution_status_id', 'label=Completed');
682 $this->click('_qf_Contribution_upload-bottom');
683 $this->waitForPageToLoad($this->getTimeoutMsec());
684 $this->verifyFinancialRecords($contributionID);
687 function verifyFinancialRecords($contributionID) {
688 // check count for civicrm_contribution and civicrm_financial_item in civicrm_entity_financial_trxn
689 $query = "SELECT COUNT(DISTINCT(c1.id)) civicrm_contribution, COUNT(c2.id) civicrm_financial_item FROM civicrm_entity_financial_trxn c1
690 LEFT JOIN civicrm_entity_financial_trxn c2 ON c1.financial_trxn_id = c2.financial_trxn_id AND c2.entity_table ='civicrm_financial_item'
691 LEFT JOIN civicrm_financial_item cfi ON cfi.id = c2.entity_id
692 WHERE c1.entity_table = 'civicrm_contribution' AND c1.entity_id = %1 AND cfi.status_id = 1";
693 $params = array(1 => array($contributionID, 'Integer'));
694 $dao = CRM_Core_DAO
::executeQuery($query, $params);
696 $this->assertEquals('2', $dao->civicrm_contribution
, 'civicrm_financial_trxn count does not match');
697 $this->assertEquals('8',$dao->civicrm_financial_item
, 'civicrm_financial_item count does not match');
698 $query = "SELECT COUNT(cft.id) civicrm_financial_trxn FROM civicrm_entity_financial_trxn ceft
699 INNER JOIN civicrm_financial_trxn cft ON ceft.financial_trxn_id = cft.id
700 WHERE ceft.entity_id = %1 AND ceft.entity_table = 'civicrm_contribution'";
701 $dao = CRM_Core_DAO
::executeQuery($query, $params);
703 $this->assertEquals('2', $dao->civicrm_financial_trxn
, 'civicrm_financial_trxn count does not match');