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