3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
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';
30 * Class WebTest_Event_AddParticipationTest
32 class WebTest_Event_AddParticipationTest
extends CiviSeleniumTestCase
{
34 protected function setUp() {
38 function testEventParticipationAdd() {
39 // Log in using webtestLogin() method
40 $this->webtestLogin();
42 // Adding contact with randomized first name (so we can then select that contact when creating event registration)
43 // We're using Quick Add block on the main page for this.
44 $firstName = substr(sha1(rand()), 0, 7);
45 $this->webtestAddContact($firstName, 'Anderson', TRUE);
46 $contactName = "Anderson, $firstName";
47 $displayName = "$firstName Anderson";
49 $this->openCiviPage("participant/add", "reset=1&action=add&context=standalone", "_qf_Participant_upload-bottom");
51 // Type contact last name in contact auto-complete, wait for dropdown and click first result
52 $this->webtestFillAutocomplete($firstName);
54 // Select event. Based on label for now.
55 $this->select2('event_id', "Rain-forest Cup Youth Soccer Tournament");
58 $this->multiselect2('role_id', array('Volunteer'));
60 // Choose Registration Date.
61 // Using helper webtestFillDate function.
62 $this->webtestFillDate('register_date', 'now');
63 $today = date('F jS, Y', strtotime('now'));
66 // Select participant status
67 $this->select('status_id', 'value=1');
69 // Setting registration source
70 $this->type('source', 'Event StandaloneAddTest Webtest');
72 // Since we're here, let's check of screen help is being displayed properly
73 $this->assertTrue($this->isTextPresent('Source for this registration (if applicable).'));
75 // Select an event fee
76 $this->waitForElementPresent('priceset');
78 $this->click("xpath=//input[@class='crm-form-radio']");
80 // Enter amount to be paid (note: this should default to selected fee level amount, s/b fixed during 3.2 cycle)
81 $this->type('total_amount', '800');
83 // Select payment method = Check and enter chk number
84 $this->select('payment_instrument_id', 'value=4');
85 $this->waitForElementPresent('check_number');
86 $this->type('check_number', '1044');
88 // go for the chicken combo (obviously)
89 // $this->click('CIVICRM_QFID_chicken_Chicken');
92 $this->click('_qf_Participant_upload-bottom');
93 $this->waitForPageToLoad($this->getTimeoutMsec());
95 // Is status message correct?
96 $this->waitForText('crm-notification-container', "Event registration for $displayName has been added");
98 $this->waitForElementPresent("xpath=//*[@id='Search']//table/tbody/tr[1]/td[8]/span/a[text()='View']");
99 //click through to the participant view screen
100 $this->click("xpath=//*[@id='Search']//table/tbody/tr[1]/td[8]/span/a[text()='View']");
101 $this->waitForElementPresent('_qf_ParticipantView_cancel-bottom');
103 $this->webtestVerifyTabularData(
105 'Event' => 'Rain-forest Cup Youth Soccer Tournament',
106 'Participant Role' => 'Attendee',
107 'Status' => 'Registered',
108 'Event Source' => 'Event StandaloneAddTest Webtest',
109 'Fees' => '$ 800.00',
112 // check contribution record as well
113 //click through to the contribution view screen
114 $this->click("xpath=id('ParticipantView')/div[2]/table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='View']");
115 $this->waitForElementPresent('_qf_ContributionView_cancel-bottom');
117 $this->webtestVerifyTabularData(
119 'From' => $displayName,
120 'Financial Type' => 'Event Fee',
121 'Total Amount' => '$ 800.00',
122 'Contribution Status' => 'Completed',
123 'Paid By' => 'Check',
124 'Check Number' => '1044',
129 function testEventParticipationAddWithMultipleRoles() {
131 // Log in using webtestLogin() method
132 $this->webtestLogin();
134 // Adding contact with randomized first name (so we can then select that contact when creating event registration)
135 // We're using Quick Add block on the main page for this.
136 $firstName = substr(sha1(rand()), 0, 7);
137 $this->webtestAddContact($firstName, 'Anderson', TRUE);
138 $contactName = "Anderson, $firstName";
139 $displayName = "$firstName Anderson";
141 // add custom data for participant role
142 $this->openCiviPage("admin/custom/group", "reset=1");
144 //add new custom data
145 $this->click("//a[@id='newCustomDataGroup']/span");
146 $this->waitForPageToLoad($this->getTimeoutMsec());
148 //fill custom group title
149 $customGroupTitle = 'custom_' . substr(sha1(rand()), 0, 7);
150 $this->click('title');
151 $this->type('title', $customGroupTitle);
153 //custom group extends
154 $this->click('extends[0]');
155 $this->select('extends[0]', 'value=ParticipantRole');
157 $this->click('extends[1][]');
158 $this->select('extends[1][]', 'value=2');
160 $this->click("//option[@value='Contact']");
161 $this->click('_qf_Group_next');
162 $this->waitForPageToLoad($this->getTimeoutMsec());
164 //Is custom group created?
165 $this->waitForText('crm-notification-container', "Your custom field set '$customGroupTitle' has been added. You can add custom fields now.");
167 //add custom field - alphanumeric checkbox
168 $checkboxFieldLabel = 'custom_field' . substr(sha1(rand()), 0, 4);
169 $this->click('label');
170 $this->type('label', $checkboxFieldLabel);
171 $this->click('data_type[1]');
172 $this->select('data_type[1]', 'value=CheckBox');
173 $this->click("//option[@value='CheckBox']");
174 $checkboxOptionLabel1 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
175 $this->type('option_label_1', $checkboxOptionLabel1);
176 $this->type('option_value_1', '1');
177 $checkboxOptionLabel2 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
178 $this->type('option_label_2', $checkboxOptionLabel2);
179 $this->type('option_value_2', '2');
180 $this->click('link=another choice');
181 $checkboxOptionLabel3 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
182 $this->type('option_label_3', $checkboxOptionLabel3);
183 $this->type('option_value_3', '3');
185 //enter options per line
186 $this->type('options_per_line', '2');
188 //enter pre help message
189 $this->type('help_pre', 'this is field pre help');
191 //enter post help message
192 $this->type('help_post', 'this field post help');
195 $this->click('is_searchable');
198 $this->click('_qf_Field_next');
199 $this->waitForPageToLoad($this->getTimeoutMsec());
201 //Is custom field created?
202 $this->waitForText('crm-notification-container', "Custom field '$checkboxFieldLabel' has been saved.");
204 //create another custom field - Integer Radio
205 $this->clickLink("//a[@id='newCustomField']/span", '_qf_Field_cancel', FALSE);
206 $this->click('data_type[0]');
207 $this->select('data_type[0]', 'value=1');
208 $this->click("//option[@value='1']");
209 $this->click('data_type[1]');
210 $this->select('data_type[1]', 'value=Radio');
211 $this->click("//option[@value='Radio']");
213 $radioFieldLabel = 'custom_field' . substr(sha1(rand()), 0, 4);
214 $this->type('label', $radioFieldLabel);
215 $radioOptionLabel1 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
216 $this->type('option_label_1', $radioOptionLabel1);
217 $this->type('option_value_1', '1');
218 $radioOptionLabel2 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
219 $this->type('option_label_2', $radioOptionLabel2);
220 $this->type('option_value_2', '2');
221 $this->click('link=another choice');
222 $radioOptionLabel3 = 'optionLabel_' . substr(sha1(rand()), 0, 5);
223 $this->type('option_label_3', $radioOptionLabel3);
224 $this->type('option_value_3', '3');
226 //select options per line
227 $this->type('options_per_line', '3');
230 $this->type('help_pre', 'this is field pre help');
232 //enter post help msg
233 $this->type('help_post', 'this is field post help');
236 $this->click('is_searchable');
239 $this->click('_qf_Field_next');
241 $this->openCiviPage("participant/add", "reset=1&action=add&context=standalone", "_qf_Participant_upload-bottom");
243 // Type contact last name in contact auto-complete, wait for dropdown and click first result
244 $this->webtestFillAutocomplete($firstName);
246 // Select event. Based on label for now.
247 $this->select2('event_id', "Rain-forest Cup Youth Soccer Tournament");
250 $this->multiselect2('role_id', array('Volunteer', 'Host'));
252 $this->waitForElementPresent("xpath=//div[@class='crm-customData-block']//div[@class='custom-group custom-group-$customGroupTitle crm-accordion-wrapper collapsed']");
253 $this->click("xpath=//div[@class='crm-customData-block']//div[@class='custom-group custom-group-$customGroupTitle crm-accordion-wrapper collapsed']//div[1]");
254 $this->click("xpath=//div[@class='crm-customData-block']//div[@class='custom-group custom-group-$customGroupTitle crm-accordion-wrapper']//div[2]//table//tbody//tr[2]//td[2]//table//tbody//tr[1]//td[1]//label");
255 $this->click("xpath=//div[@class='crm-customData-block']//div[@class='custom-group custom-group-$customGroupTitle crm-accordion-wrapper']//div[2]//table//tbody//tr[4]//td[2]//table//tbody//tr[1]//td[1]//label");
257 // Choose Registration Date.
258 // Using helper webtestFillDate function.
259 $this->webtestFillDate('register_date', 'now');
260 $today = date('F jS, Y', strtotime('now'));
263 // Select participant status
264 $this->select('status_id', 'value=1');
266 // Setting registration source
267 $this->type('source', 'Event StandaloneAddTest Webtest');
269 // Since we're here, let's check of screen help is being displayed properly
270 $this->assertTrue($this->isTextPresent('Source for this registration (if applicable).'));
272 // Select an event fee
273 $this->waitForElementPresent('priceset');
275 $this->click("xpath=//input[@class='crm-form-radio']");
277 // Enter amount to be paid (note: this should default to selected fee level amount, s/b fixed during 3.2 cycle)
278 $this->type('total_amount', '800');
280 // Select payment method = Check and enter chk number
281 $this->select('payment_instrument_id', 'value=4');
282 $this->waitForElementPresent('check_number');
283 $this->type('check_number', '1044');
286 $this->click('_qf_Participant_upload-bottom');
287 $this->waitForPageToLoad($this->getTimeoutMsec());
289 // Is status message correct?
290 $this->waitForText('crm-notification-container', "Event registration for $displayName has been added");
292 $this->waitForElementPresent("xpath=//*[@id='Search']//table/tbody/tr[1]/td[8]/span/a[text()='View']");
293 //click through to the participant view screen
294 $this->click("xpath=//*[@id='Search']//table/tbody/tr[1]/td[8]/span/a[text()='View']");
295 $this->waitForElementPresent('_qf_ParticipantView_cancel-bottom');
297 $this->webtestVerifyTabularData(
299 'Event' => 'Rain-forest Cup Youth Soccer Tournament',
300 'Participant Role' => 'Attendee, Volunteer, Host',
301 'Status' => 'Registered',
302 'Event Source' => 'Event StandaloneAddTest Webtest',
303 'Fees' => '$ 800.00',
307 $this->assertTrue($this->isTextPresent("$customGroupTitle"));
308 $this->assertTrue($this->isTextPresent("$checkboxOptionLabel1"));
309 $this->assertTrue($this->isTextPresent("$radioOptionLabel1"));
311 // check contribution record as well
312 //click through to the contribution view screen
313 $this->click("xpath=id('ParticipantView')/div[2]/table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='View']");
314 $this->waitForElementPresent('_qf_ContributionView_cancel-bottom');
316 $this->webtestVerifyTabularData(
318 'From' => $displayName,
319 'Financial Type' => 'Event Fee',
320 'Contribution Status' => 'Completed',
321 'Paid By' => 'Check',
322 'Check Number' => '1044',
325 $this->verifyText("xpath=//table/tbody/tr/td[text()='Total Amount']/following-sibling::td/strong", preg_quote('$ 800.00'), 'In line ' . __LINE__
);
328 function testEventAddMultipleParticipants() {
330 // Log in using webtestLogin() method
331 $this->webtestLogin();
333 $processorId = $this->webtestAddPaymentProcessor('dummy' . substr(sha1(rand()), 0, 7));
334 $rand = substr(sha1(rand()), 0, 7);
335 $firstName = 'First' . $rand;
336 $lastName = 'Last' . $rand;
337 $rand = substr(sha1(rand()), 0, 7);
338 $lastName2 = 'Last' . $rand;
340 $this->openCiviPage("participant/add", "reset=1&action=add&context=standalone&mode=test&eid=3");
342 $this->assertTrue($this->isTextPresent("Register New Participant"), "Page title 'Register New Participant' missing");
343 $this->assertTrue($this->isTextPresent("A TEST transaction will be submitted"), "test mode status 'A TEST transaction will be submitted' missing");
344 $this->_fillParticipantDetails($firstName, $lastName, $processorId);
345 $this->click('_qf_Participant_upload_new-bottom');
346 $this->waitForPageToLoad($this->getTimeoutMsec());
348 $this->assertTrue($this->isTextPresent("Register New Participant"), "Page title 'Register New Participant' missing");
349 $this->assertTrue($this->isTextPresent("A TEST transaction will be submitted"), "test mode status 'A TEST transaction will be submitted' missing");
350 $this->_fillParticipantDetails($firstName, $lastName2, $processorId);
351 $this->click('_qf_Participant_upload_new-bottom');
352 $this->waitForPageToLoad($this->getTimeoutMsec());
354 //searching the paricipants
355 $this->openCiviPage("event/search", "reset=1");
356 $this->type('sort_name', $firstName);
357 $eventName = "Rain-forest Cup Youth Soccer Tournament";
358 $this->select2("event_id", $eventName, FALSE, FALSE);
359 $this->check('participant_test');
360 $this->click("_qf_Search_refresh");
361 $this->waitForElementPresent("participantSearch");
363 //verifying the registered participants
364 $names = array( "{$lastName}, {$firstName}", "{$lastName2}, {$firstName}" );
365 $status = "Registered (test)";
367 foreach($names as $name) {
368 $this->verifyText("xpath=//div[@id='participantSearch']//table//tbody//tr/td[@class='crm-participant-sort_name']/a[text()='{$name}']/../../td[9]", preg_quote($status));
369 $this->verifyText("xpath=//div[@id='participantSearch']//table//tbody//tr/td[@class='crm-participant-sort_name']/a[text()='{$name}']/../../td[4]/a", preg_quote($eventName));
373 function testAjaxCustomGroupLoad() {
374 $this->webtestLogin();
377 array('entity' => 'ParticipantEventName', 'subEntity' => 'Fall Fundraiser Dinner',
378 'triggerElement' => array('name' => "event_id", 'type' => "select2")),
379 array('entity' => 'ParticipantRole', 'subEntity' => 'Attendee','triggerElement' => array('type' => "checkbox"))
381 $pageUrl = array('url' => "participant/add", 'args' => "reset=1&action=add&context=standalone");
382 $this->customFieldSetLoadOnTheFlyCheck($customSets, $pageUrl);
386 * Webtest for CRM-10983
389 function testCheckDuplicateCustomDataLoad() {
390 $this->webtestLogin();
393 array('entity' => 'ParticipantEventType', 'subEntity' => '- Any -',
394 'triggerElement' => array('name' => "event_id", 'type' => "select")),
395 array('entity' => 'ParticipantEventName', 'subEntity' => '- Any -',
396 'triggerElement' => array('name' => "event_id", 'type' => "select")),
397 array('entity' => 'ParticipantEventName', 'subEntity' => 'Rain-forest Cup Youth Soccer Tournament',
398 'triggerElement' => array('name' => "event_id", 'type' => "select")),
399 array('entity' => 'ParticipantRole', 'subEntity' => '- Any -','triggerElement' => array('type' => "checkbox")),
400 array('entity' => 'ParticipantRole', 'subEntity' => 'Volunteer','triggerElement' => array('type' => "checkbox"))
403 $return = $this->addCustomGroupField($customSets);
405 $this->openCiviPage("participant/add", "reset=1&action=add&context=standalone", "_qf_Participant_upload-bottom");
408 $this->select2('event_id', "Rain-forest Cup Youth Soccer Tournament");
411 $this->multiselect2('role_id', array('Volunteer'));
413 foreach($return as $values) {
414 foreach ($values as $entityType => $customData) {
415 //checking for duplicate custom data present or not
416 $this->assertElementPresent("xpath=//*[@class='crm-customData-block']/div[@class='custom-group custom-group-{$customData['cgtitle']} crm-accordion-wrapper ']");
417 $this->assertEquals(1, $this->getXpathCount("//*[@class='crm-customData-block']/div[@class='custom-group custom-group-{$customData['cgtitle']} crm-accordion-wrapper ']"));
425 * @param $processorId
427 function _fillParticipantDetails($firstName, $lastName, $processorId) {
428 $this->webtestNewDialogContact($firstName, $lastName);
430 $this->select('payment_processor_id', "value={$processorId}");
431 $event_id = $this->getAttribute("xpath=//*[@id='event_id']@value");
432 //check if it is the selected event
433 $this->assertEquals($event_id, 3);
434 $this->select("role_id", "value=1");
435 $this->webtestAddCreditCardDetails();
436 $this->webtestAddBillingDetails();