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_AddParticipationTest
extends CiviSeleniumTestCase
{
30 protected function setUp() {
34 function testEventParticipationAdd() {
35 // Log in using webtestLogin() method
36 $this->webtestLogin();
38 // Adding contact with randomized first name (so we can then select that contact when creating event registration)
39 // We're using Quick Add block on the main page for this.
40 $firstName = substr(sha1(rand()), 0, 7);
41 $this->webtestAddContact($firstName, 'Anderson', TRUE);
42 $contactName = "Anderson, $firstName";
43 $displayName = "$firstName Anderson";
45 $this->openCiviPage("participant/add", "reset=1&action=add&context=standalone", "_qf_Participant_upload-bottom");
47 // Type contact last name in contact auto-complete, wait for dropdown and click first result
48 $this->webtestFillAutocomplete($firstName);
50 // Select event. Based on label for now.
51 $this->select2('event_id', "Rain-forest Cup Youth Soccer Tournament");
54 $this->click('role_id[2]');
56 // Choose Registration Date.
57 // Using helper webtestFillDate function.
58 $this->webtestFillDate('register_date', 'now');
59 $today = date('F jS, Y', strtotime('now'));
62 // Select participant status
63 $this->select('status_id', 'value=1');
65 // Setting registration source
66 $this->type('source', 'Event StandaloneAddTest Webtest');
68 // Since we're here, let's check of screen help is being displayed properly
69 $this->assertTrue($this->isTextPresent('Source for this registration (if applicable).'));
71 // Select an event fee
72 $this->waitForElementPresent('priceset');
74 $this->click("xpath=//input[@class='form-radio']");
76 // Enter amount to be paid (note: this should default to selected fee level amount, s/b fixed during 3.2 cycle)
77 $this->type('total_amount', '800');
79 // Select payment method = Check and enter chk number
80 $this->select('payment_instrument_id', 'value=4');
81 $this->waitForElementPresent('check_number');
82 $this->type('check_number', '1044');
84 // go for the chicken combo (obviously)
85 // $this->click('CIVICRM_QFID_chicken_Chicken');
88 $this->click('_qf_Participant_upload-bottom');
89 $this->waitForPageToLoad($this->getTimeoutMsec());
91 // Is status message correct?
92 $this->waitForText('crm-notification-container', "Event registration for $displayName has been added");
94 $this->waitForElementPresent("xpath=//div[@id='Events']//table//tbody/tr[1]/td[8]/span/a[text()='View']");
95 //click through to the participant view screen
96 $this->click("xpath=//div[@id='Events']//table//tbody/tr[1]/td[8]/span/a[text()='View']");
97 $this->waitForElementPresent('_qf_ParticipantView_cancel-bottom');
99 $this->webtestVerifyTabularData(
101 'Event' => 'Rain-forest Cup Youth Soccer Tournament',
102 'Participant Role' => 'Attendee',
103 'Status' => 'Registered',
104 'Event Source' => 'Event StandaloneAddTest Webtest',
105 'Event Fees' => '$ 800.00',
108 // check contribution record as well
109 //click through to the contribution view screen
110 $this->click("xpath=id('ParticipantView')/div[2]/table[@class='selector']/tbody/tr[1]/td[8]/span/a[text()='View']");
111 $this->waitForElementPresent('_qf_ContributionView_cancel-bottom');
113 $this->webtestVerifyTabularData(
115 'From' => $displayName,
116 'Financial Type' => 'Event Fee',
117 'Total Amount' => '$ 800.00',
118 'Contribution Status' => 'Completed',
119 'Paid By' => 'Check',
120 'Check Number' => '1044',
125 function testEventParticipationAddWithMultipleRoles() {
127 // Log in using webtestLogin() method
128 $this->webtestLogin();
130 // Adding contact with randomized first name (so we can then select that contact when creating event registration)
131 // We're using Quick Add block on the main page for this.
132 $firstName = substr(sha1(rand()), 0, 7);
133 $this->webtestAddContact($firstName, 'Anderson', TRUE);
134 $contactName = "Anderson, $firstName";
135 $displayName = "$firstName Anderson";
137 // add custom data for participant role
138 $this->openCiviPage("admin/custom/group", "reset=1");
140 //add new custom data
141 $this->click("//a[@id='newCustomDataGroup']/span");
142 $this->waitForPageToLoad($this->getTimeoutMsec());
144 //fill custom group title
145 $customGroupTitle = 'custom_' . substr(sha1(rand()), 0, 7);
146 $this->click('title');
147 $this->type('title', $customGroupTitle);
149 //custom group extends
150 $this->click('extends[0]');
151 $this->select('extends[0]', 'value=ParticipantRole');
153 $this->click('extends[1][]');
154 $this->select('extends[1][]', 'value=2');
156 $this->click("//option[@value='Contact']");
157 $this->click('_qf_Group_next');
158 $this->waitForPageToLoad($this->getTimeoutMsec());
160 //Is custom group created?
161 $this->waitForText('crm-notification-container', "Your custom field set '$customGroupTitle' has been added. You can add custom fields now.");
163 //add custom field - alphanumeric checkbox
164 $checkboxFieldLabel = 'custom_field' . substr(sha1(rand()), 0, 4);
165 $this->click('label');
166 $this->type('label', $checkboxFieldLabel);
167 $this->click('data_type[1]');
168 $this->select('data_type[1]', 'value=CheckBox');
169 $this->click("//option[@value='CheckBox']");
170 $checkboxOptionLabel1 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
171 $this->type('option_label_1', $checkboxOptionLabel1);
172 $this->type('option_value_1', '1');
173 $checkboxOptionLabel2 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
174 $this->type('option_label_2', $checkboxOptionLabel2);
175 $this->type('option_value_2', '2');
176 $this->click('link=another choice');
177 $checkboxOptionLabel3 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
178 $this->type('option_label_3', $checkboxOptionLabel3);
179 $this->type('option_value_3', '3');
181 //enter options per line
182 $this->type('options_per_line', '2');
184 //enter pre help message
185 $this->type('help_pre', 'this is field pre help');
187 //enter post help message
188 $this->type('help_post', 'this field post help');
191 $this->click('is_searchable');
194 $this->click('_qf_Field_next');
195 $this->waitForPageToLoad($this->getTimeoutMsec());
197 //Is custom field created?
198 $this->waitForText('crm-notification-container', "Your custom field '$checkboxFieldLabel' has been saved.");
200 //create another custom field - Integer Radio
201 $this->click("//a[@id='newCustomField']/span");
202 $this->waitForPageToLoad($this->getTimeoutMsec());
203 $this->click('data_type[0]');
204 $this->select('data_type[0]', 'value=1');
205 $this->click("//option[@value='1']");
206 $this->click('data_type[1]');
207 $this->select('data_type[1]', 'value=Radio');
208 $this->click("//option[@value='Radio']");
210 $radioFieldLabel = 'custom_field' . substr(sha1(rand()), 0, 4);
211 $this->type('label', $radioFieldLabel);
212 $radioOptionLabel1 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
213 $this->type('option_label_1', $radioOptionLabel1);
214 $this->type('option_value_1', '1');
215 $radioOptionLabel2 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
216 $this->type('option_label_2', $radioOptionLabel2);
217 $this->type('option_value_2', '2');
218 $this->click('link=another choice');
219 $radioOptionLabel3 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
220 $this->type('option_label_3', $radioOptionLabel3);
221 $this->type('option_value_3', '3');
223 //select options per line
224 $this->type('options_per_line', '3');
227 $this->type('help_pre', 'this is field pre help');
229 //enter post help msg
230 $this->type('help_post', 'this is field post help');
233 $this->click('is_searchable');
236 $this->click('_qf_Field_next');
237 $this->waitForPageToLoad($this->getTimeoutMsec());
239 $this->openCiviPage("participant/add", "reset=1&action=add&context=standalone", "_qf_Participant_upload-bottom");
241 // Type contact last name in contact auto-complete, wait for dropdown and click first result
242 $this->webtestFillAutocomplete($firstName);
244 // Select event. Based on label for now.
245 $this->select2('event_id', "Rain-forest Cup Youth Soccer Tournament");
248 $this->click('role_id[2]');
249 $this->click('role_id[3]');
251 $this->waitForElementPresent("xpath=//div[@id='$customGroupTitle']//div");
252 $this->click("xpath=//div[@id='$customGroupTitle']//div[1]");
253 $this->click("xpath=//div[@id='$customGroupTitle']//div[2]//table//tbody//tr[2]//td[2]//table//tbody//tr[1]//td[1]//label");
254 $this->click("xpath=//div[@id='$customGroupTitle']//div[2]//table//tbody//tr[4]//td[2]//table//tbody//tr[1]//td[1]//label");
256 // Choose Registration Date.
257 // Using helper webtestFillDate function.
258 $this->webtestFillDate('register_date', 'now');
259 $today = date('F jS, Y', strtotime('now'));
262 // Select participant status
263 $this->select('status_id', 'value=1');
265 // Setting registration source
266 $this->type('source', 'Event StandaloneAddTest Webtest');
268 // Since we're here, let's check of screen help is being displayed properly
269 $this->assertTrue($this->isTextPresent('Source for this registration (if applicable).'));
271 // Select an event fee
272 $this->waitForElementPresent('priceset');
274 $this->click("xpath=//input[@class='form-radio']");
276 // Enter amount to be paid (note: this should default to selected fee level amount, s/b fixed during 3.2 cycle)
277 $this->type('total_amount', '800');
279 // Select payment method = Check and enter chk number
280 $this->select('payment_instrument_id', 'value=4');
281 $this->waitForElementPresent('check_number');
282 $this->type('check_number', '1044');
285 $this->click('_qf_Participant_upload-bottom');
286 $this->waitForPageToLoad($this->getTimeoutMsec());
288 // Is status message correct?
289 $this->waitForText('crm-notification-container', "Event registration for $displayName has been added");
291 $this->waitForElementPresent("xpath=//div[@id='Events']//table//tbody/tr[1]/td[8]/span/a[text()='View']");
292 //click through to the participant view screen
293 $this->click("xpath=//div[@id='Events']//table//tbody/tr[1]/td[8]/span/a[text()='View']");
294 $this->waitForElementPresent('_qf_ParticipantView_cancel-bottom');
296 $this->webtestVerifyTabularData(
298 'Event' => 'Rain-forest Cup Youth Soccer Tournament',
299 'Participant Role' => 'Attendee, Volunteer, Host',
300 'Status' => 'Registered',
301 'Event Source' => 'Event StandaloneAddTest Webtest',
302 'Event Fees' => '$ 800.00',
306 $this->assertTrue($this->isTextPresent("$customGroupTitle"));
307 $this->assertTrue($this->isTextPresent("$checkboxOptionLabel1"));
308 $this->assertTrue($this->isTextPresent("$radioOptionLabel1"));
310 // check contribution record as well
311 //click through to the contribution view screen
312 $this->click("xpath=id('ParticipantView')/div[2]/table[@class='selector']/tbody/tr[1]/td[8]/span/a[text()='View']");
313 $this->waitForElementPresent('_qf_ContributionView_cancel-bottom');
315 $this->webtestVerifyTabularData(
317 'From' => $displayName,
318 'Financial Type' => 'Event Fee',
319 'Total Amount' => '$ 800.00',
320 'Contribution Status' => 'Completed',
321 'Paid By' => 'Check',
322 'Check Number' => '1044',
327 function testEventAddMultipleParticipants() {
329 // Log in using webtestLogin() method
330 $this->webtestLogin();
332 $processorId = $this->webtestAddPaymentProcessor('dummy' . substr(sha1(rand()), 0, 7));
333 $rand = substr(sha1(rand()), 0, 7);
334 $firstName = 'First' . $rand;
335 $lastName = 'Last' . $rand;
336 $rand = substr(sha1(rand()), 0, 7);
337 $lastName2 = 'Last' . $rand;
339 $this->openCiviPage("participant/add", "reset=1&action=add&context=standalone&mode=test&eid=3");
341 $this->assertTrue($this->isTextPresent("Register New Participant"), "Page title 'Register New Participant' missing");
342 $this->assertTrue($this->isTextPresent("A TEST transaction will be submitted"), "test mode status 'A TEST transaction will be submitted' missing");
343 $this->_fillParticipantDetails($firstName, $lastName, $processorId);
344 $this->click('_qf_Participant_upload_new-bottom');
345 $this->waitForPageToLoad($this->getTimeoutMsec());
347 $this->assertTrue($this->isTextPresent("Register New Participant"), "Page title 'Register New Participant' missing");
348 $this->assertTrue($this->isTextPresent("A TEST transaction will be submitted"), "test mode status 'A TEST transaction will be submitted' missing");
349 $this->_fillParticipantDetails($firstName, $lastName2, $processorId);
350 $this->click('_qf_Participant_upload_new-bottom');
351 $this->waitForPageToLoad($this->getTimeoutMsec());
353 //searching the paricipants
354 $this->openCiviPage("event/search", "reset=1");
355 $this->type('sort_name', $firstName);
356 $eventName = "Rain-forest Cup Youth Soccer Tournament";
357 $this->type("event_name", $eventName);
358 $this->click("event_name");
359 $this->waitForElementPresent("css=div.ac_results-inner li");
360 $this->click("css=div.ac_results-inner li");
361 $this->check('participant_test');
362 $this->click("_qf_Search_refresh");
363 $this->waitForElementPresent("participantSearch");
365 //verifying the registered participants
366 $names = array( "{$lastName}, {$firstName}", "{$lastName2}, {$firstName}" );
367 $status = "Registered (test)";
369 foreach($names as $name) {
370 $this->verifyText("xpath=//div[@id='participantSearch']//table//tbody//tr/td[@class='crm-participant-sort_name']/a[text()='{$name}']/../../td[9]", preg_quote($status));
371 $this->verifyText("xpath=//div[@id='participantSearch']//table//tbody//tr/td[@class='crm-participant-sort_name']/a[text()='{$name}']/../../td[4]/a", preg_quote($eventName));
375 function testAjaxCustomGroupLoad() {
376 $this->webtestLogin();
379 array('entity' => 'ParticipantEventName', 'subEntity' => 'Fall Fundraiser Dinner',
380 'triggerElement' => array('name' => "event_id", 'type' => "select")),
381 array('entity' => 'ParticipantRole', 'subEntity' => 'Attendee','triggerElement' => array('type' => "checkbox"))
383 $pageUrl = array('url' => "participant/add", 'args' => "reset=1&action=add&context=standalone");
384 $this->customFieldSetLoadOnTheFlyCheck($customSets, $pageUrl);
388 * Webtest for CRM-10983
391 function testCheckDuplicateCustomDataLoad() {
392 $this->webtestLogin();
395 array('entity' => 'ParticipantEventType', 'subEntity' => '- Any -',
396 'triggerElement' => array('name' => "event_id", 'type' => "select")),
397 array('entity' => 'ParticipantEventName', 'subEntity' => '- Any -',
398 'triggerElement' => array('name' => "event_id", 'type' => "select")),
399 array('entity' => 'ParticipantEventName', 'subEntity' => 'Rain-forest Cup Youth Soccer Tournament',
400 'triggerElement' => array('name' => "event_id", 'type' => "select")),
401 array('entity' => 'ParticipantRole', 'subEntity' => '- Any -','triggerElement' => array('type' => "checkbox")),
402 array('entity' => 'ParticipantRole', 'subEntity' => 'Volunteer','triggerElement' => array('type' => "checkbox"))
405 $return = $this->addCustomGroupField($customSets);
407 $this->openCiviPage("participant/add", "reset=1&action=add&context=standalone", "_qf_Participant_upload-bottom");
410 $this->select2('event_id', "Rain-forest Cup Youth Soccer Tournament");
413 $this->click('role_id[2]');
415 foreach($return as $values) {
416 foreach ($values as $entityType => $customData) {
417 //checking for duplicate custom data present or not
418 $this->assertElementPresent("xpath=//div[@id='{$customData['cgtitle']}'][@class='crm-accordion-wrapper ']");
419 $this->assertEquals(1, $this->getXpathCount("//div[@id='{$customData['cgtitle']}'][@class='crm-accordion-wrapper ']"));
424 function _fillParticipantDetails($firstName, $lastName, $processorId) {
425 $this->select("id=profiles_1", "label=New Individual");
426 $this->waitForElementPresent('_qf_Edit_next');
428 $this->type("id=first_name", $firstName);
429 $this->type("id=last_name", $lastName);
430 $this->click("id=_qf_Edit_next");
431 $this->select('payment_processor_id', "value={$processorId}");
432 $this->verifySelectedValue("event_id", "3");
433 $this->check("role_id[1]");
434 $this->webtestAddCreditCardDetails();
435 $this->webtestAddBillingDetails();