Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
06a1bc01 | 4 | | CiviCRM version 4.5 | |
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 | 27 | require_once 'CiviTest/CiviSeleniumTestCase.php'; |
e9479dcf EM |
28 | |
29 | /** | |
30 | * Class WebTest_Event_MultiprofileEventTest | |
31 | */ | |
6a488035 TO |
32 | class WebTest_Event_MultiprofileEventTest extends CiviSeleniumTestCase { |
33 | ||
34 | protected function setUp() { | |
35 | parent::setUp(); | |
36 | } | |
37 | ||
38 | 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 TO |
49 | |
50 | // We need a payment processor | |
51 | $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7); | |
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 | ||
131 | 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 TO |
149 | |
150 | // We need a payment processor | |
151 | $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7); | |
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 | */ | |
6a488035 TO |
277 | function _testGetCustomFieldId($customGrpId1) { |
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"); | |
300 | $this->click("_qf_Field_next-bottom"); | |
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 EM |
318 | /** |
319 | * @param $eventPageId | |
320 | */ | |
6a488035 | 321 | 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"); | |
327 | $this->click("xpath=//select[@id='additional_custom_post_id_multiple_1']/../span/a[text()='remove profile']"); | |
328 | $this->click("xpath=//select[@id='additional_custom_post_id_multiple_2']/../span/a[text()='remove profile']"); | |
329 | $this->click("xpath=//select[@id='additional_custom_post_id_multiple_3']/../span/a[text()='remove profile']"); | |
330 | $this->click("xpath=//select[@id='additional_custom_post_id_multiple_4']/../span/a[text()='remove profile']"); | |
331 | $this->click("_qf_Registration_upload-bottom"); | |
ed174dea | 332 | $this->waitForElementPresent("_qf_Registration_upload-bottom"); |
6a488035 TO |
333 | } |
334 | ||
4cbe18b8 EM |
335 | /** |
336 | * @param $customId | |
337 | * | |
338 | * @return array | |
339 | */ | |
6a488035 TO |
340 | function _testGetProfileId($customId) { |
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 | */ | |
6a488035 TO |
419 | function _testCreateProfile($profilefield, $location = 0, $type) { |
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 | */ | |
6a488035 | 468 | 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 | */ | |
6a488035 TO |
496 | function _testAddLocation($streetAddress) { |
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"); | |
505 | $this->type("address_1_postal_code", "94117"); | |
506 | $this->select("address_1_state_province_id", "value=1004"); | |
507 | $this->type("email_1_email", "info@civicrm.org"); | |
508 | ||
509 | $this->click("_qf_Location_upload-bottom"); | |
510 | ||
511 | // Wait for "saved" status msg | |
ed174dea | 512 | $this->waitForElementPresent("_qf_Location_upload-bottom"); |
513 | $this->waitForTextPresent("'Event Location' information has been saved."); | |
6a488035 TO |
514 | } |
515 | ||
4cbe18b8 EM |
516 | /** |
517 | * @param bool $discount | |
518 | * @param bool $priceSet | |
519 | * @param string $processorName | |
520 | */ | |
6a488035 TO |
521 | function _testAddFees($discount = FALSE, $priceSet = FALSE, $processorName = "PP Pro") { |
522 | // Go to Fees tab | |
523 | $this->click("link=Fees"); | |
524 | $this->waitForElementPresent("_qf_Fee_upload-bottom"); | |
525 | $this->click("CIVICRM_QFID_1_is_monetary"); | |
526 | ||
527 | // select newly created processor | |
528 | $xpath = "xpath=//label[text() = '{$processorName}']/preceding-sibling::input[1]"; | |
d275114d | 529 | $this->assertElementContainsText('css=.crm-event-manage-fee-form-block-payment_processor', $processorName); |
6a488035 TO |
530 | $this->check($xpath); |
531 | $this->select("financial_type_id", "label=Event Fee"); | |
532 | if ($priceSet) { | |
533 | // get one - TBD | |
534 | } | |
535 | else { | |
536 | $this->type("label_1", "Member"); | |
537 | $this->type("value_1", "250.00"); | |
538 | $this->type("label_2", "Non-member"); | |
539 | $this->type("value_2", "325.00"); | |
540 | //set default | |
541 | $this->click("xpath=//table[@id='map-field-table']/tbody/tr[2]/td[3]/input"); | |
542 | } | |
543 | ||
544 | if ($discount) { | |
545 | // enter early bird discounts TBD | |
546 | } | |
547 | ||
548 | $this->click("_qf_Fee_upload-bottom"); | |
549 | ||
550 | // Wait for "saved" status msg | |
ed174dea | 551 | $this->waitForElementPresent("_qf_Fee_upload-bottom"); |
552 | $this->waitForTextPresent("'Fees' information has been saved."); | |
6a488035 TO |
553 | } |
554 | ||
4cbe18b8 EM |
555 | /** |
556 | * @param $profileId | |
557 | * | |
558 | * @return null | |
559 | */ | |
6a488035 TO |
560 | function _testAddMultipleProfile($profileId) { |
561 | // Go to Online Contribution tab | |
562 | $this->click("link=Online Registration"); | |
563 | $this->waitForElementPresent("_qf_Registration_upload-bottom"); | |
564 | $this->click("is_online_registration"); | |
565 | $this->check("is_multiple_registrations"); | |
566 | $this->select("custom_pre_id", "value=1"); | |
567 | $this->select("custom_post_id", "value=" . $profileId[3]); | |
377afa39 | 568 | $this->select("additional_custom_post_id", "label=- same as for main contact -"); |
6a488035 TO |
569 | |
570 | $this->waitForElementPresent("xpath=//div[@id='registration_screen']/table[2]//tbody/tr[2]/td[2]/span/a[text()='add profile']"); | |
571 | $this->click("xpath=//div[@id='registration_screen']/table[2]//tbody/tr[2]/td[2]/span/a[text()='add profile']"); | |
572 | $this->waitForElementPresent("custom_post_id_multiple_1"); | |
573 | $this->select("custom_post_id_multiple_1", "value=" . $profileId[2]); | |
574 | ||
575 | $this->waitForElementPresent("xpath=//div[@id='registration_screen']/table[2]//tbody/tr[2]/td[2]/span/a[text()='add profile']"); | |
576 | $this->click("xpath=//div[@id='registration_screen']/table[2]//tbody/tr[2]/td[2]/span/a[text()='add profile']"); | |
577 | $this->waitForElementPresent("custom_post_id_multiple_2"); | |
578 | $this->select("custom_post_id_multiple_2", "value=" . $profileId[1]); | |
579 | ||
580 | $this->waitForElementPresent("xpath=//div[@id='registration_screen']/table[2]//tbody/tr[2]/td[2]/span/a[text()='add profile']"); | |
581 | $this->click("xpath=//div[@id='registration_screen']/table[2]//tbody/tr[2]/td[2]/span/a[text()='add profile']"); | |
582 | $this->waitForElementPresent("custom_post_id_multiple_3"); | |
583 | $this->select("custom_post_id_multiple_3", "value=" . $profileId[4]); | |
584 | ||
585 | $this->waitForElementPresent("xpath=//div[@id='registration_screen']/table[2]//tbody/tr[2]/td[2]/span/a[text()='add profile']"); | |
586 | $this->click("xpath=//div[@id='registration_screen']/table[2]//tbody/tr[2]/td[2]/span/a[text()='add profile']"); | |
587 | $this->waitForElementPresent("custom_post_id_multiple_4"); | |
588 | $this->select("custom_post_id_multiple_4", "value=" . $profileId[5]); | |
589 | ||
590 | $this->waitForElementPresent("xpath=//div[@id='registration_screen']/table[2]//tbody/tr[2]/td[2]/span/a[text()='add profile']"); | |
591 | $this->click("xpath=//div[@id='registration_screen']/table[2]//tbody/tr[2]/td[2]/span/a[text()='add profile']"); | |
592 | $this->waitForElementPresent("custom_post_id_multiple_5"); | |
593 | $this->select("custom_post_id_multiple_5", "value=" . $profileId[6]); | |
594 | ||
595 | $this->waitForElementPresent("xpath=//div[@id='registration_screen']/table[3]//tbody/tr[2]/td[2]/span/a[text()='add profile']"); | |
596 | $this->click("xpath=//div[@id='registration_screen']/table[3]//tbody/tr[2]/td[2]/span/a[text()='add profile']"); | |
597 | $this->waitForElementPresent("additional_custom_post_id_multiple_1"); | |
598 | $this->select("additional_custom_post_id_multiple_1", "value=" . $profileId[5]); | |
599 | ||
600 | $this->waitForElementPresent("xpath=//div[@id='registration_screen']/table[3]//tbody/tr[2]/td[2]/span/a[text()='add profile']"); | |
601 | $this->click("xpath=//div[@id='registration_screen']/table[3]//tbody/tr[2]/td[2]/span/a[text()='add profile']"); | |
602 | $this->waitForElementPresent("additional_custom_post_id_multiple_2"); | |
603 | $this->select("additional_custom_post_id_multiple_2", "value=" . $profileId[1]); | |
604 | ||
605 | $this->waitForElementPresent("xpath=//div[@id='registration_screen']/table[3]//tbody/tr[2]/td[2]/span/a[text()='add profile']"); | |
606 | $this->click("xpath=//div[@id='registration_screen']/table[3]//tbody/tr[2]/td[2]/span/a[text()='add profile']"); | |
607 | $this->waitForElementPresent("additional_custom_post_id_multiple_3"); | |
608 | $this->select("additional_custom_post_id_multiple_3", "value=" . $profileId[2]); | |
609 | ||
610 | $this->waitForElementPresent("xpath=//div[@id='registration_screen']/table[3]//tbody/tr[2]/td[2]/span/a[text()='add profile']"); | |
611 | $this->click("xpath=//div[@id='registration_screen']/table[3]//tbody/tr[2]/td[2]/span/a[text()='add profile']"); | |
612 | $this->waitForElementPresent("additional_custom_post_id_multiple_4"); | |
613 | $this->select("additional_custom_post_id_multiple_4", "value=" . $profileId[3]); | |
614 | ||
615 | $this->click("CIVICRM_QFID_1_is_email_confirm"); | |
616 | $this->type("confirm_from_name", "TestEvent"); | |
617 | $this->type("confirm_from_email", "testevent@test.com"); | |
618 | $this->click("_qf_Registration_upload-bottom"); | |
619 | ||
620 | // Wait for "saved" status msg | |
ed174dea | 621 | $this->waitForElementPresent("_qf_Registration_upload-bottom"); |
622 | $this->waitForText('crm-notification-container', "'Online Registration' information has been saved."); | |
6a488035 | 623 | |
a471a3b6 | 624 | return $this->urlArg('id'); |
6a488035 TO |
625 | } |
626 | ||
4cbe18b8 EM |
627 | /** |
628 | * @param $eventPageId | |
629 | * @param $customId | |
630 | * @param $firstName | |
631 | * @param $lastName | |
632 | * @param $participantfname | |
633 | * @param $participantlname | |
634 | * @param $email1 | |
635 | * @param $email2 | |
636 | */ | |
6a488035 | 637 | function _testEventRegistration($eventPageId, $customId, $firstName, $lastName, |
d0711ea4 | 638 | $participantfname, $participantlname, $email1, $email2 |
6a488035 | 639 | ) { |
42daf119 | 640 | $this->openCiviPage("event/register", "id={$eventPageId}&reset=1", "_qf_Register_upload-bottom"); |
6a488035 TO |
641 | $this->select("additional_participants", "value=1"); |
642 | ||
643 | $this->type("email-Primary", $email1); | |
644 | $this->type("first_name", $firstName); | |
645 | $this->type("last_name", $lastName); | |
646 | $this->type("street_address-1", "Test street addres"); | |
647 | $this->type("city-1", "Mumbai"); | |
648 | $this->type("postal_code-1", "2354"); | |
649 | $this->select("state_province-1", "value=1001"); | |
650 | ||
651 | // Credit Card Info | |
652 | $this->select("credit_card_type", "value=Visa"); | |
653 | $this->type("credit_card_number", "4111111111111111"); | |
654 | $this->type("cvv2", "000"); | |
655 | $this->select("credit_card_exp_date[M]", "value=1"); | |
656 | $this->select("credit_card_exp_date[Y]", "value=2020"); | |
657 | ||
658 | //Billing Info | |
659 | $this->type("billing_first_name", $firstName . 'billing'); | |
660 | $this->type("billing_last_name", $lastName . 'billing'); | |
661 | $this->type("billing_street_address-5", "0121 Mount Highschool."); | |
662 | $this->type(" billing_city-5", "Shangai"); | |
663 | $this->select("billing_country_id-5", "value=1228"); | |
664 | $this->select("billing_state_province_id-5", "value=1004"); | |
665 | $this->type("billing_postal_code-5", "94129"); | |
666 | ||
667 | $this->type("current_employer", "ABCD"); | |
668 | $this->type("job_title", "Painter"); | |
669 | $this->type("nick_name", "Nick"); | |
670 | $this->type("url-1", "http://www.test.com"); | |
671 | ||
672 | $this->type("street_address-Primary", "Primary street address"); | |
673 | $this->type("city-Primary", "primecity"); | |
674 | $this->type("phone-Primary-1", "98667764"); | |
675 | $this->type("postal_code-Primary", "6548"); | |
676 | ||
677 | $this->type("custom_" . $customId[0], "fname_custom1"); | |
678 | $this->type("custom_" . $customId[1], "mname_custom1"); | |
679 | $this->type("custom_" . $customId[2], "lname_custom1"); | |
680 | ||
681 | $this->type("middle_name", "xyz"); | |
83739141 | 682 | $this->click("name=gender_id value=2"); |
6a488035 TO |
683 | $this->select("participant_role", "value=2"); |
684 | ||
685 | $this->click("_qf_Register_upload-bottom"); | |
686 | $this->waitForElementPresent("_qf_Participant_1_next-Array"); | |
687 | ||
688 | $this->type("email-Primary", $email2); | |
689 | $this->type("first_name", $participantfname); | |
690 | $this->type("last_name", $participantlname); | |
691 | $this->type("street_address-1", "participant street addres"); | |
692 | $this->type("city-1", "pune"); | |
693 | $this->type("postal_code-1", "2354"); | |
694 | $this->select("state_province-1", "value=1001"); | |
695 | ||
696 | $this->type("current_employer", "ABCD"); | |
697 | $this->type("job_title", "Potato picker"); | |
698 | ||
699 | $this->type("custom_" . $customId[0], "participant_custom1"); | |
700 | $this->type("custom_" . $customId[1], "participant_custom1"); | |
701 | $this->type("custom_" . $customId[2], "participant_custom1"); | |
702 | ||
703 | $this->type("street_address-Primary", "Primary street address"); | |
704 | $this->type("city-Primary", "primecity"); | |
705 | $this->type("phone-Primary-1", "98667764"); | |
706 | $this->type("postal_code-Primary", "6548"); | |
707 | ||
708 | $this->type("nick_name", "Nick1"); | |
709 | $this->type("url-1", "http://www.part.com"); | |
710 | ||
225a8648 | 711 | $this->clickLink("_qf_Participant_1_next-Array", "_qf_Confirm_next-bottom"); |
6a488035 TO |
712 | $this->click("_qf_Confirm_next-bottom"); |
713 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
714 | } | |
715 | ||
4cbe18b8 EM |
716 | /** |
717 | * @param $eventPageId | |
718 | * @param $customId | |
719 | * @param $firstName2 | |
720 | * @param $lastName2 | |
721 | * @param $participantfname2 | |
722 | * @param $participantlname2 | |
723 | * @param $email3 | |
724 | * @param $email4 | |
725 | */ | |
6a488035 | 726 | function _testEventRegistrationAfterRemoving($eventPageId, $customId, $firstName2, $lastName2, $participantfname2, $participantlname2, $email3, $email4) { |
42daf119 | 727 | $this->openCiviPage("event/register", "id={$eventPageId}&reset=1", "_qf_Register_upload-bottom"); |
6a488035 TO |
728 | $this->select("additional_participants", "value=1"); |
729 | ||
730 | $this->type("email-Primary", $email4); | |
731 | $this->type("first_name", $firstName2); | |
732 | $this->type("last_name", $lastName2); | |
733 | $this->type("street_address-1", "Test street addres"); | |
734 | $this->type("city-1", "Mumbai"); | |
735 | $this->type("postal_code-1", "2354"); | |
736 | $this->select("state_province-1", "value=1001"); | |
737 | ||
738 | // Credit Card Info | |
739 | $this->select("credit_card_type", "value=Visa"); | |
740 | $this->type("credit_card_number", "4111111111111111"); | |
741 | $this->type("cvv2", "000"); | |
742 | $this->select("credit_card_exp_date[M]", "value=1"); | |
743 | $this->select("credit_card_exp_date[Y]", "value=2020"); | |
744 | ||
745 | //Billing Info | |
746 | $this->type("billing_first_name", $firstName2 . 'billing'); | |
747 | $this->type("billing_last_name", $lastName2 . 'billing'); | |
748 | $this->type("billing_street_address-5", "0121 Mount Highschool."); | |
749 | $this->type(" billing_city-5", "Shangai"); | |
750 | $this->select("billing_country_id-5", "value=1228"); | |
751 | $this->select("billing_state_province_id-5", "value=1004"); | |
752 | $this->type("billing_postal_code-5", "94129"); | |
753 | ||
754 | $this->type("current_employer", "ABCD"); | |
755 | $this->type("job_title", "Painter"); | |
756 | ||
757 | $this->type("nick_name", "Nickkk"); | |
758 | $this->type("url-1", "http://www.testweb.com"); | |
759 | ||
760 | $this->type("street_address-Primary", "Primary street address"); | |
761 | $this->type("city-Primary", "primecity"); | |
762 | $this->type("phone-Primary-1", "9866776422"); | |
763 | $this->type("postal_code-Primary", "6534"); | |
764 | ||
765 | $this->type("custom_" . $customId[0], "fname_custom1"); | |
766 | $this->type("custom_" . $customId[1], "mname_custom1"); | |
767 | $this->type("custom_" . $customId[2], "lname_custom1"); | |
768 | ||
769 | $this->type("middle_name", "xyz"); | |
83739141 | 770 | $this->click("name=gender_id value=2"); |
6a488035 TO |
771 | $this->select("participant_role", "value=2"); |
772 | ||
773 | $this->click("_qf_Register_upload-bottom"); | |
774 | $this->waitForElementPresent("_qf_Participant_1_next-Array"); | |
775 | ||
776 | $this->type("email-Primary", $email3); | |
777 | $this->type("first_name", $participantfname2); | |
778 | $this->type("last_name", $participantlname2); | |
779 | $this->type("street_address-1", "participant street addres"); | |
780 | $this->type("city-1", "pune"); | |
781 | $this->type("postal_code-1", "2354"); | |
782 | $this->select("state_province-1", "value=1001"); | |
783 | ||
784 | $this->type("current_employer", "ABCD"); | |
785 | $this->type("job_title", "BATCHER"); | |
786 | ||
225a8648 | 787 | $this->clickLink("_qf_Participant_1_next-Array", "_qf_Confirm_next-bottom"); |
6a488035 TO |
788 | $this->click("_qf_Confirm_next-bottom"); |
789 | } | |
76e86fd8 | 790 | |
4cbe18b8 EM |
791 | /** |
792 | * @return array|string | |
793 | */ | |
d0711ea4 | 794 | function _addEmailField() { |
6a488035 | 795 | //add email field in name and address profile |
42daf119 | 796 | $this->openCiviPage('admin/uf/group/field/add', 'reset=1&action=add&gid=1', "_qf_Field_next-bottom"); |
6a488035 TO |
797 | $this->select("field_name[0]", "value=Contact"); |
798 | $this->select("field_name[1]", "value=email"); | |
799 | $this->select("field_name[2]", "value=0"); | |
800 | $this->click('_qf_Field_next-bottom'); | |
801 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
76e86fd8 | 802 | |
6a488035 TO |
803 | $cfId = ""; |
804 | //check wheather webtest has created the field | |
d0711ea4 | 805 | if ($this->assertElementNotContainsText('crm-notification-container', "The selected field was not added. It already exists in this profile")) { |
6a488035 TO |
806 | $this->waitForElementPresent("xpath=//div[@id='field_page']//table/tbody//tr[8]/td[9]/span/a[text()='Edit']"); |
807 | $cfId = explode('&id=', $this->getAttribute("xpath=//div[@id='field_page']//table/tbody//tr[8]/td[9]/span/a[text()='Edit']/@href")); | |
808 | $cfId = $cfId[1]; | |
809 | } | |
810 | return $cfId; | |
811 | } | |
76e86fd8 | 812 | |
4cbe18b8 EM |
813 | /** |
814 | * @param $cfId | |
815 | */ | |
76e86fd8 | 816 | function _removeEmailField($cfId) { |
071a6d2e | 817 | $this->openCiviPage("admin/uf/group/field", "action=delete&id={$cfId}"); |
6a488035 TO |
818 | $this->click("_qf_Field_next-bottom"); |
819 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
820 | } | |
232624b1 | 821 | } |