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_MultipleEventRegistrationbyCartTest
extends CiviSeleniumTestCase
{
30 protected function setUp() {
34 function testAuthenticatedMultipleEvent(){
36 // Log in using webtestLogin() method
37 $this->webtestLogin();
39 //Enable shopping cart style
40 $this->openCiviPage("admin/setting/preferences/event", "reset=1");
41 $this->check("enable_cart");
42 $this->click("_qf_Event_next-top");
43 $this->waitForPageToLoad($this->getTimeoutMsec());
45 // We need a payment processor
46 $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7);
47 $this->webtestAddPaymentProcessor($processorName);
51 $this->openCiviPage("event/add", "reset=1&action=add");
53 $eventTitle1 = 'My Conference1 - ' . substr(sha1(rand()), 0, 7);
54 $eventDescription1 = "Here is a description for this conference 1.";
55 $this->_testAddEventInfo($eventTitle1, $eventDescription1);
57 $streetAddress1 = "100 Main Street";
58 $this->_testAddLocation($streetAddress1);
60 $this->_testAddFees(FALSE, FALSE, $processorName);
62 // intro text for registration page
63 $registerIntro = "Fill in all the fields below and click Continue.";
64 $multipleRegistrations = TRUE;
65 $this->_testAddOnlineRegistration($registerIntro, $multipleRegistrations);
67 $eventInfoStrings1 = array($eventTitle1, $eventDescription1, $streetAddress1);
68 $this->_AddEventToCart($eventTitle1, $eventInfoStrings1);
72 $this->openCiviPage("event/add", "reset=1&action=add");
74 $eventTitle2 = 'My Conference2 - ' . substr(sha1(rand()), 0, 7);
75 $eventDescription2 = "Here is a description for this conference 2.";
76 $this->_testAddEventInfo($eventTitle2, $eventDescription2);
78 $streetAddress2 = "101 Main Street";
79 $this->_testAddLocation($streetAddress2);
81 $this->_testAddFees(FALSE, FALSE, $processorName);
83 // intro text for registration page
84 $registerIntro = "Fill in all the fields below and click Continue.";
85 $multipleRegistrations = TRUE;
86 $this->_testAddOnlineRegistration($registerIntro, $multipleRegistrations);
88 $eventInfoStrings2 = array($eventTitle2, $eventDescription2, $streetAddress2);
89 $this->_AddEventToCart($eventTitle2, $eventInfoStrings2);
93 $this->openCiviPage("event/add", "reset=1&action=add");
95 $eventTitle3 = 'My Conference3 - ' . substr(sha1(rand()), 0, 7);
96 $eventDescription3 = "Here is a description for this conference 3.";
97 $this->_testAddEventInfo($eventTitle3, $eventDescription3);
99 $streetAddress3 = "102 Main Street";
100 $this->_testAddLocation($streetAddress3);
102 $this->_testAddFees(FALSE, FALSE, $processorName);
104 // intro text for registration page
105 $registerIntro = "Fill in all the fields below and click Continue.";
106 $multipleRegistrations = TRUE;
107 $this->_testAddOnlineRegistration($registerIntro, $multipleRegistrations);
109 $eventInfoStrings3 = array($eventTitle3, $eventDescription3, $streetAddress3);
110 $this->_AddEventToCart($eventTitle3, $eventInfoStrings3);
113 $value = $this->_testCheckOut();
116 $events = array( 1 => $eventTitle1,
120 //check the existence of the contacts who were registered and the one who did the contribution
122 $this->_checkContributionsandEventRegistration($value[0],$value[1],$events);
125 function testAnonymousMultipleEvent(){
126 // This is the path where our testing install resides.
127 // The rest of URL is defined in CiviSeleniumTestCase base class, in
130 // Log in using webtestLogin() method
131 $this->webtestLogin();
133 // We need a payment processor
134 $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7);
135 $this->webtestAddPaymentProcessor($processorName);
139 $this->openCiviPage("event/add", "reset=1&action=add");
141 $eventTitle1 = 'My Conference1 - ' . substr(sha1(rand()), 0, 7);
142 $eventDescription1 = "Here is a description for this conference 1.";
143 $this->_testAddEventInfo($eventTitle1, $eventDescription1);
145 $streetAddress1 = "100 Main Street";
146 $this->_testAddLocation($streetAddress1);
148 $this->_testAddFees(FALSE, FALSE, $processorName);
150 // intro text for registration page
151 $registerIntro = "Fill in all the fields below and click Continue.";
152 $multipleRegistrations = TRUE;
153 $this->_testAddOnlineRegistration($registerIntro, $multipleRegistrations);
155 $eventInfoStrings1 = array($eventTitle1, $eventDescription1, $streetAddress1);
156 $registerUrl1 = $this->_testVerifyEventInfo($eventTitle1, $eventInfoStrings1);
160 $this->openCiviPage("event/add", "reset=1&action=add");
162 $eventTitle2 = 'My Conference2 - ' . substr(sha1(rand()), 0, 7);
163 $eventDescription2 = "Here is a description for this conference 2.";
164 $this->_testAddEventInfo($eventTitle2, $eventDescription2);
166 $streetAddress2 = "101 Main Street";
167 $this->_testAddLocation($streetAddress2);
169 $this->_testAddFees(FALSE, FALSE, $processorName);
171 // intro text for registration page
172 $registerIntro = "Fill in all the fields below and click Continue.";
173 $multipleRegistrations = TRUE;
174 $this->_testAddOnlineRegistration($registerIntro, $multipleRegistrations);
176 $eventInfoStrings2 = array($eventTitle2, $eventDescription2, $streetAddress2);
177 $registerUrl2 = $this->_testVerifyEventInfo($eventTitle2, $eventInfoStrings2);
181 $this->openCiviPage("event/add", "reset=1&action=add");
183 $eventTitle3 = 'My Conference3 - ' . substr(sha1(rand()), 0, 7);
184 $eventDescription3 = "Here is a description for this conference 3.";
185 $this->_testAddEventInfo($eventTitle3, $eventDescription3);
187 $streetAddress3 = "102 Main Street";
188 $this->_testAddLocation($streetAddress3);
190 $this->_testAddFees(FALSE, FALSE, $processorName);
192 // intro text for registration page
193 $registerIntro = "Fill in all the fields below and click Continue.";
194 $multipleRegistrations = TRUE;
195 $this->_testAddOnlineRegistration($registerIntro, $multipleRegistrations);
197 $eventInfoStrings3 = array($eventTitle3, $eventDescription3, $streetAddress3);
198 $registerUrl3 = $this->_testVerifyEventInfo($eventTitle3, $eventInfoStrings3);
200 //Enable shopping cart style
201 $this->openCiviPage("admin/setting/preferences/event", "reset=1");
202 $this->check("enable_cart");
203 $this->click("_qf_Event_next-top");
205 $numberRegistrations = 1;
207 $this->_testOnlineRegistration($registerUrl1, $numberRegistrations, $anonymous);
208 $this->_testOnlineRegistration($registerUrl2, $numberRegistrations, $anonymous);
209 $this->_testOnlineRegistration($registerUrl3, $numberRegistrations, $anonymous);
211 $value = $this->_testCheckOut();
212 // Log in using webtestLogin() method
213 $this->webtestLogin();
215 $this->openCiviPage("dashboard", "reset=1");
218 $events = array( 1 => $eventTitle1,
222 //check the existence of the contacts who were registered and the one who did the contribution
224 $this->_checkContributionsandEventRegistration($value[0],$value[1],$events);
227 function _testAddEventInfo($eventTitle, $eventDescription) {
228 $this->waitForElementPresent("_qf_EventInfo_upload-bottom");
230 $this->select("event_type_id", "value=1");
232 // Attendee role s/b selected now.
233 $this->select("default_role_id", "value=1");
235 // Enter Event Title, Summary and Description
236 $this->type("title", $eventTitle);
237 $this->type("summary", "This is a great conference. Sign up now!");
239 // Type description in ckEditor (fieldname, text to type, editor)
240 $this->fillRichTextField("description", $eventDescription, 'CKEditor');
242 // Choose Start and End dates.
243 // Using helper webtestFillDate function.
244 $this->webtestFillDateTime("start_date", "+1 week");
245 $this->webtestFillDateTime("end_date", "+1 week 1 day 8 hours ");
247 $this->type("max_participants", "50");
248 $this->click("is_map");
249 $this->click("_qf_EventInfo_upload-bottom");
252 function _testAddLocation($streetAddress) {
253 // Wait for Location tab form to load
254 $this->waitForPageToLoad($this->getTimeoutMsec());
255 $this->waitForElementPresent("_qf_Location_upload-bottom");
257 $this->type("address_1_street_address", $streetAddress);
258 $this->type("address_1_city", "San Francisco");
259 $this->type("address_1_postal_code", "94117");
260 $this->select("address_1_state_province_id", "value=1004");
261 $this->type("email_1_email", "info@civicrm.org");
263 $this->click("_qf_Location_upload-bottom");
265 // Wait for "saved" status msg
266 $this->waitForPageToLoad($this->getTimeoutMsec());
267 $this->waitForTextPresent("'Location' information has been saved.");
270 function _testAddFees($discount = FALSE, $priceSet = FALSE, $processorName = "PP Pro") {
272 $this->click("link=Fees");
273 $this->waitForElementPresent("_qf_Fee_upload-bottom");
274 $this->click("CIVICRM_QFID_1_is_monetary");
275 $this->click("xpath=//tr[@class='crm-event-manage-fee-form-block-payment_processor']/td[2]/label[text()='$processorName']");
276 $this->select('financial_type_id','Event Fee');
281 $this->type("label_1", "Member");
282 $this->type("value_1", "250.00");
283 $this->type("label_2", "Non-member");
284 $this->type("value_2", "325.00");
285 $this->click("CIVICRM_QFID_2_6");
289 // enter early bird discount fees
290 $this->click("is_discount");
291 $this->waitForElementPresent("discount_name_1");
292 $this->type("discount_name_1", "Early-bird" . substr(sha1(rand()), 0, 7));
293 $this->webtestFillDate("discount_start_date_1", "-1 week");
294 $this->webtestFillDate("discount_end_date_1", "+2 week");
295 $this->clickLink("_qf_Fee_submit", "discounted_value_2_1");
296 $this->type("discounted_value_1_1","225.00");
297 $this->type("discounted_value_2_1","300.00");
298 $this->click("xpath=//fieldset[@id='discount']/fieldset/table/tbody/tr[2]/td[3]/input");
301 $this->click("_qf_Fee_upload-bottom");
303 // Wait for "saved" status msg
304 $this->waitForPageToLoad($this->getTimeoutMsec());
305 $this->waitForTextPresent("'Fee' information has been saved.");
308 function _testAddOnlineRegistration($registerIntro, $multipleRegistrations = FALSE) {
309 // Go to Online Registration tab
310 $this->click("link=Online Registration");
311 $this->waitForElementPresent("_qf_Registration_upload-bottom");
313 $this->check("is_online_registration");
314 $this->assertChecked("is_online_registration");
315 if ($multipleRegistrations) {
316 $this->check("is_multiple_registrations");
317 $this->assertChecked("is_multiple_registrations");
320 $this->fillRichTextField("intro_text", $registerIntro);
322 // enable confirmation email
323 $this->click("CIVICRM_QFID_1_is_email_confirm");
324 $this->type("confirm_from_name", "Jane Doe");
325 $this->type("confirm_from_email", "jane.doe@example.org");
327 $this->click("_qf_Registration_upload-bottom");
328 $this->waitForPageToLoad($this->getTimeoutMsec());
329 $this->waitForTextPresent("'Registration' information has been saved.");
332 function _AddEventToCart($eventTitle, $eventInfoStrings, $eventFees = NULL) {
333 // verify event input on info page
334 // start at Manage Events listing
335 $this->openCiviPage("event/manage", "reset=1");
336 $this->clickLink("link=$eventTitle", "link=Add to Cart");
337 $this->click("link=Add to Cart");
338 $this->waitForPageToLoad($this->getTimeoutMsec());
339 $this->assertTrue($this->isTextPresent("$eventTitle has been added to your cart"));
342 function _testVerifyEventInfo($eventTitle, $eventInfoStrings, $eventFees = NULL) {
343 // verify event input on info page
344 // start at Manage Events listing
345 $this->openCiviPage("event/manage", "reset=1");
346 $this->click("link=$eventTitle");
347 $this->waitForPageToLoad($this->getTimeoutMsec());
349 // Check for correct event info strings
350 $this->assertStringsPresent($eventInfoStrings);
352 // Optionally verify event fees (especially for discounts)
354 $this->assertStringsPresent($eventFees);
357 return $this->getLocation();
360 function _testOnlineRegistration($registerUrl, $numberRegistrations = 1, $anonymous = TRUE) {
362 $this->webtestLogout();
364 $this->open($registerUrl);
365 $this->waitForPageToLoad($this->getTimeoutMsec());
366 $this->waitForElementPresent("link=Add to Cart");
367 $this->click("link=Add to Cart");
368 $this->waitForPageToLoad($this->getTimeoutMsec());
371 function _testCheckOut(){
373 $this->click("xpath=//div[@id='messages']/div/div/a[text()='View your cart.']");
376 $this->waitForElementPresent("xpath=//a[@class='button crm-check-out-button']/span");
377 $this->click("xpath=//a[@class='button crm-check-out-button']/span");
378 $this->waitForPageToLoad($this->getTimeoutMsec());
380 $firstName = "AB".substr(sha1(rand()), 0, 7);
381 $lastName = "XY".substr(sha1(rand()), 0, 7);
382 for( $i = 1; $i <= 3; $i++
){
383 $this->type("xpath=//form[@id='ParticipantsAndPrices']/fieldset[$i]/div/fieldset/div/div/fieldset/div/div[2]/input","{$firstName}.{$lastName}@home.com");
384 $this->type("xpath=//form[@id='ParticipantsAndPrices']/fieldset[$i]/div/fieldset/div/div[2]/div[2]/input","{$firstName}.{$lastName}@example.com");
385 $this->click("xpath=//form[@id='ParticipantsAndPrices']/fieldset[$i]/div[2]/div[2]/input[2]");
387 $this->click("_qf_ParticipantsAndPrices_upload-bottom");
388 $this->waitForPageToLoad($this->getTimeoutMsec());
389 $this->select("credit_card_type", "value=Visa");
390 $this->type("credit_card_number", "4111111111111111");
391 $this->type("cvv2", "000");
392 $this->select("credit_card_exp_date[M]", "value=1");
393 $this->select("credit_card_exp_date[Y]", "value=2020");
394 $this->type("billing_first_name", $firstName);
395 $this->type("billing_last_name", $lastName);
396 $this->type("billing_street_address-5", "15 Main St.");
397 $this->type(" billing_city-5", "San Jose");
398 $this->select("billing_country_id-5", "value=1228");
399 $this->select("billing_state_province_id-5", "value=1004");
400 $this->type("billing_postal_code-5", "94129");
401 $this->type("billing_contact_email", "{$firstName}.{$lastName}@example.com");
403 $this->click("_qf_Payment_next-bottom");
404 $this->waitForPageToLoad($this->getTimeoutMsec());
406 $this->assertTrue($this->isTextPresent("This is your receipt of payment made for the following event registration."));
407 return array($firstName, $lastName);
410 function _checkContributionsandEventRegistration($firstName,$lastName,$events){
411 //Type the registered participant's email in autocomplete.
412 $this->click('sort_name_navigation');
413 $this->type('css=input#sort_name_navigation',"{$firstName}.{$lastName}@home.com" );
414 $this->typeKeys('css=input#sort_name_navigation', "{$firstName}.{$lastName}@home.com");
416 // Wait for result list.
417 $this->waitForElementPresent("css=div.ac_results-inner li");
419 // Visit contact summary page.
420 $this->click("css=div.ac_results-inner li");
421 $this->waitForPageToLoad($this->getTimeoutMsec());
423 //click on Events Tab
424 $this->click("xpath=//li[@id='tab_participant']/a");
425 //check if the participant is registered for all the three events
426 foreach($events as $key => $value){
427 $this->waitForElementPresent("link=$value");
428 $this->assertTrue($this->isElementPresent("link=$value"));
430 for( $i = 1; $i <= 3; $i++
){
431 $this->waitForElementPresent("xpath=//table[@class='selector']/tbody/tr[$i]/td[6][text()='Registered']");
432 $this->assertTrue($this->isElementPresent("xpath=//table[@class='selector']/tbody/tr[$i]/td[6][text()='Registered']"));
435 //Type the billing email in autocomplete.
436 $this->click('sort_name_navigation');
437 $this->type('css=input#sort_name_navigation',"{$firstName}.{$lastName}@example.com" );
438 $this->typeKeys('css=input#sort_name_navigation', "{$firstName}.{$lastName}@example.com");
440 // Wait for result list.
441 $this->waitForElementPresent("css=div.ac_results-inner li");
443 // Visit contact summary page.
444 $this->click("css=div.ac_results-inner li");
445 $this->waitForPageToLoad($this->getTimeoutMsec());
447 //click on Contributions Tab
448 $this->click("xpath=//li[@id='tab_contribute']/a");
449 //check for the three contributions
450 foreach($events as $key => $value){
451 $this->waitForElementPresent("xpath=//table[@class='selector']/tbody/tr/td[3][contains(text(),'$value')]");
452 $this->assertTrue($this->isElementPresent("xpath=//table[@class='selector']/tbody/tr/td[3][contains(text(),'$value')]"));
455 //Disable shopping cart style
456 $this->openCiviPage("admin/setting/preferences/event", "reset=1");
457 $this->click("enable_cart");
458 $this->click("_qf_Event_next-top");