3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.4 |
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_MultipleEventRegistrationbyCartTest
extends CiviSeleniumTestCase
{
30 protected function setUp() {
34 // this functionality is broken hence skipping the test
35 function skiptestAuthenticatedMultipleEvent() {
37 // Log in using webtestLogin() method
38 $this->webtestLogin();
40 //Enable shopping cart style
41 $this->openCiviPage("admin/setting/preferences/event", "reset=1");
42 $this->check("enable_cart");
43 $this->click("_qf_Event_next-top");
44 $this->waitForPageToLoad($this->getTimeoutMsec());
46 // We need a payment processor
47 $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7);
48 $this->webtestAddPaymentProcessor($processorName);
52 $this->openCiviPage("event/add", "reset=1&action=add");
54 $eventTitle1 = 'My Conference1 - ' . substr(sha1(rand()), 0, 7);
55 $eventDescription1 = "Here is a description for this conference 1.";
56 $this->_testAddEventInfo($eventTitle1, $eventDescription1);
58 $streetAddress1 = "100 Main Street";
59 $this->_testAddLocation($streetAddress1);
61 $this->_testAddFees(FALSE, FALSE, $processorName);
63 // intro text for registration page
64 $registerIntro = "Fill in all the fields below and click Continue.";
65 $multipleRegistrations = TRUE;
66 $this->_testAddOnlineRegistration($registerIntro, $multipleRegistrations);
68 $eventInfoStrings1 = array($eventTitle1, $eventDescription1, $streetAddress1);
69 $this->_AddEventToCart($eventTitle1, $eventInfoStrings1);
73 $this->openCiviPage("event/add", "reset=1&action=add");
75 $eventTitle2 = 'My Conference2 - ' . substr(sha1(rand()), 0, 7);
76 $eventDescription2 = "Here is a description for this conference 2.";
77 $this->_testAddEventInfo($eventTitle2, $eventDescription2);
79 $streetAddress2 = "101 Main Street";
80 $this->_testAddLocation($streetAddress2);
82 $this->_testAddFees(FALSE, FALSE, $processorName);
84 // intro text for registration page
85 $registerIntro = "Fill in all the fields below and click Continue.";
86 $multipleRegistrations = TRUE;
87 $this->_testAddOnlineRegistration($registerIntro, $multipleRegistrations);
89 $eventInfoStrings2 = array($eventTitle2, $eventDescription2, $streetAddress2);
90 $this->_AddEventToCart($eventTitle2, $eventInfoStrings2);
94 $this->openCiviPage("event/add", "reset=1&action=add");
96 $eventTitle3 = 'My Conference3 - ' . substr(sha1(rand()), 0, 7);
97 $eventDescription3 = "Here is a description for this conference 3.";
98 $this->_testAddEventInfo($eventTitle3, $eventDescription3);
100 $streetAddress3 = "102 Main Street";
101 $this->_testAddLocation($streetAddress3);
103 $this->_testAddFees(FALSE, FALSE, $processorName);
105 // intro text for registration page
106 $registerIntro = "Fill in all the fields below and click Continue.";
107 $multipleRegistrations = TRUE;
108 $this->_testAddOnlineRegistration($registerIntro, $multipleRegistrations);
110 $eventInfoStrings3 = array($eventTitle3, $eventDescription3, $streetAddress3);
111 $this->_AddEventToCart($eventTitle3, $eventInfoStrings3);
114 $value = $this->_testCheckOut();
122 //check the existence of the contacts who were registered and the one who did the contribution
124 $this->_checkContributionsandEventRegistration($value[0], $value[1], $events);
127 // this functionality is broken hence skipping the test
128 function skiptestAnonymousMultipleEvent() {
129 // This is the path where our testing install resides.
130 // The rest of URL is defined in CiviSeleniumTestCase base class, in
133 // Log in using webtestLogin() method
134 $this->webtestLogin();
136 // We need a payment processor
137 $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7);
138 $this->webtestAddPaymentProcessor($processorName);
142 $this->openCiviPage("event/add", "reset=1&action=add");
144 $eventTitle1 = 'My Conference1 - ' . substr(sha1(rand()), 0, 7);
145 $eventDescription1 = "Here is a description for this conference 1.";
146 $this->_testAddEventInfo($eventTitle1, $eventDescription1);
148 $streetAddress1 = "100 Main Street";
149 $this->_testAddLocation($streetAddress1);
151 $this->_testAddFees(FALSE, FALSE, $processorName);
153 // intro text for registration page
154 $registerIntro = "Fill in all the fields below and click Continue.";
155 $multipleRegistrations = TRUE;
156 $this->_testAddOnlineRegistration($registerIntro, $multipleRegistrations);
158 $eventInfoStrings1 = array($eventTitle1, $eventDescription1, $streetAddress1);
159 $registerUrl1 = $this->_testVerifyEventInfo($eventTitle1, $eventInfoStrings1);
163 $this->openCiviPage("event/add", "reset=1&action=add");
165 $eventTitle2 = 'My Conference2 - ' . substr(sha1(rand()), 0, 7);
166 $eventDescription2 = "Here is a description for this conference 2.";
167 $this->_testAddEventInfo($eventTitle2, $eventDescription2);
169 $streetAddress2 = "101 Main Street";
170 $this->_testAddLocation($streetAddress2);
172 $this->_testAddFees(FALSE, FALSE, $processorName);
174 // intro text for registration page
175 $registerIntro = "Fill in all the fields below and click Continue.";
176 $multipleRegistrations = TRUE;
177 $this->_testAddOnlineRegistration($registerIntro, $multipleRegistrations);
179 $eventInfoStrings2 = array($eventTitle2, $eventDescription2, $streetAddress2);
180 $registerUrl2 = $this->_testVerifyEventInfo($eventTitle2, $eventInfoStrings2);
184 $this->openCiviPage("event/add", "reset=1&action=add");
186 $eventTitle3 = 'My Conference3 - ' . substr(sha1(rand()), 0, 7);
187 $eventDescription3 = "Here is a description for this conference 3.";
188 $this->_testAddEventInfo($eventTitle3, $eventDescription3);
190 $streetAddress3 = "102 Main Street";
191 $this->_testAddLocation($streetAddress3);
193 $this->_testAddFees(FALSE, FALSE, $processorName);
195 // intro text for registration page
196 $registerIntro = "Fill in all the fields below and click Continue.";
197 $multipleRegistrations = TRUE;
198 $this->_testAddOnlineRegistration($registerIntro, $multipleRegistrations);
200 $eventInfoStrings3 = array($eventTitle3, $eventDescription3, $streetAddress3);
201 $registerUrl3 = $this->_testVerifyEventInfo($eventTitle3, $eventInfoStrings3);
203 //Enable shopping cart style
204 $this->openCiviPage("admin/setting/preferences/event", "reset=1");
205 $this->check("enable_cart");
206 $this->click("_qf_Event_next-top");
208 $numberRegistrations = 1;
210 $this->_testOnlineRegistration($registerUrl1, $numberRegistrations, $anonymous);
211 $this->_testOnlineRegistration($registerUrl2, $numberRegistrations, $anonymous);
212 $this->_testOnlineRegistration($registerUrl3, $numberRegistrations, $anonymous);
214 $value = $this->_testCheckOut();
215 // Log in using webtestLogin() method
216 $this->webtestLogin();
218 $this->openCiviPage("dashboard", "reset=1");
226 //check the existence of the contacts who were registered and the one who did the contribution
228 $this->_checkContributionsandEventRegistration($value[0], $value[1], $events);
231 function _testAddEventInfo($eventTitle, $eventDescription) {
232 $this->waitForElementPresent("_qf_EventInfo_upload-bottom");
234 $this->select("event_type_id", "value=1");
236 // Attendee role s/b selected now.
237 $this->select("default_role_id", "value=1");
239 // Enter Event Title, Summary and Description
240 $this->type("title", $eventTitle);
241 $this->type("summary", "This is a great conference. Sign up now!");
243 // Type description in ckEditor (fieldname, text to type, editor)
244 $this->fillRichTextField("description", $eventDescription, 'CKEditor');
246 // Choose Start and End dates.
247 // Using helper webtestFillDate function.
248 $this->webtestFillDateTime("start_date", "+1 week");
249 $this->webtestFillDateTime("end_date", "+1 week 1 day 8 hours ");
251 $this->type("max_participants", "50");
252 $this->click("is_map");
253 $this->click("_qf_EventInfo_upload-bottom");
256 function _testAddLocation($streetAddress) {
257 // Wait for Location tab form to load
258 $this->waitForPageToLoad($this->getTimeoutMsec());
259 $this->waitForElementPresent("_qf_Location_upload-bottom");
261 $this->type("address_1_street_address", $streetAddress);
262 $this->type("address_1_city", "San Francisco");
263 $this->type("address_1_postal_code", "94117");
264 $this->select("address_1_state_province_id", "value=1004");
265 $this->type("email_1_email", "info@civicrm.org");
267 $this->click("_qf_Location_upload-bottom");
269 // Wait for "saved" status msg
270 $this->waitForPageToLoad($this->getTimeoutMsec());
271 $this->waitForTextPresent("'Location' information has been saved.");
274 function _testAddFees($discount = FALSE, $priceSet = FALSE, $processorName = "PP Pro") {
276 $this->click("link=Fees");
277 $this->waitForElementPresent("_qf_Fee_upload-bottom");
278 $this->click("CIVICRM_QFID_1_is_monetary");
279 $this->click("xpath=//tr[@class='crm-event-manage-fee-form-block-payment_processor']/td[2]/label[text()='$processorName']");
280 $this->select('financial_type_id', 'Event Fee');
285 $this->type("label_1", "Member");
286 $this->type("value_1", "250.00");
287 $this->type("label_2", "Non-member");
288 $this->type("value_2", "325.00");
289 $this->click("CIVICRM_QFID_2_6");
293 // enter early bird discount fees
294 $this->click("is_discount");
295 $this->waitForElementPresent("discount_name_1");
296 $this->type("discount_name_1", "Early-bird" . substr(sha1(rand()), 0, 7));
297 $this->webtestFillDate("discount_start_date_1", "-1 week");
298 $this->webtestFillDate("discount_end_date_1", "+2 week");
299 $this->clickLink("_qf_Fee_submit", "discounted_value_2_1");
300 $this->type("discounted_value_1_1", "225.00");
301 $this->type("discounted_value_2_1", "300.00");
302 $this->click("xpath=//fieldset[@id='discount']/fieldset/table/tbody/tr[2]/td[3]/input");
305 $this->click("_qf_Fee_upload-bottom");
307 // Wait for "saved" status msg
308 $this->waitForPageToLoad($this->getTimeoutMsec());
309 $this->waitForTextPresent("'Fee' information has been saved.");
312 function _testAddOnlineRegistration($registerIntro, $multipleRegistrations = FALSE) {
313 // Go to Online Registration tab
314 $this->click("link=Online Registration");
315 $this->waitForElementPresent("_qf_Registration_upload-bottom");
317 $this->check("is_online_registration");
318 $this->assertChecked("is_online_registration");
319 if ($multipleRegistrations) {
320 $this->check("is_multiple_registrations");
321 $this->assertChecked("is_multiple_registrations");
324 $this->fillRichTextField("intro_text", $registerIntro);
326 // enable confirmation email
327 $this->click("CIVICRM_QFID_1_is_email_confirm");
328 $this->type("confirm_from_name", "Jane Doe");
329 $this->type("confirm_from_email", "jane.doe@example.org");
331 $this->click("_qf_Registration_upload-bottom");
332 $this->waitForPageToLoad($this->getTimeoutMsec());
333 $this->waitForTextPresent("'Registration' information has been saved.");
336 function _AddEventToCart($eventTitle, $eventInfoStrings, $eventFees = NULL) {
337 // verify event input on info page
338 // start at Manage Events listing
339 $this->openCiviPage("event/manage", "reset=1");
340 $this->clickLink("link=$eventTitle", "link=Add to Cart");
341 $this->click("link=Add to Cart");
342 $this->waitForPageToLoad($this->getTimeoutMsec());
343 $this->assertTrue($this->isTextPresent("$eventTitle has been added to your cart"));
346 function _testVerifyEventInfo($eventTitle, $eventInfoStrings, $eventFees = NULL) {
347 // verify event input on info page
348 // start at Manage Events listing
349 $this->openCiviPage("event/manage", "reset=1");
350 $this->click("link=$eventTitle");
351 $this->waitForPageToLoad($this->getTimeoutMsec());
353 // Check for correct event info strings
354 $this->assertStringsPresent($eventInfoStrings);
356 // Optionally verify event fees (especially for discounts)
358 $this->assertStringsPresent($eventFees);
361 return $this->getLocation();
364 function _testOnlineRegistration($registerUrl, $numberRegistrations = 1, $anonymous = TRUE) {
366 $this->webtestLogout();
368 $this->open($registerUrl);
369 $this->waitForPageToLoad($this->getTimeoutMsec());
370 $this->waitForElementPresent("link=Add to Cart");
371 $this->click("link=Add to Cart");
372 $this->waitForPageToLoad($this->getTimeoutMsec());
375 function _testCheckOut() {
377 $this->click("xpath=//div[@id='messages']/div/div/a[text()='View your cart.']");
380 $this->waitForElementPresent("xpath=//a[@class='button crm-check-out-button']/span");
381 $this->click("xpath=//a[@class='button crm-check-out-button']/span");
382 $this->waitForPageToLoad($this->getTimeoutMsec());
384 $firstName = "AB" . substr(sha1(rand()), 0, 7);
385 $lastName = "XY" . substr(sha1(rand()), 0, 7);
386 for ($i = 1; $i <= 3; $i++
) {
387 $this->type("xpath=//form[@id='ParticipantsAndPrices']/fieldset[$i]/div/fieldset/div/div/fieldset/div/div[2]/input", "{$firstName}.{$lastName}@home.com");
388 $this->type("xpath=//form[@id='ParticipantsAndPrices']/fieldset[$i]/div/fieldset/div/div[2]/div[2]/input", "{$firstName}.{$lastName}@example.com");
389 $this->click("xpath=//form[@id='ParticipantsAndPrices']/fieldset[$i]/div[2]/div[2]/input[2]");
391 $this->click("_qf_ParticipantsAndPrices_upload-bottom");
392 $this->waitForPageToLoad($this->getTimeoutMsec());
393 $this->select("credit_card_type", "value=Visa");
394 $this->type("credit_card_number", "4111111111111111");
395 $this->type("cvv2", "000");
396 $this->select("credit_card_exp_date[M]", "value=1");
397 $this->select("credit_card_exp_date[Y]", "value=2020");
398 $this->type("billing_first_name", $firstName);
399 $this->type("billing_last_name", $lastName);
400 $this->type("billing_street_address-5", "15 Main St.");
401 $this->type(" billing_city-5", "San Jose");
402 $this->select("billing_country_id-5", "value=1228");
403 $this->select("billing_state_province_id-5", "value=1004");
404 $this->type("billing_postal_code-5", "94129");
405 $this->type("billing_contact_email", "{$firstName}.{$lastName}@example.com");
407 $this->click("_qf_Payment_next-bottom");
408 $this->waitForPageToLoad($this->getTimeoutMsec());
410 $this->assertTrue($this->isTextPresent("This is your receipt of payment made for the following event registration."));
411 return array($firstName, $lastName);
414 function _checkContributionsandEventRegistration($firstName, $lastName, $events) {
415 //Type the registered participant's email in autocomplete.
416 $this->click('sort_name_navigation');
417 $this->type('css=input#sort_name_navigation', "{$firstName}.{$lastName}@home.com");
418 $this->typeKeys('css=input#sort_name_navigation', "{$firstName}.{$lastName}@home.com");
420 // Wait for result list.
421 $this->waitForElementPresent("css=div.ac_results-inner li");
423 // Visit contact summary page.
424 $this->click("css=div.ac_results-inner li");
425 $this->waitForPageToLoad($this->getTimeoutMsec());
427 //click on Events Tab
428 $this->click("xpath=//li[@id='tab_participant']/a");
429 //check if the participant is registered for all the three events
430 foreach ($events as $key => $value) {
431 $this->waitForElementPresent("link=$value");
432 $this->assertTrue($this->isElementPresent("link=$value"));
434 for ($i = 1; $i <= 3; $i++
) {
435 $this->waitForElementPresent("xpath=//table[@class='selector']/tbody/tr[$i]/td[6][text()='Registered']");
436 $this->assertTrue($this->isElementPresent("xpath=//table[@class='selector']/tbody/tr[$i]/td[6][text()='Registered']"));
439 //Type the billing email in autocomplete.
440 $this->click('sort_name_navigation');
441 $this->type('css=input#sort_name_navigation', "{$firstName}.{$lastName}@example.com");
442 $this->typeKeys('css=input#sort_name_navigation', "{$firstName}.{$lastName}@example.com");
444 // Wait for result list.
445 $this->waitForElementPresent("css=div.ac_results-inner li");
447 // Visit contact summary page.
448 $this->click("css=div.ac_results-inner li");
449 $this->waitForPageToLoad($this->getTimeoutMsec());
451 //click on Contributions Tab
452 $this->click("xpath=//li[@id='tab_contribute']/a");
453 //check for the three contributions
454 foreach ($events as $key => $value) {
455 $this->waitForElementPresent("xpath=//table[@class='selector']/tbody/tr/td[3][contains(text(),'$value')]");
456 $this->assertTrue($this->isElementPresent("xpath=//table[@class='selector']/tbody/tr/td[3][contains(text(),'$value')]"));
459 //Disable shopping cart style
460 $this->openCiviPage("admin/setting/preferences/event", "reset=1");
461 $this->click("enable_cart");
462 $this->click("_qf_Event_next-top");