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 +--------------------------------------------------------------------+
28 require_once 'CiviTest/CiviSeleniumTestCase.php';
29 class WebTest_Event_MultipleEventRegistrationbyCartTest
extends CiviSeleniumTestCase
{
31 protected function setUp() {
35 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
121 $this->_checkContributionsandEventRegistration($value[0],$value[1],$events);
124 function testAnonymousMultipleEvent(){
125 // This is the path where our testing install resides.
126 // The rest of URL is defined in CiviSeleniumTestCase base class, in
129 // Log in using webtestLogin() method
130 $this->webtestLogin();
132 // We need a payment processor
133 $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7);
134 $this->webtestAddPaymentProcessor($processorName);
138 $this->openCiviPage("event/add", "reset=1&action=add");
140 $eventTitle1 = 'My Conference1 - ' . substr(sha1(rand()), 0, 7);
141 $eventDescription1 = "Here is a description for this conference 1.";
142 $this->_testAddEventInfo($eventTitle1, $eventDescription1);
144 $streetAddress1 = "100 Main Street";
145 $this->_testAddLocation($streetAddress1);
147 $this->_testAddFees(FALSE, FALSE, $processorName);
149 // intro text for registration page
150 $registerIntro = "Fill in all the fields below and click Continue.";
151 $multipleRegistrations = TRUE;
152 $this->_testAddOnlineRegistration($registerIntro, $multipleRegistrations);
154 $eventInfoStrings1 = array($eventTitle1, $eventDescription1, $streetAddress1);
155 $registerUrl1 = $this->_testVerifyEventInfo($eventTitle1, $eventInfoStrings1);
159 $this->openCiviPage("event/add", "reset=1&action=add");
161 $eventTitle2 = 'My Conference2 - ' . substr(sha1(rand()), 0, 7);
162 $eventDescription2 = "Here is a description for this conference 2.";
163 $this->_testAddEventInfo($eventTitle2, $eventDescription2);
165 $streetAddress2 = "101 Main Street";
166 $this->_testAddLocation($streetAddress2);
168 $this->_testAddFees(FALSE, FALSE, $processorName);
170 // intro text for registration page
171 $registerIntro = "Fill in all the fields below and click Continue.";
172 $multipleRegistrations = TRUE;
173 $this->_testAddOnlineRegistration($registerIntro, $multipleRegistrations);
175 $eventInfoStrings2 = array($eventTitle2, $eventDescription2, $streetAddress2);
176 $registerUrl2 = $this->_testVerifyEventInfo($eventTitle2, $eventInfoStrings2);
180 $this->openCiviPage("event/add", "reset=1&action=add");
182 $eventTitle3 = 'My Conference3 - ' . substr(sha1(rand()), 0, 7);
183 $eventDescription3 = "Here is a description for this conference 3.";
184 $this->_testAddEventInfo($eventTitle3, $eventDescription3);
186 $streetAddress3 = "102 Main Street";
187 $this->_testAddLocation($streetAddress3);
189 $this->_testAddFees(FALSE, FALSE, $processorName);
191 // intro text for registration page
192 $registerIntro = "Fill in all the fields below and click Continue.";
193 $multipleRegistrations = TRUE;
194 $this->_testAddOnlineRegistration($registerIntro, $multipleRegistrations);
196 $eventInfoStrings3 = array($eventTitle3, $eventDescription3, $streetAddress3);
197 $registerUrl3 = $this->_testVerifyEventInfo($eventTitle3, $eventInfoStrings3);
199 //Enable shopping cart style
200 $this->openCiviPage("admin/setting/preferences/event", "reset=1");
201 $this->check("enable_cart");
202 $this->click("_qf_Event_next-top");
204 $numberRegistrations = 1;
206 $this->_testOnlineRegistration($registerUrl1, $numberRegistrations, $anonymous);
207 $this->_testOnlineRegistration($registerUrl2, $numberRegistrations, $anonymous);
208 $this->_testOnlineRegistration($registerUrl3, $numberRegistrations, $anonymous);
210 $value = $this->_testCheckOut();
211 // Log in using webtestLogin() method
212 $this->webtestLogin();
214 $this->openCiviPage("dashboard", "reset=1");
217 $events = array( 1 => $eventTitle1,
221 //check the existence of the contacts who were registered and the one who did the contribution
222 $this->_checkContributionsandEventRegistration($value[0],$value[1],$events);
225 function _testAddEventInfo($eventTitle, $eventDescription) {
226 $this->waitForElementPresent("_qf_EventInfo_upload-bottom");
228 $this->select("event_type_id", "value=1");
230 // Attendee role s/b selected now.
231 $this->select("default_role_id", "value=1");
233 // Enter Event Title, Summary and Description
234 $this->type("title", $eventTitle);
235 $this->type("summary", "This is a great conference. Sign up now!");
237 // Type description in ckEditor (fieldname, text to type, editor)
238 $this->fillRichTextField("description", $eventDescription, 'CKEditor');
240 // Choose Start and End dates.
241 // Using helper webtestFillDate function.
242 $this->webtestFillDateTime("start_date", "+1 week");
243 $this->webtestFillDateTime("end_date", "+1 week 1 day 8 hours ");
245 $this->type("max_participants", "50");
246 $this->click("is_map");
247 $this->click("_qf_EventInfo_upload-bottom");
250 function _testAddLocation($streetAddress) {
251 // Wait for Location tab form to load
252 $this->waitForPageToLoad($this->getTimeoutMsec());
253 $this->waitForElementPresent("_qf_Location_upload-bottom");
255 $this->type("address_1_street_address", $streetAddress);
256 $this->type("address_1_city", "San Francisco");
257 $this->type("address_1_postal_code", "94117");
258 $this->select("address_1_state_province_id", "value=1004");
259 $this->type("email_1_email", "info@civicrm.org");
261 $this->click("_qf_Location_upload-bottom");
263 // Wait for "saved" status msg
264 $this->waitForPageToLoad($this->getTimeoutMsec());
265 $this->waitForTextPresent("'Location' information has been saved.");
268 function _testAddFees($discount = FALSE, $priceSet = FALSE, $processorName = "PP Pro") {
270 $this->click("link=Fees");
271 $this->waitForElementPresent("_qf_Fee_upload-bottom");
272 $this->click("CIVICRM_QFID_1_is_monetary");
273 $this->click("xpath=//tr[@class='crm-event-manage-fee-form-block-payment_processor']/td[2]/label[text()='$processorName']");
274 $this->select('financial_type_id','Event Fee');
279 $this->type("label_1", "Member");
280 $this->type("value_1", "250.00");
281 $this->type("label_2", "Non-member");
282 $this->type("value_2", "325.00");
283 $this->click("CIVICRM_QFID_2_6");
287 // enter early bird discount fees
288 $this->click("is_discount");
289 $this->waitForElementPresent("discount_name_1");
290 $this->type("discount_name_1", "Early-bird" . substr(sha1(rand()), 0, 7));
291 $this->webtestFillDate("discount_start_date_1", "-1 week");
292 $this->webtestFillDate("discount_end_date_1", "+2 week");
293 $this->click("_qf_Fee_submit");
294 $this->waitForPageToLoad($this->getTimeoutMsec());
295 $this->waitForElementPresent("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->click("link=$eventTitle");
337 $this->waitForPageToLoad($this->getTimeoutMsec());
339 // Look for Add to Cart button
340 $this->waitForElementPresent("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);
360 return $this->getLocation();
363 function _testOnlineRegistration($registerUrl, $numberRegistrations = 1, $anonymous = TRUE) {
365 $this->webtestLogout();
367 $this->open($registerUrl);
368 $this->waitForPageToLoad($this->getTimeoutMsec());
369 $this->waitForElementPresent("link=Add to Cart");
370 $this->click("link=Add to Cart");
371 $this->waitForPageToLoad($this->getTimeoutMsec());
374 function _testCheckOut(){
376 $this->click("xpath=//div[@id='messages']/div/div/a[text()='View your cart.']");
379 $this->waitForElementPresent("xpath=//a[@class='button crm-check-out-button']/span");
380 $this->click("xpath=//a[@class='button crm-check-out-button']/span");
381 $this->waitForPageToLoad($this->getTimeoutMsec());
383 $firstName = "AB".substr(sha1(rand()), 0, 7);
384 $lastName = "XY".substr(sha1(rand()), 0, 7);
385 for( $i = 1; $i <= 3; $i++
){
386 $this->type("xpath=//form[@id='ParticipantsAndPrices']/fieldset[$i]/div/fieldset/div/div/fieldset/div/div[2]/input","{$firstName}.{$lastName}@home.com");
387 $this->type("xpath=//form[@id='ParticipantsAndPrices']/fieldset[$i]/div/fieldset/div/div[2]/div[2]/input","{$firstName}.{$lastName}@example.com");
388 $this->click("xpath=//form[@id='ParticipantsAndPrices']/fieldset[$i]/div[2]/div[2]/input[2]");
390 $this->click("_qf_ParticipantsAndPrices_upload-bottom");
391 $this->waitForPageToLoad($this->getTimeoutMsec());
392 $this->select("credit_card_type", "value=Visa");
393 $this->type("credit_card_number", "4111111111111111");
394 $this->type("cvv2", "000");
395 $this->select("credit_card_exp_date[M]", "value=1");
396 $this->select("credit_card_exp_date[Y]", "value=2020");
397 $this->type("billing_first_name", $firstName);
398 $this->type("billing_last_name", $lastName);
399 $this->type("billing_street_address-5", "15 Main St.");
400 $this->type(" billing_city-5", "San Jose");
401 $this->select("billing_country_id-5", "value=1228");
402 $this->select("billing_state_province_id-5", "value=1004");
403 $this->type("billing_postal_code-5", "94129");
404 $this->type("billing_contact_email", "{$firstName}.{$lastName}@example.com");
406 $this->click("_qf_Payment_next-bottom");
407 $this->waitForPageToLoad($this->getTimeoutMsec());
409 $this->assertTrue($this->isTextPresent("This is your receipt of payment made for the following event registration."));
410 return array($firstName, $lastName);
413 function _checkContributionsandEventRegistration($firstName,$lastName,$events){
414 //Type the registered participant's email in autocomplete.
415 $this->click('sort_name_navigation');
416 $this->type('css=input#sort_name_navigation',"{$firstName}.{$lastName}@home.com" );
417 $this->typeKeys('css=input#sort_name_navigation', "{$firstName}.{$lastName}@home.com");
419 // Wait for result list.
420 $this->waitForElementPresent("css=div.ac_results-inner li");
422 // Visit contact summary page.
423 $this->click("css=div.ac_results-inner li");
424 $this->waitForPageToLoad($this->getTimeoutMsec());
426 //click on Events Tab
427 $this->click("xpath=//li[@id='tab_participant']/a");
428 //check if the participant is registered for all the three events
429 foreach($events as $key => $value){
430 $this->waitForElementPresent("link=$value");
431 $this->assertTrue($this->isElementPresent("link=$value"));
433 for( $i = 1; $i <= 3; $i++
){
434 $this->waitForElementPresent("xpath=//table[@class='selector']/tbody/tr[$i]/td[6][text()='Registered']");
435 $this->assertTrue($this->isElementPresent("xpath=//table[@class='selector']/tbody/tr[$i]/td[6][text()='Registered']"));
438 //Type the billing email in autocomplete.
439 $this->click('sort_name_navigation');
440 $this->type('css=input#sort_name_navigation',"{$firstName}.{$lastName}@example.com" );
441 $this->typeKeys('css=input#sort_name_navigation', "{$firstName}.{$lastName}@example.com");
443 // Wait for result list.
444 $this->waitForElementPresent("css=div.ac_results-inner li");
446 // Visit contact summary page.
447 $this->click("css=div.ac_results-inner li");
448 $this->waitForPageToLoad($this->getTimeoutMsec());
450 //click on Contributions Tab
451 $this->click("xpath=//li[@id='tab_contribute']/a");
452 //check for the three contributions
453 foreach($events as $key => $value){
454 $this->waitForElementPresent("xpath=//table[@class='selector']/tbody/tr/td[3][contains(text(),'$value')]");
455 $this->assertTrue($this->isElementPresent("xpath=//table[@class='selector']/tbody/tr/td[3][contains(text(),'$value')]"));
458 //Disable shopping cart style
459 $this->openCiviPage("admin/setting/preferences/event", "reset=1");
460 $this->click("enable_cart");
461 $this->click("_qf_Event_next-top");