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