Merge pull request #7271 from jitendrapurohit/CRM-17613
[civicrm-core.git] / tests / phpunit / WebTest / Event / AddEventTest.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
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. |
13 | |
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. |
18 | |
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 +--------------------------------------------------------------------+
25 */
26
27 require_once 'CiviTest/CiviSeleniumTestCase.php';
28
29 /**
30 * Class WebTest_Event_AddEventTest
31 */
32 class WebTest_Event_AddEventTest extends CiviSeleniumTestCase {
33
34 protected function setUp() {
35 parent::setUp();
36 }
37
38 public function testAddPaidEventNoTemplate() {
39 // Log in using webtestLogin() method
40 $this->webtestLogin();
41
42 // Use default payment processor
43 $processorName = 'Test Processor';
44 $this->webtestAddPaymentProcessor($processorName);
45
46 $this->openCiviPage("event/add", "reset=1&action=add");
47
48 $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7);
49 $eventDescription = "Here is a description for this conference.";
50 $this->_testAddEventInfo($eventTitle, $eventDescription);
51
52 $streetAddress = "100 Main Street";
53 $this->_testAddLocation($streetAddress);
54
55 $this->_testAddReminder($eventTitle);
56
57 $this->_testAddFees(FALSE, FALSE, $processorName);
58
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);
63
64 $eventInfoStrings = array($eventTitle, $eventDescription, $streetAddress);
65 $eventId = $this->_testVerifyEventInfo($eventTitle, $eventInfoStrings);
66
67 $registerStrings = array("225.00", "Member", "300.00", "Non-member", $registerIntro);
68 $registerUrl = $this->_testVerifyRegisterPage($registerStrings);
69
70 $numberRegistrations = 3;
71 $anonymous = TRUE;
72 $this->_testOnlineRegistration($registerUrl, $numberRegistrations, $anonymous);
73
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);
79 }
80
81 public function testAddPaidEventDiscount() {
82
83 // Log in using webtestLogin() method
84 $this->webtestLogin();
85
86 // Use default payment processor
87 $processorName = 'Test Processor';
88 $this->webtestAddPaymentProcessor($processorName);
89
90 $this->openCiviPage("event/add", "reset=1&action=add");
91
92 $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7);
93 $eventDescription = "Here is a description for this conference.";
94 $this->_testAddEventInfo($eventTitle, $eventDescription);
95
96 $streetAddress = "100 Main Street";
97 $this->_testAddLocation($streetAddress);
98
99 $this->_testAddReminder($eventTitle);
100
101 $this->_testAddFees(TRUE, FALSE, $processorName);
102
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);
107
108 $discountFees = array("225.00", "300.00");
109
110 $eventInfoStrings = array($eventTitle, $eventDescription, $streetAddress);
111 $this->_testVerifyEventInfo($eventTitle, $eventInfoStrings, $discountFees);
112
113 $registerStrings = array_push($discountFees, "Member", "Non-member", $registerIntro);
114 $registerUrl = $this->_testVerifyRegisterPage($registerStrings);
115
116 $numberRegistrations = 3;
117 $anonymous = TRUE;
118 $this->_testOnlineRegistration($registerUrl, $numberRegistrations, $anonymous);
119 }
120
121 public function testDeletePriceSetDiscount() {
122
123 // Log in using webtestLogin() method
124 $this->webtestLogin();
125
126 // Use default payment processor
127 $processorName = 'Test Processor';
128 $this->webtestAddPaymentProcessor($processorName);
129
130 $this->openCiviPage("event/add", "reset=1&action=add");
131
132 $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7);
133 $eventDescription = "Here is a description for this conference.";
134 $this->_testAddEventInfo($eventTitle, $eventDescription);
135
136 $streetAddress = "100 Main Street";
137 $this->_testAddLocation($streetAddress);
138
139 //Add two discounts
140 $discount = $this->_testAddFees(TRUE, FALSE, $processorName, TRUE);
141
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);
146
147 $discountFees = array("225.00", "300.00");
148
149 $eventInfoStrings = array($eventTitle, $eventDescription, $streetAddress);
150 $id = $this->_testVerifyEventInfo($eventTitle, $eventInfoStrings, $discountFees);
151
152 $registerStrings = array_push($discountFees, "Member", "Non-member", $registerIntro);
153 $registerUrl = $this->_testVerifyRegisterPage($registerStrings);
154
155 //Add Price Set now
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']");
160
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);
165 }
166 }
167
168 public function testAddDeleteEventDiscount() {
169
170 // Log in using webtestLogin() method
171 $this->webtestLogin();
172
173 // Use default payment processor
174 $processorName = 'Test Processor';
175 $this->webtestAddPaymentProcessor($processorName);
176
177 $this->openCiviPage("event/add", "reset=1&action=add");
178
179 $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7);
180 $eventDescription = "Here is a description for this conference.";
181 $this->_testAddEventInfo($eventTitle, $eventDescription);
182
183 $streetAddress = "100 Main Street";
184 $this->_testAddLocation($streetAddress);
185
186 //Add two discounts
187 $discount = $this->_testAddFees(TRUE, FALSE, $processorName, TRUE);
188
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);
193
194 $discountFees = array("225.00", "300.00");
195
196 $eventInfoStrings = array($eventTitle, $eventDescription, $streetAddress);
197 $id = $this->_testVerifyEventInfo($eventTitle, $eventInfoStrings, $discountFees);
198
199 $registerStrings = array_push($discountFees, "Member", "Non-member", $registerIntro);
200 $registerUrl = $this->_testVerifyRegisterPage($registerStrings);
201 //Delete the discount
202 $this->_deleteDiscount($id, $eventTitle, $discount);
203 }
204
205 /**
206 * @param int $id
207 * @param $eventTitle
208 * @param $discount
209 */
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.");
219 //Assertions
220 $this->openCiviPage("admin/price", "reset=1");
221 $this->assertStringsPresent($discount[1]);
222 }
223
224 public function testAddPaidEventWithTemplate() {
225
226 // Log in using webtestLogin() method
227 $this->webtestLogin();
228
229 // Use default payment processor
230 $processorName = 'Test Processor';
231 $this->webtestAddPaymentProcessor($processorName);
232
233 $this->openCiviPage("event/add", "reset=1&action=add");
234
235 $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7);
236 $eventDescription = "Here is a description for this conference.";
237 // Select paid online registration template.
238 $templateID = 6;
239 $eventTypeID = 1;
240 $this->_testAddEventInfoFromTemplate($eventTitle, $eventDescription, $templateID, $eventTypeID);
241
242 $streetAddress = "100 Main Street";
243 $this->_testAddLocation($streetAddress);
244
245 $this->_testAddFees(FALSE, FALSE, $processorName);
246
247 // intro text for registration page
248 $registerIntro = "Fill in all the fields below and click Continue.";
249 $this->_testAddOnlineRegistration($registerIntro);
250
251 // $eventInfoStrings = array( $eventTitle, $eventDescription, $streetAddress );
252 $eventInfoStrings = array($eventTitle, $streetAddress);
253 $this->_testVerifyEventInfo($eventTitle, $eventInfoStrings);
254
255 $registerStrings = array("225.00", "Member", "300.00", "Non-member", $registerIntro);
256 $this->_testVerifyRegisterPage($registerStrings);
257 }
258
259 public function testAddFreeEventWithTemplate() {
260
261 // Log in using webtestLogin() method
262 $this->webtestLogin();
263
264 $this->openCiviPage("event/add", "reset=1&action=add");
265
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).
269 $templateID = 5;
270 $eventTypeID = 4;
271
272 $this->_testAddEventInfoFromTemplate($eventTitle, $eventDescription, $templateID, $eventTypeID);
273
274 $streetAddress = "100 Main Street";
275
276 $this->_testAddLocation($streetAddress);
277
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");
282
283 // intro text for registration page
284 $registerIntro = "Fill in all the fields below and click Continue.";
285 $this->_testAddOnlineRegistration($registerIntro);
286
287 // $eventInfoStrings = array( $eventTitle, $eventDescription, $streetAddress );
288 $eventInfoStrings = array($eventTitle, $streetAddress);
289 $this->_testVerifyEventInfo($eventTitle, $eventInfoStrings);
290
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");
295 }
296
297 public function testUnpaidPaid() {
298 $this->markTestSkipped('Skipping for now as it works fine locally.');
299 // Log in using webtestLogin() method
300 $this->webtestLogin();
301
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);
306
307 //add fee section with pay later checked
308 $this->_testAddFees(FALSE, FALSE, NULL, FALSE, TRUE);
309
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");
314
315 $this->click("_qf_Fee_upload-bottom");
316 $this->waitForText('crm-notification-container', "'Fees' information has been saved.");
317 $this->waitForAjaxContent();
318
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');
324 }
325
326 public function testAjaxCustomGroupLoad() {
327 $this->webtestLogin();
328
329 $triggerElement = array('name' => 'event_type_id', 'type' => 'select');
330 $customSets = array(
331 array('entity' => 'Event', 'subEntity' => 'Conference', 'triggerElement' => $triggerElement),
332 );
333
334 $pageUrl = array('url' => 'event/add', 'args' => "reset=1&action=add");
335 $this->customFieldSetLoadOnTheFlyCheck($customSets, $pageUrl);
336 }
337
338 /**
339 * @param $eventTitle
340 * @param $eventDescription
341 */
342 public function _testAddEventInfo($eventTitle, $eventDescription) {
343 $this->waitForElementPresent("_qf_EventInfo_upload-bottom");
344
345 $this->select("event_type_id", "value=1");
346
347 // Attendee role s/b selected now.
348 $this->select("default_role_id", "value=1");
349
350 // Enter Event Title, Summary and Description
351 $this->type("title", $eventTitle);
352 $this->type("summary", "This is a great conference. Sign up now!");
353
354 // Type description in ckEditor (fieldname, text to type, editor)
355 $this->fillRichTextField("description", $eventDescription, 'CKEditor');
356
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 ");
361
362 $this->type("max_participants", "50");
363 $this->click("is_map");
364 $this->click("is_public");
365 $this->clickLink("_qf_EventInfo_upload-bottom");
366 }
367
368 /**
369 * @param $eventTitle
370 * @param $eventDescription
371 * @param int $templateID
372 * @param int $eventTypeID
373 */
374 public function _testAddEventInfoFromTemplate($eventTitle, $eventDescription, $templateID, $eventTypeID) {
375 $this->waitForElementPresent("_qf_EventInfo_upload-bottom");
376
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}");
379
380 // Wait for event type to be filled in (since page refreshes)
381 $this->waitForAjaxContent();
382 $this->verifySelectedValue("event_type_id", $eventTypeID);
383
384 // Attendee role s/b selected now.
385 $this->verifySelectedValue("default_role_id", "1");
386
387 // Enter Event Title, Summary and Description
388 $this->type("title", $eventTitle);
389
390 $this->type("summary", "This is a great conference. Sign up now!");
391
392 // Type description in ckEditor (fieldname, text to type, editor)
393 $this->fillRichTextField("description", $eventDescription, 'CKEditor');
394
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 ");
399
400 $this->type("max_participants", "50");
401 $this->click("is_map");
402 $this->clickLink("_qf_EventInfo_upload-bottom");
403 }
404
405 /**
406 * @param $streetAddress
407 */
408 public function _testAddLocation($streetAddress) {
409 // Wait for Location tab form to load
410 $this->waitForAjaxContent();
411 $this->waitForElementPresent("_qf_Location_upload-bottom");
412
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");
421
422 $this->click("_qf_Location_upload-bottom");
423
424 // Wait for "saved" status msg
425 $this->waitForText('crm-notification-container', "'Event Location' information has been saved.");
426 }
427
428 /**
429 * @param bool $discount
430 * @param bool $priceSet
431 * @param string $processorName
432 * @param bool $double
433 * @param bool $payLater
434 *
435 * @return array
436 */
437 public function _testAddFees($discount = FALSE, $priceSet = FALSE, $processorName = "PP Pro", $double = FALSE, $payLater = FALSE) {
438 $discount1 = "Early-bird" . substr(sha1(rand()), 0, 7);
439 $discount2 = "";
440 // Go to Fees tab
441 $this->click("link=Fees");
442 $this->waitForElementPresent("_qf_Fee_upload-bottom");
443 $this->click("CIVICRM_QFID_1_is_monetary");
444
445 if ($payLater) {
446 $this->click('is_pay_later');
447 $this->fillRichTextField('pay_later_receipt', 'testing later instructions');
448 }
449 else {
450 $this->uncheck('is_pay_later');
451 }
452
453 if ($processorName) {
454 $this->select2('payment_processor', $processorName, TRUE);
455 }
456 $this->select("financial_type_id", "value=4");
457 if ($priceSet) {
458 // get one - TBD
459 }
460 else {
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");
466 }
467
468 if ($discount) {
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");
476
477 $this->type("discounted_value_1_1", "225.00");
478 $this->type("discounted_value_2_1", "300.00");
479
480 if ($double) {
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");
491 }
492 $this->click("xpath=//fieldset[@id='discount']/fieldset/table/tbody/tr[2]/td[3]/input");
493 }
494 $this->click("_qf_Fee_upload-bottom");
495
496 // Wait for "saved" status msg
497 $this->waitForText('crm-notification-container', "'Fees' information has been saved");
498 return array($discount1, $discount2);
499 }
500
501 /**
502 * @param $registerIntro
503 * @param bool $multipleRegistrations
504 */
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");
509
510 $isChecked = $this->isChecked('is_online_registration');
511 if (!$isChecked) {
512 $this->click("is_online_registration");
513 }
514 $this->assertChecked("is_online_registration");
515 if ($multipleRegistrations) {
516 $isChecked = $this->isChecked('is_multiple_registrations');
517 if (!$isChecked) {
518 $this->click("is_multiple_registrations");
519 }
520 $this->assertChecked("is_multiple_registrations");
521 }
522
523 $this->fillRichTextField("intro_text", $registerIntro, 'CKEditor', TRUE);
524
525 // enable confirmation email
526 $this->click("CIVICRM_QFID_1_is_email_confirm");
527 $this->type("confirm_from_name", "Jane Doe");
528
529 $this->type("confirm_from_email", "jane.doe@example.org");
530
531 $this->click("_qf_Registration_upload-bottom");
532 $this->waitForText('crm-notification-container', "'Online Registration' information has been saved.");
533 }
534
535 /**
536 * @param $eventTitle
537 * @param $eventInfoStrings
538 * @param null $eventFees
539 *
540 * @return null
541 */
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");
547
548 // Look for Register button
549 $this->waitForElementPresent("link=Register Now");
550
551 // Check for correct event info strings
552 $this->assertStringsPresent($eventInfoStrings);
553
554 // Optionally verify event fees (especially for discounts)
555 if ($eventFees) {
556 $this->assertStringsPresent($eventFees);
557
558 }
559 return $this->urlArg('id');
560 }
561
562 /**
563 * @param $registerStrings
564 *
565 * @return string
566 */
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();
573 }
574
575 /**
576 * @param $registerUrl
577 * @param int $numberRegistrations
578 * @param bool $anonymous
579 * @param bool $isPayLater
580 * @param array $participantEmailInfo
581 * @param null $paymentProcessor
582 *
583 * @return array
584 */
585 public function _testOnlineRegistration($registerUrl, $numberRegistrations = 1, $anonymous = TRUE, $isPayLater = FALSE, $participantEmailInfo = array(), $paymentProcessor = NULL) {
586 $infoPassed = FALSE;
587 if (!empty($participantEmailInfo)) {
588 $infoPassed = TRUE;
589 }
590 if ($anonymous) {
591 $this->webtestLogout();
592 }
593 $primaryParticipantInfo = array();
594 $this->open($registerUrl);
595 $this->waitForPageToLoad($this->getTimeoutMsec());
596
597 $this->waitForElementPresent('additional_participants');
598
599 $this->select("additional_participants", "value=" . $numberRegistrations);
600
601 if ($infoPassed) {
602 $primaryParticipantInfo['first_name'] = $participantEmailInfo[0]['first_name'];
603 $primaryParticipantInfo['last_name'] = $participantEmailInfo[0]['last_name'];
604 $primaryParticipantInfo['email'] = $participantEmailInfo[0]['email'];
605 }
606 else {
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";
610 }
611
612 $this->type("first_name", $primaryParticipantInfo['first_name']);
613 $this->type("last_name", $primaryParticipantInfo['last_name']);
614 $this->type("email-Primary", $primaryParticipantInfo['email']);
615
616 if (!$isPayLater) {
617 if ($paymentProcessor) {
618 $paymentProcessorEle = $this->getAttribute("xpath=//form[@id='Register']//label[contains(text(), '{$paymentProcessor}')]/@for");
619 $this->click($paymentProcessorEle);
620 }
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");
633 }
634
635 $this->click("_qf_Register_upload-bottom");
636
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");
642
643 if ($infoPassed) {
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']);
647 }
648 else {
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");
652 }
653
654 $this->click("_qf_Participant_{$i}_next");
655 }
656 }
657
658 $this->waitForPageToLoad($this->getTimeoutMsec());
659 $this->waitForElementPresent("_qf_Confirm_next-bottom");
660 $confirmStrings = array("Event Fee(s)");
661 if (!$isPayLater) {
662 $confirmStrings += array("Billing Name and Address", "Credit Card Information");
663 }
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");
668 if (!$isPayLater) {
669 $thankStrings = array("Transaction Date");
670 }
671 else {
672 $thankStrings += array("testing later instructions");
673 }
674 $this->assertStringsPresent($thankStrings);
675 return $primaryParticipantInfo;
676 }
677
678 /**
679 * @param $eventTitle
680 */
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');
689
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' );
698
699 // Fill Subject
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');
703
704 $this->type("text_message", "This is the test text version here!!!");
705 //click on save
706 $this->click('_qf_ScheduleReminders_next-bottom');
707 $this->waitForElementPresent("link=Add Reminder");
708
709 $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[7]/span/a[1]");
710
711 $verifyText = array(
712 1 => 'Event Reminder for ' . $eventTitle,
713 3 => '1 hour after Event Start Date',
714 4 => 'Registered',
715 5 => 'Yes',
716 6 => 'Yes',
717 );
718
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);
723 }
724 }
725
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");
731
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);
737
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);
744
745 $registerStrings = array("225.00", "Member", "300.00", "Non-member", $registerIntro);
746 $registerUrl = $this->_testVerifyRegisterPage($registerStrings);
747 $numberRegistrations = 3;
748 $anonymous = TRUE;
749
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),
755 );
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),
760 );
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),
765 );
766
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'));
780
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');
786 $this->assertTrue(
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');
789 $this->assertTrue(
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'
794 );
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");
798 }
799
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.");
804
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();
808
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']");
814
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);
832
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();
836
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);
853 }
854
855 /**
856 * @param int $contributionID
857 */
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);
866 $dao->fetch();
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);
873 $dao->fetch();
874 $this->assertEquals('2', $dao->civicrm_financial_trxn, 'civicrm_financial_trxn count does not match');
875 }
876
877 public function testEventApprovalRegistration() {
878 $this->webtestLogin();
879
880 //Participant Status
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']");
886 }
887
888 //Create New Event
889
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');
895
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!');
901
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');
907
908 // Wait for Location tab form to load
909 $this->waitForPageToLoad($this->getTimeoutMsec());
910
911 // Go to Fees tab
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);
918
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.");
927
928 // intro text for registration page
929 $registerIntro = 'Fill in all the fields below and click Continue.';
930
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');
936
937 //Requires Approvel
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.");
942
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);
954
955 //fill in last name
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");
966
967 }
968
969 /**
970 * Test enabling participant statuses.
971 *
972 * @param int $statusId
973 */
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']");
979 }
980 }
981
982 /**
983 * CRM-16777: Allow to add schedule reminder for event with 'edit all event' permission
984 */
985 public function testConfigureScheduleReminder() {
986 // Log in using webtestLogin() method
987 $this->webtestLogin('admin');
988
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';
993
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",
1007 );
1008 $this->changePermissions($permissions);
1009
1010 //Create TestUser1
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());
1028
1029 //Add event
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);
1034
1035 //Logging out
1036 $this->webtestLogout();
1037
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();
1046
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';
1051
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",
1065 );
1066 $this->changePermissions($permissions);
1067
1068 //Create TestUser2
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());
1086
1087 //Logout
1088 $this->webtestLogout();
1089
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();
1096 }
1097
1098 }