whitespace cleanup
[civicrm-core.git] / tests / phpunit / WebTest / Event / MultiprofileEventTest.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.3 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
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
6a488035
TO
27require_once 'CiviTest/CiviSeleniumTestCase.php';
28class WebTest_Event_MultiprofileEventTest extends CiviSeleniumTestCase {
29
30 protected function setUp() {
31 parent::setUp();
32 }
33
34 function testCreateEventRegisterPage() {
6a488035
TO
35 // Log in using webtestLogin() method
36 $this->webtestLogin();
37
42daf119
CW
38 $customGrp1 = "Custom Data1_" . substr(sha1(rand()), 0, 7);
39 $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
40 $lastName = 'An' . substr(sha1(rand()), 0, 7);
6a488035
TO
41 $participantfname = 'Dany' . substr(sha1(rand()), 0, 4);
42 $participantlname = 'Dan' . substr(sha1(rand()), 0, 4);
42daf119
CW
43 $email1 = $firstName . "@test.com";
44 $email2 = $participantfname . "@test.com";
6a488035
TO
45
46 // We need a payment processor
47 $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7);
48 $this->webtestAddPaymentProcessor($processorName);
49
50 //add email to name and address profile
51 $cfId = $this->_addEmailField();
76e86fd8 52
6a488035 53 // create custom group1
071a6d2e 54 $this->openCiviPage("admin/custom/group", "reset=1");
6a488035
TO
55 $this->click("newCustomDataGroup");
56 $this->waitForPageToLoad($this->getTimeoutMsec());
57 $this->type("title", $customGrp1);
58 $this->select("extends[0]", "value=Contact");
59 $this->click("_qf_Group_next-bottom");
60 $this->waitForPageToLoad($this->getTimeoutMsec());
61
62 // get custom group id
63 $elements = $this->parseURL();
64 $customGrpId1 = $elements['queryString']['gid'];
65
66 $customId = $this->_testGetCustomFieldId($customGrpId1);
67
68 $profileId = $this->_testGetProfileId($customId);
69
071a6d2e 70 $this->openCiviPage("event/add", "reset=1&action=add");
6a488035
TO
71
72 $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7);
73 $eventDescription = "Here is a description for this conference.";
74 $this->_testAddEventInfo($eventTitle, $eventDescription);
75
76 $streetAddress = "100 Main Street";
77 $this->_testAddLocation($streetAddress);
78
79 $this->_testAddFees(FALSE, FALSE, $processorName);
80
81 $eventPageId = $this->_testAddMultipleProfile($profileId);
82
83 $this->_testEventRegistration($eventPageId, $customId, $firstName, $lastName,
84 $participantfname, $participantlname, $email1, $email2
85 );
86 $this->waitForPageToLoad($this->getTimeoutMsec());
87
88 // Find Main Participant
071a6d2e 89 $this->openCiviPage("event/search", "reset=1");
6a488035 90 $this->type("sort_name", $firstName);
225a8648
CW
91 $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='participantSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
92 $this->clickLink("xpath=//div[@id='participantSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_ParticipantView_cancel-top");
6a488035
TO
93
94 $name = $firstName . " " . $lastName;
95 $status = 'Registered';
96
97 $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[1]/td[2]/a", preg_quote($name));
98 $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[3]/td[2]/a", preg_quote($eventTitle));
99 $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[6]/td[2]", preg_quote($status));
100
101 // Find additional Participant
071a6d2e 102 $this->openCiviPage("event/search", "reset=1");
6a488035 103 $this->type("sort_name", $participantfname);
225a8648
CW
104 $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='participantSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
105 $this->clickLink("xpath=//div[@id='participantSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_ParticipantView_cancel-top");
6a488035
TO
106
107 $name = $participantfname . " " . $participantlname;
108 $status = 'Registered';
109
110 $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[1]/td[2]/a", preg_quote($name));
111 $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[3]/td[2]/a", preg_quote($eventTitle));
112 $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[6]/td[2]", preg_quote($status));
113
114 // delete all custom data
115 if (isset($cfId)) {
116 $this->_removeEmailField($cfId);
117 }
071a6d2e
CW
118 foreach ($customId as $cid) {
119 $this->openCiviPage("admin/custom/group/field", "action=delete&reset=1&gid={$customGrpId1}&id=$cid");
120 $this->click("_qf_DeleteField_next-bottom");
121 $this->waitForPageToLoad($this->getTimeoutMsec());
122 }
123 $this->openCiviPage("admin/custom/group", "action=delete&reset=1&id=$customGrpId1");
6a488035
TO
124 $this->click("_qf_DeleteGroup_next-bottom");
125 $this->waitForPageToLoad($this->getTimeoutMsec());
6a488035
TO
126 }
127
128 function testAnoumyousRegisterPage() {
6a488035
TO
129 // add the required Drupal permission
130 $permission = array('edit-1-access-all-custom-data');
131 $this->changePermissions($permission);
132
42daf119
CW
133 $customGrp1 = "Custom Data1_" . substr(sha1(rand()), 0, 7);
134 $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
135 $lastName = 'An' . substr(sha1(rand()), 0, 7);
136 $participantfname = 'Dany' . substr(sha1(rand()), 0, 4);
137 $participantlname = 'Dan' . substr(sha1(rand()), 0, 4);
138 $email1 = $firstName . "@test.com";
139 $email2 = $participantfname . "@test.com";
140 $firstName2 = 'Man' . substr(sha1(rand()), 0, 4);
141 $lastName2 = 'Ann' . substr(sha1(rand()), 0, 7);
6a488035
TO
142 $participantfname2 = 'Adam' . substr(sha1(rand()), 0, 4);
143 $participantlname2 = 'Gil' . substr(sha1(rand()), 0, 4);
42daf119
CW
144 $email3 = $participantfname2 . "@test.com";
145 $email4 = $firstName2 . "@test.com";
6a488035
TO
146
147 // We need a payment processor
148 $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7);
149 $this->webtestAddPaymentProcessor($processorName);
150
151 //add email field to name and address profile
152 $cfId = $this->_addEmailField( );
76e86fd8 153
6a488035 154 // create custom group1
071a6d2e 155 $this->openCiviPage("admin/custom/group", "reset=1");
6a488035
TO
156 $this->click("newCustomDataGroup");
157 $this->waitForPageToLoad($this->getTimeoutMsec());
158 $this->type("title", $customGrp1);
159 $this->select("extends[0]", "value=Contact");
160 $this->click("_qf_Group_next-bottom");
161 $this->waitForPageToLoad($this->getTimeoutMsec());
162
163 // get custom group id
164 $elements = $this->parseURL();
165 $customGrpId1 = $elements['queryString']['gid'];
166
167 $customId = $this->_testGetCustomFieldId($customGrpId1);
168
169 $profileId = $this->_testGetProfileId($customId);
170
42daf119 171 $this->openCiviPage('event/add', "reset=1&action=add");
6a488035
TO
172
173 $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7);
174 $eventDescription = "Here is a description for this conference.";
175 $this->_testAddEventInfo($eventTitle, $eventDescription);
176
177 $streetAddress = "100 Main Street";
178 $this->_testAddLocation($streetAddress);
179
180 $this->_testAddFees(FALSE, FALSE, $processorName);
181
182 $eventPageId = $this->_testAddMultipleProfile($profileId);
183
184 // logout
42daf119 185 $this->webtestLogout();
6a488035
TO
186
187 $this->_testEventRegistration($eventPageId, $customId, $firstName, $lastName, $participantfname, $participantlname, $email1, $email2);
188 $this->waitForPageToLoad($this->getTimeoutMsec());
189 // Log in using webtestLogin() method
190 $this->webtestLogin();
191
192 // Find Main Participant
071a6d2e 193 $this->openCiviPage("event/search", "reset=1");
6a488035 194 $this->type("sort_name", $firstName);
225a8648
CW
195 $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='participantSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
196 $this->clickLink("xpath=//div[@id='participantSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_ParticipantView_cancel-top");
6a488035
TO
197
198 $name = $firstName . " " . $lastName;
199 $status = 'Registered';
200
201 $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[1]/td[2]/a", preg_quote($name));
202 $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[3]/td[2]/a", preg_quote($eventTitle));
203 $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[6]/td[2]", preg_quote($status));
204
205 // Find additional Participant
071a6d2e 206 $this->openCiviPage("event/search", "reset=1");
6a488035 207 $this->type("sort_name", $participantfname);
225a8648
CW
208 $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='participantSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
209 $this->clickLink("xpath=//div[@id='participantSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_ParticipantView_cancel-top");
6a488035
TO
210
211 $name = $participantfname . " " . $participantlname;
212 $status = 'Registered';
213
214 $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[1]/td[2]/a", preg_quote($name));
215 $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[3]/td[2]/a", preg_quote($eventTitle));
216 $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[6]/td[2]", preg_quote($status));
217
218 // Edit page and remove some profile
219 $this->_testRemoveProfile($eventPageId);
220
221 // logout
42daf119 222 $this->webtestLogout();
6a488035
TO
223
224 $this->_testEventRegistrationAfterRemoving($eventPageId, $customId, $firstName2, $lastName2, $participantfname2, $participantlname2, $email3, $email4);
225 $this->waitForPageToLoad($this->getTimeoutMsec());
226
227 // Log in using webtestLogin() method
228 $this->webtestLogin();
229
230 // Find Main Participant
42daf119 231 $this->openCiviPage('event/search', "reset=1");
6a488035 232 $this->type("sort_name", $firstName2);
225a8648
CW
233 $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='participantSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
234 $this->clickLink("xpath=//div[@id='participantSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_ParticipantView_cancel-top");
6a488035
TO
235
236 $name = $firstName2 . " " . $lastName2;
237 $status = 'Registered';
238
239 $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[1]/td[2]/a", preg_quote($name));
240 $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[3]/td[2]/a", preg_quote($eventTitle));
241 $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[6]/td[2]", preg_quote($status));
242
243 // Find additional Participant
071a6d2e 244 $this->openCiviPage("event/search", "reset=1");
6a488035 245 $this->type("sort_name", $participantfname2);
225a8648
CW
246 $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='participantSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
247 $this->clickLink("xpath=//div[@id='participantSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_ParticipantView_cancel-top");
6a488035
TO
248
249 $name = $participantfname2 . " " . $participantlname2;
250 $status = 'Registered';
251
252 $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[1]/td[2]/a", preg_quote($name));
253 $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[3]/td[2]/a", preg_quote($eventTitle));
254 $this->verifyText("xpath=//form[@id='ParticipantView']/div[2]/table/tbody/tr[6]/td[2]", preg_quote($status));
255
256 // delete all custom data
76e86fd8
CW
257 if (isset($cfId)) {
258
6a488035
TO
259 $this->_removeEmailField($cfId);
260 }
071a6d2e
CW
261 foreach ($customId as $cid) {
262 $this->openCiviPage("admin/custom/group/field", "action=delete&reset=1&gid={$customGrpId1}&id=$cid");
263 $this->click("_qf_DeleteField_next-bottom");
264 $this->waitForPageToLoad($this->getTimeoutMsec());
265 }
266 $this->openCiviPage("admin/custom/group", "action=delete&reset=1&id=$customGrpId1");
6a488035
TO
267 $this->click("_qf_DeleteGroup_next-bottom");
268 $this->waitForPageToLoad($this->getTimeoutMsec());
269 }
270
271 function _testGetCustomFieldId($customGrpId1) {
272 $customId = array();
273
274 // Create a custom data to add in profile
275
276 $field1 = "Fname" . substr(sha1(rand()), 0, 7);
277 $field2 = "Mname" . substr(sha1(rand()), 0, 7);
278 $field3 = "Lname" . substr(sha1(rand()), 0, 7);
279
280 // add custom fields for group 1
071a6d2e 281 $this->openCiviPage("admin/custom/group/field/add", "reset=1&action=add&gid=$customGrpId1");
6a488035
TO
282 $this->type("label", $field1);
283 $this->check("is_searchable");
284 $this->click("_qf_Field_next_new-bottom");
285 $this->waitForPageToLoad($this->getTimeoutMsec());
286
287 $this->type("label", $field2);
288 $this->check("is_searchable");
289 $this->click("_qf_Field_next_new-bottom");
290 $this->waitForPageToLoad($this->getTimeoutMsec());
291
292 $this->type("label", $field3);
293 $this->check("is_searchable");
294 $this->click("_qf_Field_next-bottom");
295 $this->waitForPageToLoad($this->getTimeoutMsec());
296
297 // get id of custom fields
071a6d2e 298 $this->openCiviPage("admin/custom/group/field", "reset=1&action=browse&gid=$customGrpId1");
6a488035
TO
299 $custom1 = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody//tr[1]/td[8]/span/a[text()='Edit Field']/@href"));
300 $custom1 = $custom1[1];
301 array_push($customId, $custom1);
302 $custom2 = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody//tr[2]/td[8]/span/a[text()='Edit Field']/@href"));
303 $custom2 = $custom2[1];
304 array_push($customId, $custom2);
305 $custom3 = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody//tr[3]/td[8]/span/a[text()='Edit Field']/@href"));
306 $custom3 = $custom3[1];
307 array_push($customId, $custom3);
308
309 return $customId;
310 }
311
312 function _testRemoveProfile($eventPageId) {
071a6d2e 313 $this->openCiviPage("event/manage/settings", "reset=1&action=update&id=$eventPageId");
6a488035
TO
314
315 // Go to Online Contribution tab
316 $this->click("link=Online Registration");
317 $this->waitForElementPresent("_qf_Registration_upload-bottom");
318 $this->click("xpath=//select[@id='additional_custom_post_id_multiple_1']/../span/a[text()='remove profile']");
319 $this->click("xpath=//select[@id='additional_custom_post_id_multiple_2']/../span/a[text()='remove profile']");
320 $this->click("xpath=//select[@id='additional_custom_post_id_multiple_3']/../span/a[text()='remove profile']");
321 $this->click("xpath=//select[@id='additional_custom_post_id_multiple_4']/../span/a[text()='remove profile']");
322 $this->click("_qf_Registration_upload-bottom");
323 $this->waitForPageToLoad($this->getTimeoutMsec());
324 }
325
326 function _testGetProfileId($customId) {
327 // create profiles
328 $profileId = array();
329 $profilefield = array(
330 'street_address' => 'street_address',
331 'supplemental_address_1' => 'supplemental_address_1',
332 'city' => 'city',
333 );
42daf119
CW
334 $location = 1;
335 $type = "Contact";
6a488035
TO
336 $profileId1 = $this->_testCreateProfile($profilefield, $location, $type);
337 array_push($profileId, $profileId1);
338
339 $profilefield = array(
340 'street_address' => 'street_address',
341 'city' => 'city',
342 'phone' => 'phone',
343 'postal_code' => 'postal_code',
344 );
42daf119
CW
345 $location = 0;
346 $type = "Contact";
6a488035
TO
347 $profileId2 = $this->_testCreateProfile($profilefield, $location, $type);
348 array_push($profileId, $profileId2);
349
350 $profilefield = array(
351 'nick_name' => 'nick_name',
352 'url' => 'url',
353 );
42daf119
CW
354 $location = 0;
355 $type = "Contact";
6a488035
TO
356 $profileId3 = $this->_testCreateProfile($profilefield, $location, $type);
357 array_push($profileId, $profileId3);
358
359 $profilefield = array(
360 'current_employer' => 'current_employer',
361 'job_title' => 'job_title',
362 );
42daf119
CW
363 $location = 0;
364 $type = "Individual";
6a488035
TO
365 $profileId4 = $this->_testCreateProfile($profilefield, $location, $type);
366 array_push($profileId, $profileId4);
367
368 $profilefield = array(
369 'middle_name' => 'middle_name',
370 'gender' => 'gender',
371 );
42daf119
CW
372 $location = 0;
373 $type = "Individual";
6a488035
TO
374 $profileId5 = $this->_testCreateProfile($profilefield, $location, $type);
375 array_push($profileId, $profileId5);
376
377 $profilefield = array(
378 'custom_' . $customId[0] => 'custom_' . $customId[0],
379 'custom_' . $customId[1] => 'custom_' . $customId[1],
380 'custom_' . $customId[2] => 'custom_' . $customId[2],
381 );
42daf119
CW
382 $location = 0;
383 $type = "Contact";
6a488035
TO
384 $profileId6 = $this->_testCreateProfile($profilefield, $location, $type);
385 array_push($profileId, $profileId6);
386
387 $profilefield = array(
388 'participant_role' => 'participant_role',
389 );
42daf119
CW
390 $location = 0;
391 $type = "Participant";
6a488035
TO
392 $profileId7 = $this->_testCreateProfile($profilefield, $location, $type);
393 array_push($profileId, $profileId7);
394
395 return $profileId;
396 }
397
398 function _testCreateProfile($profilefield, $location = 0, $type) {
399 $locationfields = array(
400 'supplemental_address_1',
401 'supplemental_address_2',
402 'city',
403 'country',
404 'email',
405 'state',
406 'street_address',
407 'postal_code',
408 );
409
42daf119 410 // Add new profile.
6a488035 411 $profilename = "Profile_" . substr(sha1(rand()), 0, 7);
071a6d2e 412 $this->openCiviPage("admin/uf/group", "reset=1");
6a488035
TO
413 $this->click('newCiviCRMProfile-top');
414 $this->waitForElementPresent('_qf_Group_next-top');
415
416 //Name of profile
417 $this->type('title', $profilename);
418 $this->click('_qf_Group_next-top');
419 $this->waitForPageToLoad($this->getTimeoutMsec());
420 $elements = $this->parseURL();
421 $profileId = $elements['queryString']['gid'];
422
423 //Add field to profile_testCreateProfile
424 foreach ($profilefield as $key => $value) {
071a6d2e 425 $this->openCiviPage("admin/uf/group/field/add", "reset=1&action=add&gid=$profileId");
6a488035
TO
426 $this->waitForPageToLoad($this->getTimeoutMsec());
427 if (in_array($value, $locationfields)) {
428 $this->select("field_name[0]", "value={$type}");
429 $this->select("field_name[1]", "value={$value}");
430 $this->select("field_name[2]", "value={$location}");
431 $this->type("label", $value);
432 }
433 else {
434 $this->select("field_name[0]", "value={$type}");
435 $this->select("field_name[1]", "value={$value}");
436 $this->type("label", $value);
437 }
438 $this->click('_qf_Field_next-top');
439 $this->waitForPageToLoad($this->getTimeoutMsec());
440 }
441 return $profileId;
442 }
443
444 function _testAddEventInfo($eventTitle, $eventDescription) {
6a488035
TO
445 $this->waitForElementPresent("_qf_EventInfo_upload-bottom");
446
6a488035
TO
447 $this->select("event_type_id", "value=1");
448
449 // Attendee role s/b selected now.
450 $this->select("default_role_id", "value=1");
451
452 // Enter Event Title, Summary and Description
453 $this->type("title", $eventTitle);
454 $this->type("summary", "This is a great conference. Sign up now!");
455
456 // Type description in ckEditor (fieldname, text to type, editor)
457 $this->fillRichTextField("description", $eventDescription, 'CKEditor');
458
459 // Choose Start and End dates.
460 // Using helper webtestFillDate function.
461 $this->webtestFillDateTime("start_date", "+1 week");
462 $this->webtestFillDateTime("end_date", "+1 week 1 day 8 hours ");
463
464 $this->type("max_participants", "50");
465 $this->click("is_map");
466 $this->click("_qf_EventInfo_upload-bottom");
467 }
468
469 function _testAddLocation($streetAddress) {
470 // Wait for Location tab form to load
471 $this->waitForPageToLoad($this->getTimeoutMsec());
472 $this->waitForElementPresent("_qf_Location_upload-bottom");
473
474 // Fill in address fields
475 //$streetAddress = "100 Main Street";
476 $this->type("address_1_street_address", $streetAddress);
477 $this->type("address_1_city", "San Francisco");
478 $this->type("address_1_postal_code", "94117");
479 $this->select("address_1_state_province_id", "value=1004");
480 $this->type("email_1_email", "info@civicrm.org");
481
482 $this->click("_qf_Location_upload-bottom");
483
484 // Wait for "saved" status msg
485 $this->waitForPageToLoad($this->getTimeoutMsec());
486 $this->waitForTextPresent("'Location' information has been saved.");
487 }
488
489 function _testAddFees($discount = FALSE, $priceSet = FALSE, $processorName = "PP Pro") {
490 // Go to Fees tab
491 $this->click("link=Fees");
492 $this->waitForElementPresent("_qf_Fee_upload-bottom");
493 $this->click("CIVICRM_QFID_1_is_monetary");
494
495 // select newly created processor
496 $xpath = "xpath=//label[text() = '{$processorName}']/preceding-sibling::input[1]";
497 $this->assertTrue($this->isTextPresent($processorName));
498 $this->check($xpath);
499 $this->select("financial_type_id", "label=Event Fee");
500 if ($priceSet) {
501 // get one - TBD
502 }
503 else {
504 $this->type("label_1", "Member");
505 $this->type("value_1", "250.00");
506 $this->type("label_2", "Non-member");
507 $this->type("value_2", "325.00");
508 //set default
509 $this->click("xpath=//table[@id='map-field-table']/tbody/tr[2]/td[3]/input");
510 }
511
512 if ($discount) {
513 // enter early bird discounts TBD
514 }
515
516 $this->click("_qf_Fee_upload-bottom");
517
518 // Wait for "saved" status msg
519 $this->waitForPageToLoad($this->getTimeoutMsec());
520 $this->waitForTextPresent("'Fee' information has been saved.");
521 }
522
523 function _testAddMultipleProfile($profileId) {
524 // Go to Online Contribution tab
525 $this->click("link=Online Registration");
526 $this->waitForElementPresent("_qf_Registration_upload-bottom");
527 $this->click("is_online_registration");
528 $this->check("is_multiple_registrations");
529 $this->select("custom_pre_id", "value=1");
530 $this->select("custom_post_id", "value=" . $profileId[3]);
531
532 $this->waitForElementPresent("xpath=//div[@id='registration_screen']/table[2]//tbody/tr[2]/td[2]/span/a[text()='add profile']");
533 $this->click("xpath=//div[@id='registration_screen']/table[2]//tbody/tr[2]/td[2]/span/a[text()='add profile']");
534 $this->waitForElementPresent("custom_post_id_multiple_1");
535 $this->select("custom_post_id_multiple_1", "value=" . $profileId[2]);
536
537 $this->waitForElementPresent("xpath=//div[@id='registration_screen']/table[2]//tbody/tr[2]/td[2]/span/a[text()='add profile']");
538 $this->click("xpath=//div[@id='registration_screen']/table[2]//tbody/tr[2]/td[2]/span/a[text()='add profile']");
539 $this->waitForElementPresent("custom_post_id_multiple_2");
540 $this->select("custom_post_id_multiple_2", "value=" . $profileId[1]);
541
542 $this->waitForElementPresent("xpath=//div[@id='registration_screen']/table[2]//tbody/tr[2]/td[2]/span/a[text()='add profile']");
543 $this->click("xpath=//div[@id='registration_screen']/table[2]//tbody/tr[2]/td[2]/span/a[text()='add profile']");
544 $this->waitForElementPresent("custom_post_id_multiple_3");
545 $this->select("custom_post_id_multiple_3", "value=" . $profileId[4]);
546
547 $this->waitForElementPresent("xpath=//div[@id='registration_screen']/table[2]//tbody/tr[2]/td[2]/span/a[text()='add profile']");
548 $this->click("xpath=//div[@id='registration_screen']/table[2]//tbody/tr[2]/td[2]/span/a[text()='add profile']");
549 $this->waitForElementPresent("custom_post_id_multiple_4");
550 $this->select("custom_post_id_multiple_4", "value=" . $profileId[5]);
551
552 $this->waitForElementPresent("xpath=//div[@id='registration_screen']/table[2]//tbody/tr[2]/td[2]/span/a[text()='add profile']");
553 $this->click("xpath=//div[@id='registration_screen']/table[2]//tbody/tr[2]/td[2]/span/a[text()='add profile']");
554 $this->waitForElementPresent("custom_post_id_multiple_5");
555 $this->select("custom_post_id_multiple_5", "value=" . $profileId[6]);
556
557 $this->waitForElementPresent("xpath=//div[@id='registration_screen']/table[3]//tbody/tr[2]/td[2]/span/a[text()='add profile']");
558 $this->click("xpath=//div[@id='registration_screen']/table[3]//tbody/tr[2]/td[2]/span/a[text()='add profile']");
559 $this->waitForElementPresent("additional_custom_post_id_multiple_1");
560 $this->select("additional_custom_post_id_multiple_1", "value=" . $profileId[5]);
561
562 $this->waitForElementPresent("xpath=//div[@id='registration_screen']/table[3]//tbody/tr[2]/td[2]/span/a[text()='add profile']");
563 $this->click("xpath=//div[@id='registration_screen']/table[3]//tbody/tr[2]/td[2]/span/a[text()='add profile']");
564 $this->waitForElementPresent("additional_custom_post_id_multiple_2");
565 $this->select("additional_custom_post_id_multiple_2", "value=" . $profileId[1]);
566
567 $this->waitForElementPresent("xpath=//div[@id='registration_screen']/table[3]//tbody/tr[2]/td[2]/span/a[text()='add profile']");
568 $this->click("xpath=//div[@id='registration_screen']/table[3]//tbody/tr[2]/td[2]/span/a[text()='add profile']");
569 $this->waitForElementPresent("additional_custom_post_id_multiple_3");
570 $this->select("additional_custom_post_id_multiple_3", "value=" . $profileId[2]);
571
572 $this->waitForElementPresent("xpath=//div[@id='registration_screen']/table[3]//tbody/tr[2]/td[2]/span/a[text()='add profile']");
573 $this->click("xpath=//div[@id='registration_screen']/table[3]//tbody/tr[2]/td[2]/span/a[text()='add profile']");
574 $this->waitForElementPresent("additional_custom_post_id_multiple_4");
575 $this->select("additional_custom_post_id_multiple_4", "value=" . $profileId[3]);
576
577 $this->click("CIVICRM_QFID_1_is_email_confirm");
578 $this->type("confirm_from_name", "TestEvent");
579 $this->type("confirm_from_email", "testevent@test.com");
580 $this->click("_qf_Registration_upload-bottom");
581
582 // Wait for "saved" status msg
583 $this->waitForPageToLoad($this->getTimeoutMsec());
584 $elements = $this->parseURL();
585 $eventPageId = $elements['queryString']['id'];
586
587 $this->waitForTextPresent("'Registration' information has been saved.");
588
589 return $eventPageId;
590 }
591
592 function _testEventRegistration($eventPageId, $customId, $firstName, $lastName,
593 $participantfname, $participantlname, $email1, $email2
594 ) {
42daf119 595 $this->openCiviPage("event/register", "id={$eventPageId}&reset=1", "_qf_Register_upload-bottom");
6a488035
TO
596 $this->select("additional_participants", "value=1");
597
598 $this->type("email-Primary", $email1);
599 $this->type("first_name", $firstName);
600 $this->type("last_name", $lastName);
601 $this->type("street_address-1", "Test street addres");
602 $this->type("city-1", "Mumbai");
603 $this->type("postal_code-1", "2354");
604 $this->select("state_province-1", "value=1001");
605
606 // Credit Card Info
607 $this->select("credit_card_type", "value=Visa");
608 $this->type("credit_card_number", "4111111111111111");
609 $this->type("cvv2", "000");
610 $this->select("credit_card_exp_date[M]", "value=1");
611 $this->select("credit_card_exp_date[Y]", "value=2020");
612
613 //Billing Info
614 $this->type("billing_first_name", $firstName . 'billing');
615 $this->type("billing_last_name", $lastName . 'billing');
616 $this->type("billing_street_address-5", "0121 Mount Highschool.");
617 $this->type(" billing_city-5", "Shangai");
618 $this->select("billing_country_id-5", "value=1228");
619 $this->select("billing_state_province_id-5", "value=1004");
620 $this->type("billing_postal_code-5", "94129");
621
622 $this->type("current_employer", "ABCD");
623 $this->type("job_title", "Painter");
624 $this->type("nick_name", "Nick");
625 $this->type("url-1", "http://www.test.com");
626
627 $this->type("street_address-Primary", "Primary street address");
628 $this->type("city-Primary", "primecity");
629 $this->type("phone-Primary-1", "98667764");
630 $this->type("postal_code-Primary", "6548");
631
632 $this->type("custom_" . $customId[0], "fname_custom1");
633 $this->type("custom_" . $customId[1], "mname_custom1");
634 $this->type("custom_" . $customId[2], "lname_custom1");
635
636 $this->type("middle_name", "xyz");
637 $this->click("name=gender value=2");
638 $this->select("participant_role", "value=2");
639
640 $this->click("_qf_Register_upload-bottom");
641 $this->waitForElementPresent("_qf_Participant_1_next-Array");
642
643 $this->type("email-Primary", $email2);
644 $this->type("first_name", $participantfname);
645 $this->type("last_name", $participantlname);
646 $this->type("street_address-1", "participant street addres");
647 $this->type("city-1", "pune");
648 $this->type("postal_code-1", "2354");
649 $this->select("state_province-1", "value=1001");
650
651 $this->type("current_employer", "ABCD");
652 $this->type("job_title", "Potato picker");
653
654 $this->type("custom_" . $customId[0], "participant_custom1");
655 $this->type("custom_" . $customId[1], "participant_custom1");
656 $this->type("custom_" . $customId[2], "participant_custom1");
657
658 $this->type("street_address-Primary", "Primary street address");
659 $this->type("city-Primary", "primecity");
660 $this->type("phone-Primary-1", "98667764");
661 $this->type("postal_code-Primary", "6548");
662
663 $this->type("nick_name", "Nick1");
664 $this->type("url-1", "http://www.part.com");
665
225a8648 666 $this->clickLink("_qf_Participant_1_next-Array", "_qf_Confirm_next-bottom");
6a488035
TO
667 $this->click("_qf_Confirm_next-bottom");
668 $this->waitForPageToLoad($this->getTimeoutMsec());
669 }
670
671 function _testEventRegistrationAfterRemoving($eventPageId, $customId, $firstName2, $lastName2, $participantfname2, $participantlname2, $email3, $email4) {
42daf119 672 $this->openCiviPage("event/register", "id={$eventPageId}&reset=1", "_qf_Register_upload-bottom");
6a488035
TO
673 $this->select("additional_participants", "value=1");
674
675 $this->type("email-Primary", $email4);
676 $this->type("first_name", $firstName2);
677 $this->type("last_name", $lastName2);
678 $this->type("street_address-1", "Test street addres");
679 $this->type("city-1", "Mumbai");
680 $this->type("postal_code-1", "2354");
681 $this->select("state_province-1", "value=1001");
682
683 // Credit Card Info
684 $this->select("credit_card_type", "value=Visa");
685 $this->type("credit_card_number", "4111111111111111");
686 $this->type("cvv2", "000");
687 $this->select("credit_card_exp_date[M]", "value=1");
688 $this->select("credit_card_exp_date[Y]", "value=2020");
689
690 //Billing Info
691 $this->type("billing_first_name", $firstName2 . 'billing');
692 $this->type("billing_last_name", $lastName2 . 'billing');
693 $this->type("billing_street_address-5", "0121 Mount Highschool.");
694 $this->type(" billing_city-5", "Shangai");
695 $this->select("billing_country_id-5", "value=1228");
696 $this->select("billing_state_province_id-5", "value=1004");
697 $this->type("billing_postal_code-5", "94129");
698
699 $this->type("current_employer", "ABCD");
700 $this->type("job_title", "Painter");
701
702 $this->type("nick_name", "Nickkk");
703 $this->type("url-1", "http://www.testweb.com");
704
705 $this->type("street_address-Primary", "Primary street address");
706 $this->type("city-Primary", "primecity");
707 $this->type("phone-Primary-1", "9866776422");
708 $this->type("postal_code-Primary", "6534");
709
710 $this->type("custom_" . $customId[0], "fname_custom1");
711 $this->type("custom_" . $customId[1], "mname_custom1");
712 $this->type("custom_" . $customId[2], "lname_custom1");
713
714 $this->type("middle_name", "xyz");
715 $this->click("name=gender value=2");
716 $this->select("participant_role", "value=2");
717
718 $this->click("_qf_Register_upload-bottom");
719 $this->waitForElementPresent("_qf_Participant_1_next-Array");
720
721 $this->type("email-Primary", $email3);
722 $this->type("first_name", $participantfname2);
723 $this->type("last_name", $participantlname2);
724 $this->type("street_address-1", "participant street addres");
725 $this->type("city-1", "pune");
726 $this->type("postal_code-1", "2354");
727 $this->select("state_province-1", "value=1001");
728
729 $this->type("current_employer", "ABCD");
730 $this->type("job_title", "BATCHER");
731
225a8648 732 $this->clickLink("_qf_Participant_1_next-Array", "_qf_Confirm_next-bottom");
6a488035
TO
733 $this->click("_qf_Confirm_next-bottom");
734 }
76e86fd8 735
6a488035
TO
736 function _addEmailField( ){
737 //add email field in name and address profile
42daf119 738 $this->openCiviPage('admin/uf/group/field/add', 'reset=1&action=add&gid=1', "_qf_Field_next-bottom");
6a488035
TO
739 $this->select("field_name[0]", "value=Contact");
740 $this->select("field_name[1]", "value=email");
741 $this->select("field_name[2]", "value=0");
742 $this->click('_qf_Field_next-bottom');
743 $this->waitForPageToLoad($this->getTimeoutMsec());
76e86fd8 744
6a488035
TO
745 $cfId = "";
746 //check wheather webtest has created the field
747 if (!$this->isTextPresent("The selected field was not added. It already exists in this profile")) {
748 $this->waitForElementPresent("xpath=//div[@id='field_page']//table/tbody//tr[8]/td[9]/span/a[text()='Edit']");
749 $cfId = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody//tr[8]/td[9]/span/a[text()='Edit']/@href"));
750 $cfId = $cfId[1];
751 }
752 return $cfId;
753 }
76e86fd8
CW
754
755 function _removeEmailField($cfId) {
756
071a6d2e 757 $this->openCiviPage("admin/uf/group/field", "action=delete&id={$cfId}");
6a488035
TO
758 $this->click("_qf_Field_next-bottom");
759 $this->waitForPageToLoad($this->getTimeoutMsec());
760 }
761}
762