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_AddEventTest | |
31 | */ | |
6a488035 TO |
32 | class WebTest_Event_AddEventTest extends CiviSeleniumTestCase { |
33 | ||
34 | protected function setUp() { | |
35 | parent::setUp(); | |
36 | } | |
37 | ||
38 | function testAddPaidEventNoTemplate() { | |
6a488035 TO |
39 | // Log in using webtestLogin() method |
40 | $this->webtestLogin(); | |
41 | ||
c3ad8633 CW |
42 | // Use default payment processor |
43 | $processorName = 'Test Processor'; | |
6a488035 TO |
44 | $this->webtestAddPaymentProcessor($processorName); |
45 | ||
071a6d2e | 46 | $this->openCiviPage("event/add", "reset=1&action=add"); |
6a488035 TO |
47 | |
48 | $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7); | |
49 | $eventDescription = "Here is a description for this conference."; | |
50 | $this->_testAddEventInfo($eventTitle, $eventDescription); | |
51 | ||
52 | $streetAddress = "100 Main Street"; | |
53 | $this->_testAddLocation($streetAddress); | |
54 | ||
55 | $this->_testAddReminder($eventTitle); | |
56 | ||
57 | $this->_testAddFees(FALSE, FALSE, $processorName); | |
58 | ||
59 | // intro text for registration page | |
60 | $registerIntro = "Fill in all the fields below and click Continue."; | |
61 | $multipleRegistrations = TRUE; | |
62 | $this->_testAddOnlineRegistration($registerIntro, $multipleRegistrations); | |
63 | ||
64 | $eventInfoStrings = array($eventTitle, $eventDescription, $streetAddress); | |
05f3c31c | 65 | $eventId = $this->_testVerifyEventInfo($eventTitle, $eventInfoStrings); |
6a488035 TO |
66 | |
67 | $registerStrings = array("225.00", "Member", "300.00", "Non-member", $registerIntro); | |
68 | $registerUrl = $this->_testVerifyRegisterPage($registerStrings); | |
69 | ||
70 | $numberRegistrations = 3; | |
71 | $anonymous = TRUE; | |
72 | $this->_testOnlineRegistration($registerUrl, $numberRegistrations, $anonymous); | |
6712d671 | 73 | |
05f3c31c DG |
74 | // Now test making a copy of the event |
75 | $this->webtestLogin(); | |
76 | $this->openCiviPage("event/manage", "reset=1&action=copy&id=$eventId"); | |
6712d671 | 77 | $this->_testVerifyEventInfo('Copy of ' . $eventTitle, $eventInfoStrings); |
78 | $this->_testVerifyRegisterPage($registerStrings); | |
6a488035 TO |
79 | } |
80 | ||
81 | function testAddPaidEventDiscount() { | |
6a488035 TO |
82 | |
83 | // Log in using webtestLogin() method | |
84 | $this->webtestLogin(); | |
85 | ||
c3ad8633 CW |
86 | // Use default payment processor |
87 | $processorName = 'Test Processor'; | |
6a488035 TO |
88 | $this->webtestAddPaymentProcessor($processorName); |
89 | ||
071a6d2e | 90 | $this->openCiviPage("event/add", "reset=1&action=add"); |
6a488035 TO |
91 | |
92 | $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7); | |
93 | $eventDescription = "Here is a description for this conference."; | |
94 | $this->_testAddEventInfo($eventTitle, $eventDescription); | |
95 | ||
96 | $streetAddress = "100 Main Street"; | |
97 | $this->_testAddLocation($streetAddress); | |
98 | ||
99 | $this->_testAddReminder($eventTitle); | |
100 | ||
101 | $this->_testAddFees(TRUE, FALSE, $processorName); | |
102 | ||
103 | // intro text for registration page | |
104 | $registerIntro = "Fill in all the fields below and click Continue."; | |
105 | $multipleRegistrations = TRUE; | |
106 | $this->_testAddOnlineRegistration($registerIntro, $multipleRegistrations); | |
107 | ||
76e86fd8 CW |
108 | $discountFees = array("225.00", "300.00"); |
109 | ||
6a488035 TO |
110 | $eventInfoStrings = array($eventTitle, $eventDescription, $streetAddress); |
111 | $this->_testVerifyEventInfo($eventTitle, $eventInfoStrings, $discountFees); | |
112 | ||
113 | $registerStrings = array_push($discountFees, "Member", "Non-member", $registerIntro); | |
114 | $registerUrl = $this->_testVerifyRegisterPage($registerStrings); | |
115 | ||
116 | $numberRegistrations = 3; | |
117 | $anonymous = TRUE; | |
118 | $this->_testOnlineRegistration($registerUrl, $numberRegistrations, $anonymous); | |
119 | } | |
120 | ||
121 | function testDeletePriceSetDiscount() { | |
6a488035 TO |
122 | |
123 | // Log in using webtestLogin() method | |
124 | $this->webtestLogin(); | |
125 | ||
c3ad8633 CW |
126 | // Use default payment processor |
127 | $processorName = 'Test Processor'; | |
6a488035 TO |
128 | $this->webtestAddPaymentProcessor($processorName); |
129 | ||
071a6d2e | 130 | $this->openCiviPage("event/add", "reset=1&action=add"); |
6a488035 TO |
131 | |
132 | $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7); | |
133 | $eventDescription = "Here is a description for this conference."; | |
134 | $this->_testAddEventInfo($eventTitle, $eventDescription); | |
135 | ||
136 | $streetAddress = "100 Main Street"; | |
137 | $this->_testAddLocation($streetAddress); | |
138 | ||
139 | //Add two discounts | |
140 | $discount = $this->_testAddFees(TRUE, FALSE, $processorName, TRUE); | |
141 | ||
142 | // intro text for registration page | |
143 | $registerIntro = "Fill in all the fields below and click Continue."; | |
144 | $multipleRegistrations = TRUE; | |
145 | $this->_testAddOnlineRegistration($registerIntro, $multipleRegistrations); | |
146 | ||
76e86fd8 CW |
147 | $discountFees = array("225.00", "300.00"); |
148 | ||
6a488035 TO |
149 | $eventInfoStrings = array($eventTitle, $eventDescription, $streetAddress); |
150 | $id = $this->_testVerifyEventInfo($eventTitle, $eventInfoStrings, $discountFees); | |
151 | ||
152 | $registerStrings = array_push($discountFees, "Member", "Non-member", $registerIntro); | |
153 | $registerUrl = $this->_testVerifyRegisterPage($registerStrings); | |
154 | ||
155 | //Add Price Set now | |
42daf119 | 156 | $this->openCiviPage("event/manage/fee", "reset=1&action=update&id=$id", "_qf_Fee_upload-bottom"); |
6a488035 | 157 | $this->click("xpath=//a[@id='quickconfig']"); |
038f0330 | 158 | $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']"); |
c494e713 | 159 | $this->click("xpath=//div[@class='ui-dialog-buttonset']//button/span[text()='Continue']"); |
76e86fd8 | 160 | |
6a488035 | 161 | //Assert quick config change and discount deletion |
071a6d2e | 162 | $this->openCiviPage("admin/price", "reset=1"); |
c494e713 RK |
163 | foreach ($discount as $key => $val) { |
164 | $this->waitForTextPresent($val); | |
165 | } | |
6a488035 TO |
166 | } |
167 | ||
168 | function testAddDeleteEventDiscount() { | |
6a488035 TO |
169 | |
170 | // Log in using webtestLogin() method | |
171 | $this->webtestLogin(); | |
172 | ||
c3ad8633 CW |
173 | // Use default payment processor |
174 | $processorName = 'Test Processor'; | |
6a488035 TO |
175 | $this->webtestAddPaymentProcessor($processorName); |
176 | ||
071a6d2e | 177 | $this->openCiviPage("event/add", "reset=1&action=add"); |
6a488035 TO |
178 | |
179 | $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7); | |
180 | $eventDescription = "Here is a description for this conference."; | |
181 | $this->_testAddEventInfo($eventTitle, $eventDescription); | |
182 | ||
183 | $streetAddress = "100 Main Street"; | |
184 | $this->_testAddLocation($streetAddress); | |
185 | ||
186 | //Add two discounts | |
187 | $discount = $this->_testAddFees(TRUE, FALSE, $processorName, TRUE); | |
188 | ||
189 | // intro text for registration page | |
190 | $registerIntro = "Fill in all the fields below and click Continue."; | |
191 | $multipleRegistrations = TRUE; | |
192 | $this->_testAddOnlineRegistration($registerIntro, $multipleRegistrations); | |
193 | ||
76e86fd8 CW |
194 | $discountFees = array("225.00", "300.00"); |
195 | ||
6a488035 TO |
196 | $eventInfoStrings = array($eventTitle, $eventDescription, $streetAddress); |
197 | $id = $this->_testVerifyEventInfo($eventTitle, $eventInfoStrings, $discountFees); | |
198 | ||
199 | $registerStrings = array_push($discountFees, "Member", "Non-member", $registerIntro); | |
200 | $registerUrl = $this->_testVerifyRegisterPage($registerStrings); | |
201 | //Delete the discount | |
202 | $this->_deleteDiscount($id, $eventTitle, $discount); | |
203 | } | |
204 | ||
4cbe18b8 | 205 | /** |
100fef9d | 206 | * @param int $id |
4cbe18b8 EM |
207 | * @param $eventTitle |
208 | * @param $discount | |
209 | */ | |
6a488035 | 210 | function _deleteDiscount($id, $eventTitle, $discount) { |
42daf119 | 211 | $this->openCiviPage("event/manage/fee", "reset=1&action=update&id=$id", "_qf_Fee_upload-bottom"); |
6a488035 | 212 | $this->type("discount_name_2", ""); |
60709d21 JP |
213 | $this->click("xpath=//tr[@id='discount_2']/td[3]/a"); |
214 | $this->click("xpath=//tr[@id='discount_2']/td[4]/a"); | |
6a488035 TO |
215 | $this->type("discounted_value_1_2", ""); |
216 | $this->type("discounted_value_2_2", ""); | |
217 | $this->click("_qf_Fee_upload-bottom"); | |
60709d21 | 218 | $this->waitForText('crm-notification-container', "'Fees' information has been saved."); |
6a488035 | 219 | //Assertions |
071a6d2e | 220 | $this->openCiviPage("admin/price", "reset=1"); |
6a488035 TO |
221 | $this->assertStringsPresent($discount[1]); |
222 | } | |
223 | ||
224 | function testAddPaidEventWithTemplate() { | |
6a488035 TO |
225 | |
226 | // Log in using webtestLogin() method | |
227 | $this->webtestLogin(); | |
228 | ||
c3ad8633 CW |
229 | // Use default payment processor |
230 | $processorName = 'Test Processor'; | |
6a488035 TO |
231 | $this->webtestAddPaymentProcessor($processorName); |
232 | ||
071a6d2e | 233 | $this->openCiviPage("event/add", "reset=1&action=add"); |
6a488035 TO |
234 | |
235 | $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7); | |
236 | $eventDescription = "Here is a description for this conference."; | |
237 | // Select paid online registration template. | |
238 | $templateID = 6; | |
239 | $eventTypeID = 1; | |
240 | $this->_testAddEventInfoFromTemplate($eventTitle, $eventDescription, $templateID, $eventTypeID); | |
241 | ||
242 | $streetAddress = "100 Main Street"; | |
243 | $this->_testAddLocation($streetAddress); | |
244 | ||
245 | $this->_testAddFees(FALSE, FALSE, $processorName); | |
246 | ||
247 | // intro text for registration page | |
248 | $registerIntro = "Fill in all the fields below and click Continue."; | |
249 | $this->_testAddOnlineRegistration($registerIntro); | |
250 | ||
251 | // $eventInfoStrings = array( $eventTitle, $eventDescription, $streetAddress ); | |
252 | $eventInfoStrings = array($eventTitle, $streetAddress); | |
253 | $this->_testVerifyEventInfo($eventTitle, $eventInfoStrings); | |
254 | ||
255 | $registerStrings = array("225.00", "Member", "300.00", "Non-member", $registerIntro); | |
256 | $this->_testVerifyRegisterPage($registerStrings); | |
257 | } | |
258 | ||
259 | function testAddFreeEventWithTemplate() { | |
6a488035 TO |
260 | |
261 | // Log in using webtestLogin() method | |
262 | $this->webtestLogin(); | |
42daf119 | 263 | |
071a6d2e | 264 | $this->openCiviPage("event/add", "reset=1&action=add"); |
76e86fd8 | 265 | |
6a488035 TO |
266 | $eventTitle = 'My Free Meeting - ' . substr(sha1(rand()), 0, 7); |
267 | $eventDescription = "Here is a description for this free meeting."; | |
268 | // Select "Free Meeting with Online Registration" template (id = 5). | |
269 | $templateID = 5; | |
76e86fd8 CW |
270 | $eventTypeID = 4; |
271 | ||
6a488035 | 272 | $this->_testAddEventInfoFromTemplate($eventTitle, $eventDescription, $templateID, $eventTypeID); |
76e86fd8 CW |
273 | |
274 | $streetAddress = "100 Main Street"; | |
275 | ||
276 | $this->_testAddLocation($streetAddress); | |
6a488035 TO |
277 | |
278 | // Go to Fees tab and check that Paid Event is false (No) | |
279 | $this->click("link=Fees"); | |
280 | $this->waitForElementPresent("_qf_Fee_upload-bottom"); | |
281 | $this->verifyChecked("CIVICRM_QFID_0_is_monetary"); | |
282 | ||
283 | // intro text for registration page | |
284 | $registerIntro = "Fill in all the fields below and click Continue."; | |
285 | $this->_testAddOnlineRegistration($registerIntro); | |
286 | ||
287 | // $eventInfoStrings = array( $eventTitle, $eventDescription, $streetAddress ); | |
288 | $eventInfoStrings = array($eventTitle, $streetAddress); | |
289 | $this->_testVerifyEventInfo($eventTitle, $eventInfoStrings); | |
290 | ||
291 | $registerStrings = array($registerIntro); | |
292 | $this->_testVerifyRegisterPage($registerStrings); | |
293 | // make sure paid_event div is NOT present since this is a free event | |
294 | $this->verifyElementNotPresent("css=div.paid_event-section"); | |
295 | } | |
296 | ||
0dce9149 | 297 | function testUnpaidPaid() { |
0dce9149 PJ |
298 | // Log in using webtestLogin() method |
299 | $this->webtestLogin(); | |
300 | ||
071a6d2e | 301 | $this->openCiviPage("event/add", "reset=1&action=add"); |
0dce9149 PJ |
302 | $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7); |
303 | $eventDescription = "Here is a description for this conference."; | |
304 | $this->_testAddEventInfo($eventTitle, $eventDescription); | |
305 | ||
306 | //add fee section with pay later checked | |
307 | $this->_testAddFees(FALSE, FALSE, NULL, FALSE, TRUE); | |
308 | ||
309 | //make the event unpaid | |
310 | $this->waitForElementPresent("_qf_Fee_upload-bottom"); | |
311 | $this->assertChecked('is_pay_later'); | |
312 | $this->click("CIVICRM_QFID_0_is_monetary"); | |
0dce9149 | 313 | |
50d95825 CW |
314 | $this->click("_qf_Fee_upload-bottom"); |
315 | $this->waitForText('crm-notification-container', "'Fees' information has been saved."); | |
316 | $this->waitForAjaxContent(); | |
3e60ff7f | 317 | |
0dce9149 PJ |
318 | //check if pay later option is disabled |
319 | $this->click('CIVICRM_QFID_1_is_monetary'); | |
0dce9149 PJ |
320 | $this->waitForElementPresent('is_pay_later'); |
321 | $this->assertNotChecked('is_pay_later'); | |
322 | } | |
323 | ||
c4e6d4e8 PJ |
324 | function testAjaxCustomGroupLoad() { |
325 | $this->webtestLogin(); | |
326 | ||
327 | $triggerElement = array('name' => 'event_type_id', 'type' => 'select'); | |
328 | $customSets = array( | |
329 | array('entity' => 'Event', 'subEntity' => 'Conference', 'triggerElement' => $triggerElement), | |
330 | ); | |
331 | ||
332 | $pageUrl = array('url' => 'event/add', 'args' => "reset=1&action=add"); | |
333 | $this->customFieldSetLoadOnTheFlyCheck($customSets, $pageUrl); | |
334 | } | |
335 | ||
4cbe18b8 EM |
336 | /** |
337 | * @param $eventTitle | |
338 | * @param $eventDescription | |
339 | */ | |
6a488035 | 340 | function _testAddEventInfo($eventTitle, $eventDescription) { |
6a488035 TO |
341 | $this->waitForElementPresent("_qf_EventInfo_upload-bottom"); |
342 | ||
6a488035 TO |
343 | $this->select("event_type_id", "value=1"); |
344 | ||
345 | // Attendee role s/b selected now. | |
346 | $this->select("default_role_id", "value=1"); | |
347 | ||
348 | // Enter Event Title, Summary and Description | |
349 | $this->type("title", $eventTitle); | |
350 | $this->type("summary", "This is a great conference. Sign up now!"); | |
351 | ||
352 | // Type description in ckEditor (fieldname, text to type, editor) | |
353 | $this->fillRichTextField("description", $eventDescription, 'CKEditor'); | |
354 | ||
355 | // Choose Start and End dates. | |
356 | // Using helper webtestFillDate function. | |
357 | $this->webtestFillDateTime("start_date", "+1 week"); | |
358 | $this->webtestFillDateTime("end_date", "+1 week 1 day 8 hours "); | |
359 | ||
360 | $this->type("max_participants", "50"); | |
361 | $this->click("is_map"); | |
362 | $this->click("is_public"); | |
50d95825 | 363 | $this->clickLink("_qf_EventInfo_upload-bottom"); |
6a488035 TO |
364 | } |
365 | ||
4cbe18b8 EM |
366 | /** |
367 | * @param $eventTitle | |
368 | * @param $eventDescription | |
100fef9d CW |
369 | * @param int $templateID |
370 | * @param int $eventTypeID | |
4cbe18b8 | 371 | */ |
6a488035 | 372 | function _testAddEventInfoFromTemplate($eventTitle, $eventDescription, $templateID, $eventTypeID) { |
6a488035 | 373 | $this->waitForElementPresent("_qf_EventInfo_upload-bottom"); |
42daf119 | 374 | |
6a488035 | 375 | // Select event template. Use option value, not label - since labels can be translated and test would fail |
76e86fd8 | 376 | $this->select("template_id", "value={$templateID}"); |
6a488035 | 377 | |
50d95825 CW |
378 | // Wait for event type to be filled in (since page refreshes) |
379 | $this->waitForAjaxContent(); | |
76e86fd8 | 380 | $this->verifySelectedValue("event_type_id", $eventTypeID); |
6a488035 TO |
381 | |
382 | // Attendee role s/b selected now. | |
383 | $this->verifySelectedValue("default_role_id", "1"); | |
76e86fd8 | 384 | |
6a488035 | 385 | // Enter Event Title, Summary and Description |
76e86fd8 CW |
386 | $this->type("title", $eventTitle); |
387 | ||
6a488035 TO |
388 | $this->type("summary", "This is a great conference. Sign up now!"); |
389 | ||
390 | // Type description in ckEditor (fieldname, text to type, editor) | |
391 | $this->fillRichTextField("description", $eventDescription, 'CKEditor'); | |
392 | ||
393 | // Choose Start and End dates. | |
394 | // Using helper webtestFillDate function. | |
395 | $this->webtestFillDateTime("start_date", "+1 week"); | |
396 | $this->webtestFillDateTime("end_date", "+1 week 1 day 8 hours "); | |
397 | ||
398 | $this->type("max_participants", "50"); | |
399 | $this->click("is_map"); | |
50d95825 | 400 | $this->clickLink("_qf_EventInfo_upload-bottom"); |
6a488035 TO |
401 | } |
402 | ||
4cbe18b8 EM |
403 | /** |
404 | * @param $streetAddress | |
405 | */ | |
6a488035 TO |
406 | function _testAddLocation($streetAddress) { |
407 | // Wait for Location tab form to load | |
50d95825 | 408 | $this->waitForAjaxContent(); |
6a488035 TO |
409 | $this->waitForElementPresent("_qf_Location_upload-bottom"); |
410 | ||
411 | // Fill in address fields | |
412 | $streetAddress = "100 Main Street"; | |
413 | $this->type("address_1_street_address", $streetAddress); | |
414 | $this->type("address_1_city", "San Francisco"); | |
415 | $this->type("address_1_postal_code", "94117"); | |
3e60ff7f | 416 | $this->select('address_1_country_id', 'United States'); |
6a488035 TO |
417 | $this->select("address_1_state_province_id", "value=1004"); |
418 | $this->type("email_1_email", "info@civicrm.org"); | |
419 | ||
420 | $this->click("_qf_Location_upload-bottom"); | |
421 | ||
422 | // Wait for "saved" status msg | |
02e08b2e | 423 | $this->waitForText('crm-notification-container', "'Event Location' information has been saved."); |
6a488035 TO |
424 | } |
425 | ||
4cbe18b8 EM |
426 | /** |
427 | * @param bool $discount | |
428 | * @param bool $priceSet | |
429 | * @param string $processorName | |
430 | * @param bool $double | |
431 | * @param bool $payLater | |
432 | * | |
433 | * @return array | |
434 | */ | |
0dce9149 | 435 | function _testAddFees($discount = FALSE, $priceSet = FALSE, $processorName = "PP Pro", $double = FALSE, $payLater = FALSE) { |
6a488035 TO |
436 | $discount1 = "Early-bird" . substr(sha1(rand()), 0, 7); |
437 | $discount2 = ""; | |
438 | // Go to Fees tab | |
439 | $this->click("link=Fees"); | |
440 | $this->waitForElementPresent("_qf_Fee_upload-bottom"); | |
441 | $this->click("CIVICRM_QFID_1_is_monetary"); | |
0dce9149 PJ |
442 | |
443 | if ($payLater) { | |
02e08b2e | 444 | $this->click('is_pay_later'); |
8ca3d31e | 445 | $this->fillRichTextField('pay_later_receipt', 'testing later instructions'); |
0dce9149 PJ |
446 | } |
447 | else { | |
448 | $this->uncheck('is_pay_later'); | |
449 | } | |
450 | ||
451 | if ($processorName) { | |
2913f26f | 452 | $this->check("xpath=//tr[@class='crm-event-manage-fee-form-block-payment_processor']/td[2]/label[text()='$processorName']/../input"); |
0dce9149 | 453 | } |
6a488035 TO |
454 | $this->select("financial_type_id", "value=4"); |
455 | if ($priceSet) { | |
456 | // get one - TBD | |
457 | } | |
458 | else { | |
459 | $this->type("label_1", "Member"); | |
460 | $this->type("value_1", "225.00"); | |
461 | $this->type("label_2", "Non-member"); | |
462 | $this->type("value_2", "300.00"); | |
02e08b2e | 463 | $this->click("CIVICRM_QFID_1_6"); |
6a488035 TO |
464 | } |
465 | ||
466 | if ($discount) { | |
467 | // enter early bird discount fees | |
468 | $this->click("is_discount"); | |
469 | $this->waitForElementPresent("discount_name_1"); | |
470 | $this->type("discount_name_1", $discount1); | |
471 | $this->webtestFillDate("discount_start_date_1", "-3 week"); | |
472 | $this->webtestFillDate("discount_end_date_1", "-2 week"); | |
76e86fd8 CW |
473 | $this->clickLink("_qf_Fee_submit", "discounted_value_1_1"); |
474 | ||
6712d671 | 475 | $this->type("discounted_value_1_1", "225.00"); |
476 | $this->type("discounted_value_2_1", "300.00"); | |
6a488035 TO |
477 | |
478 | if ($double) { | |
479 | $discount2 = "Early-bird" . substr(sha1(rand()), 0, 7); | |
480 | // enter early bird discount fees | |
481 | $this->click("link=another discount set"); | |
482 | $this->waitForElementPresent("discount_name_2"); | |
483 | $this->type("discount_name_2", $discount2); | |
484 | $this->webtestFillDate("discount_start_date_2", "-1 week"); | |
485 | $this->webtestFillDate("discount_end_date_2", "+1 week"); | |
225a8648 | 486 | $this->clickLink("_qf_Fee_submit", "discounted_value_2_1"); |
6712d671 | 487 | $this->type("discounted_value_1_2", "225.00"); |
488 | $this->type("discounted_value_2_2", "300.00"); | |
489 | } | |
6a488035 TO |
490 | $this->click("xpath=//fieldset[@id='discount']/fieldset/table/tbody/tr[2]/td[3]/input"); |
491 | } | |
492 | $this->click("_qf_Fee_upload-bottom"); | |
76e86fd8 | 493 | |
6a488035 | 494 | // Wait for "saved" status msg |
02e08b2e | 495 | $this->waitForText('crm-notification-container', "'Fees' information has been saved"); |
6a488035 TO |
496 | return array($discount1, $discount2); |
497 | } | |
498 | ||
4cbe18b8 EM |
499 | /** |
500 | * @param $registerIntro | |
501 | * @param bool $multipleRegistrations | |
502 | */ | |
6a488035 TO |
503 | function _testAddOnlineRegistration($registerIntro, $multipleRegistrations = FALSE) { |
504 | // Go to Online Registration tab | |
505 | $this->click("link=Online Registration"); | |
506 | $this->waitForElementPresent("_qf_Registration_upload-bottom"); | |
507 | ||
60709d21 JP |
508 | $isChecked = $this->isChecked('is_online_registration'); |
509 | if (!$isChecked) { | |
510 | $this->click("is_online_registration"); | |
511 | } | |
6a488035 TO |
512 | $this->assertChecked("is_online_registration"); |
513 | if ($multipleRegistrations) { | |
60709d21 JP |
514 | $isChecked = $this->isChecked('is_multiple_registrations'); |
515 | if (!$isChecked) { | |
516 | $this->click("is_multiple_registrations"); | |
517 | } | |
6a488035 TO |
518 | $this->assertChecked("is_multiple_registrations"); |
519 | } | |
520 | ||
02e08b2e | 521 | $this->fillRichTextField("intro_text", $registerIntro, 'CKEditor', TRUE); |
76e86fd8 | 522 | |
6a488035 TO |
523 | // enable confirmation email |
524 | $this->click("CIVICRM_QFID_1_is_email_confirm"); | |
76e86fd8 CW |
525 | $this->type("confirm_from_name", "Jane Doe"); |
526 | ||
6a488035 TO |
527 | $this->type("confirm_from_email", "jane.doe@example.org"); |
528 | ||
529 | $this->click("_qf_Registration_upload-bottom"); | |
02e08b2e | 530 | $this->waitForText('crm-notification-container', "'Online Registration' information has been saved."); |
6a488035 TO |
531 | } |
532 | ||
4cbe18b8 EM |
533 | /** |
534 | * @param $eventTitle | |
535 | * @param $eventInfoStrings | |
536 | * @param null $eventFees | |
537 | * | |
538 | * @return null | |
539 | */ | |
6a488035 TO |
540 | function _testVerifyEventInfo($eventTitle, $eventInfoStrings, $eventFees = NULL) { |
541 | // verify event input on info page | |
542 | // start at Manage Events listing | |
071a6d2e | 543 | $this->openCiviPage("event/manage", "reset=1"); |
6a488035 TO |
544 | $this->click("link=$eventTitle"); |
545 | ||
546 | // Look for Register button | |
547 | $this->waitForElementPresent("link=Register Now"); | |
548 | ||
549 | // Check for correct event info strings | |
550 | $this->assertStringsPresent($eventInfoStrings); | |
76e86fd8 | 551 | |
6a488035 TO |
552 | // Optionally verify event fees (especially for discounts) |
553 | if ($eventFees) { | |
76e86fd8 CW |
554 | $this->assertStringsPresent($eventFees); |
555 | ||
6a488035 | 556 | } |
a471a3b6 | 557 | return $this->urlArg('id'); |
6a488035 TO |
558 | } |
559 | ||
4cbe18b8 EM |
560 | /** |
561 | * @param $registerStrings | |
562 | * | |
563 | * @return string | |
564 | */ | |
6a488035 TO |
565 | function _testVerifyRegisterPage($registerStrings) { |
566 | // Go to Register page and check for intro text and fee levels | |
567 | $this->click("link=Register Now"); | |
568 | $this->waitForElementPresent("_qf_Register_upload-bottom"); | |
569 | $this->assertStringsPresent($registerStrings); | |
570 | return $this->getLocation(); | |
571 | } | |
572 | ||
4cbe18b8 EM |
573 | /** |
574 | * @param $registerUrl | |
575 | * @param int $numberRegistrations | |
576 | * @param bool $anonymous | |
577 | * @param bool $isPayLater | |
578 | * @param array $participantEmailInfo | |
579 | * @param null $paymentProcessor | |
580 | * | |
581 | * @return array | |
582 | */ | |
dc91d100 PJ |
583 | function _testOnlineRegistration($registerUrl, $numberRegistrations = 1, $anonymous = TRUE, $isPayLater = FALSE, $participantEmailInfo = array(), $paymentProcessor = NULL) { |
584 | $infoPassed = FALSE; | |
585 | if (!empty($participantEmailInfo)) { | |
586 | $infoPassed = TRUE; | |
587 | } | |
6a488035 | 588 | if ($anonymous) { |
42daf119 | 589 | $this->webtestLogout(); |
6a488035 | 590 | } |
4a2859ea | 591 | $primaryParticipantInfo = array(); |
6a488035 | 592 | $this->open($registerUrl); |
dc91d100 PJ |
593 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
594 | ||
57e9cdaf CW |
595 | $this->waitForElementPresent('additional_participants'); |
596 | ||
6a488035 | 597 | $this->select("additional_participants", "value=" . $numberRegistrations); |
dc91d100 | 598 | |
5480e9b2 | 599 | if ($infoPassed) { |
600 | $primaryParticipantInfo['first_name'] = $participantEmailInfo[0]['first_name']; | |
601 | $primaryParticipantInfo['last_name'] = $participantEmailInfo[0]['last_name']; | |
602 | $primaryParticipantInfo['email'] = $participantEmailInfo[0]['email']; | |
603 | } | |
604 | else { | |
605 | $primaryParticipantInfo['first_name'] = "Jane"; | |
606 | $primaryParticipantInfo['last_name'] = "Smith" . substr(sha1(rand()), 0, 7); | |
607 | $primaryParticipantInfo['email'] = "smith" . substr(sha1(rand()), 0, 7) . "@example.org"; | |
608 | } | |
609 | ||
8ca3d31e | 610 | $this->type("first_name", $primaryParticipantInfo['first_name']); |
611 | $this->type("last_name", $primaryParticipantInfo['last_name']); | |
5480e9b2 | 612 | $this->type("email-Primary", $primaryParticipantInfo['email']); |
8ca3d31e | 613 | |
f9057553 | 614 | if (!$isPayLater) { |
dc91d100 | 615 | if ($paymentProcessor) { |
6712d671 | 616 | $paymentProcessorEle = $this->getAttribute("xpath=//form[@id='Register']//label[contains(text(), '{$paymentProcessor}')]/@for"); |
02e08b2e | 617 | $this->click($paymentProcessorEle); |
dc91d100 | 618 | } |
f9057553 PN |
619 | $this->select("credit_card_type", "value=Visa"); |
620 | $this->type("credit_card_number", "4111111111111111"); | |
621 | $this->type("cvv2", "000"); | |
622 | $this->select("credit_card_exp_date[M]", "value=1"); | |
623 | $this->select("credit_card_exp_date[Y]", "value=2020"); | |
4a2859ea PJ |
624 | $this->type("billing_first_name", $primaryParticipantInfo['first_name']); |
625 | $this->type("billing_last_name", $primaryParticipantInfo['last_name']); | |
f9057553 PN |
626 | $this->type("billing_street_address-5", "15 Main St."); |
627 | $this->type(" billing_city-5", "San Jose"); | |
628 | $this->select("billing_country_id-5", "value=1228"); | |
629 | $this->select("billing_state_province_id-5", "value=1004"); | |
630 | $this->type("billing_postal_code-5", "94129"); | |
631 | } | |
6a488035 TO |
632 | |
633 | $this->click("_qf_Register_upload-bottom"); | |
634 | ||
635 | if ($numberRegistrations > 1) { | |
636 | for ($i = 1; $i <= $numberRegistrations; $i++) { | |
637 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
638 | // Look for Skip button | |
639 | $this->waitForElementPresent("_qf_Participant_{$i}_next_skip-Array"); | |
8ca3d31e | 640 | |
5480e9b2 | 641 | if ($infoPassed) { |
642 | $this->type("first_name", $participantEmailInfo[$i]['first_name']); | |
643 | $this->type("last_name", $participantEmailInfo[$i]['last_name']); | |
644 | $this->type("email-Primary", $participantEmailInfo[$i]['email']); | |
645 | } | |
646 | else { | |
647 | $this->type("first_name", "Jane Add $i"); | |
648 | $this->type("last_name", "Smith" . substr(sha1(rand()), 0, 7)); | |
649 | $this->type("email-Primary", "smith" . substr(sha1(rand()), 0, 7) . "@example.org"); | |
650 | } | |
8ca3d31e | 651 | |
6a488035 TO |
652 | $this->click("_qf_Participant_{$i}_next"); |
653 | } | |
654 | } | |
655 | ||
656 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
657 | $this->waitForElementPresent("_qf_Confirm_next-bottom"); | |
6712d671 | 658 | $confirmStrings = array("Event Fee(s)"); |
659 | if (!$isPayLater) { | |
660 | $confirmStrings += array("Billing Name and Address", "Credit Card Information"); | |
f9057553 | 661 | } |
6a488035 TO |
662 | $this->assertStringsPresent($confirmStrings); |
663 | $this->click("_qf_Confirm_next-bottom"); | |
664 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
6712d671 | 665 | $thankStrings = array("Thank You for Registering", "Event Total"); |
666 | if (!$isPayLater) { | |
f9057553 PN |
667 | $thankStrings = array("Transaction Date"); |
668 | } | |
669 | else { | |
670 | $thankStrings += array("testing later instructions"); | |
671 | } | |
6a488035 | 672 | $this->assertStringsPresent($thankStrings); |
4a2859ea | 673 | return $primaryParticipantInfo; |
6a488035 TO |
674 | } |
675 | ||
4cbe18b8 EM |
676 | /** |
677 | * @param $eventTitle | |
678 | */ | |
6a488035 TO |
679 | function _testAddReminder($eventTitle) { |
680 | // Go to Schedule Reminders tab | |
681 | $this->click('css=li#tab_reminder a'); | |
02e08b2e DG |
682 | $this->waitForElementPresent("newScheduleReminder"); |
683 | $this->click("newScheduleReminder"); | |
6a488035 TO |
684 | $this->waitForElementPresent("_qf_ScheduleReminders_upload-bottom"); |
685 | $this->type("title", "Event Reminder for " . $eventTitle); | |
686 | $this->select('entity', 'label=Registered'); | |
687 | ||
688 | $this->select('start_action_offset', 'label=1'); | |
689 | $this->select('start_action_condition', 'label=after'); | |
690 | $this->click('is_repeat'); | |
691 | $this->select('repetition_frequency_interval', 'label=2'); | |
692 | $this->select('end_date', 'label=Event End Date'); | |
693 | $this->click('recipient'); | |
694 | $this->select('recipient', 'label=Participant Role'); | |
695 | // $this->select( 'recipient_listing', 'value=1' ); | |
696 | ||
697 | // Fill Subject | |
698 | $subject = 'subject' . substr(sha1(rand()), 0, 4); | |
699 | $this->type('subject', $subject); | |
700 | $this->fillRichTextField("html_message", "This is the test HTML version here!!!", 'CKEditor'); | |
701 | ||
702 | $this->type("text_message", "This is the test text version here!!!"); | |
703 | //click on save | |
704 | $this->click('_qf_ScheduleReminders_upload-bottom'); | |
705 | $this->waitForElementPresent("link=Add Reminder"); | |
706 | ||
707 | $this->waitForElementPresent("link=Edit"); | |
708 | ||
709 | $verifyText = array( | |
710 | 1 => 'Event Reminder for ' . $eventTitle, | |
711 | 3 => '1 hour after Event Start Date', | |
712 | 4 => 'Registered', | |
713 | 5 => 'Yes', | |
60709d21 | 714 | 6 => 'Yes', |
6a488035 TO |
715 | ); |
716 | ||
60709d21 | 717 | $this->waitForElementPresent("xpath=//form[@id='ScheduleReminders']//div[@id='option11_wrapper']"); |
6a488035 TO |
718 | //verify the fields for Event Reminder selector |
719 | foreach ($verifyText as $key => $value) { | |
60709d21 | 720 | $this->verifyText("xpath=//form[@id='ScheduleReminders']//div['option11_wrapper']/table/tbody/tr/td[$key]", $value); |
6a488035 TO |
721 | } |
722 | } | |
723 | ||
f9057553 PN |
724 | function testEventAddMultipleParticipant() { |
725 | // Log in using webtestLogin() method | |
4a2859ea | 726 | $this->webtestLogin(); |
f9057553 PN |
727 | $this->openCiviPage("event/add", "reset=1&action=add"); |
728 | ||
729 | $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7); | |
730 | $eventDescription = "Here is a description for this conference."; | |
731 | $this->_testAddEventInfo($eventTitle, $eventDescription); | |
732 | $streetAddress = "100 Main Street"; | |
733 | $this->_testAddLocation($streetAddress); | |
734 | ||
dc91d100 | 735 | $this->_testAddFees(FALSE, FALSE, "Test Processor", FALSE, TRUE); |
f9057553 PN |
736 | $registerIntro = "Fill in all the fields below and click Continue."; |
737 | $multipleRegistrations = TRUE; | |
738 | $this->_testAddOnlineRegistration($registerIntro, $multipleRegistrations); | |
739 | $eventInfoStrings = array($eventTitle, $eventDescription, $streetAddress); | |
dc91d100 | 740 | $eventId = $this->_testVerifyEventInfo($eventTitle, $eventInfoStrings); |
f9057553 PN |
741 | |
742 | $registerStrings = array("225.00", "Member", "300.00", "Non-member", $registerIntro); | |
743 | $registerUrl = $this->_testVerifyRegisterPage($registerStrings); | |
f9057553 PN |
744 | $numberRegistrations = 3; |
745 | $anonymous = TRUE; | |
dc91d100 PJ |
746 | |
747 | // CRM-12615 add additional participants and check email, amount | |
5480e9b2 | 748 | $primaryParticipant = array( |
749 | 'email' => "smith" . substr(sha1(rand()), 0, 7) . "@example.org", | |
750 | 'first_name' => "Kate", | |
751 | 'last_name' => "Simth" . substr(sha1(rand()), 0, 7), | |
752 | ); | |
753 | $secParticipant = array( | |
754 | 'email' => "smith" . substr(sha1(rand()), 0, 7) . "@example.org", | |
755 | 'first_name' => "Kate Add 1", | |
756 | 'last_name' => "Simth" . substr(sha1(rand()), 0, 7), | |
757 | ); | |
758 | $thirdParticipant = array( | |
759 | 'email' => "smith" . substr(sha1(rand()), 0, 7) . "@example.org", | |
760 | 'first_name' => "Kate Add 2", | |
761 | 'last_name' => "Simth" . substr(sha1(rand()), 0, 7), | |
762 | ); | |
763 | ||
dc91d100 | 764 | $participantEmails = array($primaryParticipant, $secParticipant, $thirdParticipant); |
4a2859ea | 765 | $addtlPart = array($secParticipant, $thirdParticipant); |
5480e9b2 | 766 | $primaryParticipantInfo = |
87a7b760 | 767 | $this->_testOnlineRegistration($registerUrl, 2, $anonymous, FALSE, $participantEmails, "Test Processor"); |
4a2859ea | 768 | $primaryDisplayName = "{$primaryParticipantInfo['first_name']} {$primaryParticipantInfo['last_name']}"; |
dc91d100 | 769 | $this->webtestLogin(); |
50d95825 | 770 | $this->openCiviPage("event/search", "reset=1"); |
60709d21 | 771 | $this->select2("event_id", $eventTitle, FALSE); |
dc91d100 | 772 | $this->clickLink('_qf_Search_refresh'); |
87a7b760 | 773 | $this->waitForElementPresent("xpath=//div[@id='participantSearch']/table/tbody//tr/td[3]/a"); |
5480e9b2 | 774 | $this->verifyText("xpath=//div[@id='participantSearch']/table/tbody//tr/td[3]/a[contains(text(), |
775 | '{$secParticipant['last_name']}, {$secParticipant['first_name']}')]/../../td[6]", preg_quote('225.00')); | |
776 | $this->verifyText("xpath=//div[@id='participantSearch']/table/tbody//tr/td[3]/a[contains(text(), | |
777 | '{$thirdParticipant['last_name']}, {$thirdParticipant['first_name']}')]/../../td[6]", preg_quote('225.00')); | |
4a2859ea PJ |
778 | |
779 | //CRM-12618 check edit screen of additional participant and ensuring record_contribution not present | |
780 | foreach ($addtlPart as $value) { | |
57d32317 | 781 | $this->clickAjaxLink("xpath=//div[@id='participantSearch']/table/tbody//tr/td[3]/a[contains(text(), |
5480e9b2 | 782 | '{$value['last_name']}, {$value['first_name']}')]/../../td[11]/span/a[2][contains(text(), 'Edit')]", |
50d95825 | 783 | '_qf_Participant_upload-bottom'); |
5480e9b2 | 784 | $this->assertTrue( |
785 | $this->isElementPresent("xpath=//tr[@class='crm-participant-form-block-registered-by']/td[2]/a[contains(text(), | |
786 | '$primaryDisplayName')]"), 'Registered By info is wrong on additional participant edit form'); | |
5480e9b2 | 787 | $this->assertTrue( |
788 | $this->isElementPresent( | |
789 | "xpath=//table/tbody/tr[@class='crm-participant-form-block-displayName']/td[2][contains(text(), | |
790 | '{$value['first_name']} {$value['last_name']}')]"), | |
4a2859ea PJ |
791 | 'Wrong Participant edit form' |
792 | ); | |
5480e9b2 | 793 | $this->assertFalse($this->isElementPresent('record_contribution'), |
794 | 'Record Payment checkbox showed up wrongly for additional participant edit screen'); | |
57e9cdaf | 795 | $this->click("_qf_Participant_cancel-top"); |
4a2859ea PJ |
796 | } |
797 | ||
dc91d100 PJ |
798 | //unselect the payment processor configured |
799 | $this->openCiviPage("event/manage/fee", "reset=1&action=update&id={$eventId}", '_qf_Fee_upload-bottom'); | |
800 | $this->click("xpath=//tr[@class='crm-event-manage-fee-form-block-payment_processor']/td[2]/label[text()='Test Processor']"); | |
60709d21 JP |
801 | $this->click("_qf_Fee_upload-bottom"); |
802 | $this->waitForText('crm-notification-container', "'Fees' information has been saved."); | |
dc91d100 | 803 | |
f9057553 PN |
804 | // add participant and 3 additional participant and change status of participant from edit participant |
805 | $this->_testOnlineRegistration($registerUrl, $numberRegistrations, $anonymous, TRUE); | |
dc91d100 | 806 | $this->webtestLogin(); |
f9057553 PN |
807 | |
808 | $this->openCiviPage("event/search?reset=1", "reset=1"); | |
60709d21 | 809 | $this->select2("event_id", $eventTitle, FALSE); |
f9057553 | 810 | $this->click("xpath=//td[@class='crm-event-form-block-participant_status']/div[@class='listing-box']//div/label[text()='Pending from pay later']"); |
57e9cdaf | 811 | $this->clickLink('_qf_Search_refresh'); |
4e38284c | 812 | $this->waitForElementPresent("xpath=//div[@id='participantSearch']/table/tbody//tr/td[11]/span/a[text()='Edit']"); |
57e9cdaf | 813 | |
60709d21 | 814 | $uRL = $this->getAttribute("xpath=//div[@id='participantSearch']/table/tbody//tr/td[11]/span/a[text()='Edit']@href"); |
f9057553 | 815 | $this->click("xpath=//div[@id='participantSearch']/table/tbody//tr/td[11]/span/a[text()='Edit']"); |
60709d21 | 816 | $this->waitForElementPresent("status_id"); |
f9057553 | 817 | $this->select('status_id', 'label=Registered'); |
60709d21 | 818 | $this->waitForElementPresent("record_contribution"); |
f9057553 | 819 | $this->click('record_contribution'); |
60709d21 | 820 | $this->waitForElementPresent("contribution_status_id"); |
f9057553 | 821 | $this->select('contribution_status_id', 'label=Completed'); |
60709d21 | 822 | $pID = $this->urlArg('id', $uRL); |
f9057553 PN |
823 | $contributionID = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $pID, 'contribution_id', 'participant_id'); |
824 | $this->click('_qf_Participant_upload-top'); | |
60709d21 | 825 | $this->waitForElementPresent("xpath=//div[@id='participantSearch']/table/tbody//tr/td[11]/span/a[text()='Edit']"); |
4e38284c | 826 | $this->waitForElementPresent("xpath=//div[@id='participantSearch']/table/tbody//tr/td[11]/span/a[text()='View']"); |
60709d21 | 827 | $this->click("xpath=//div[@id='participantSearch']/table/tbody//tr/td[11]/span/a[text()='View']"); |
57e9cdaf | 828 | $this->waitForElementPresent("css=.ui-dialog"); |
4e38284c | 829 | $this->waitForAjaxContent(); |
f9057553 | 830 | $this->verifyFinancialRecords($contributionID); |
6712d671 | 831 | |
f9057553 PN |
832 | // add participant and 3 additional participant and change status of participant from edit contribution |
833 | $this->_testOnlineRegistration($registerUrl, $numberRegistrations, $anonymous, TRUE); | |
6712d671 | 834 | $this->webtestLogin(); |
f9057553 | 835 | |
6712d671 | 836 | $this->openCiviPage("event/search?reset=1", "reset=1"); |
60709d21 | 837 | $this->select2("event_id", $eventTitle, FALSE); |
f9057553 | 838 | $this->click("xpath=//td[@class='crm-event-form-block-participant_status']/div[@class='listing-box']//div/label[text()='Pending from pay later']"); |
4e38284c | 839 | $this->clickLink('_qf_Search_refresh'); |
840 | $this->waitForElementPresent("xpath=//div[@id='participantSearch']/table/tbody//tr/td[11]/span/a[text()='View']"); | |
60709d21 | 841 | $uRL = $this->getAttribute("xpath=//div[@id='participantSearch']/table/tbody//tr/td[11]/span/a[text()='View']@href"); |
f9057553 | 842 | $this->click("xpath=//div[@id='participantSearch']/table/tbody//tr/td[11]/span/a[text()='View']"); |
60709d21 | 843 | $pID = $this->urlArg('id', $uRL); |
f9057553 | 844 | $contributionID = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $pID, 'contribution_id', 'participant_id'); |
60709d21 | 845 | $this->waitForElementPresent("xpath=//tr[@id='rowid$contributionID']/td[8]/span//a[text()='Edit']"); |
f9057553 | 846 | $this->click("xpath=//tr[@id='rowid$contributionID']/td[8]/span//a[text()='Edit']"); |
60709d21 | 847 | $this->waitForElementPresent("_qf_Contribution_upload-bottom"); |
f9057553 | 848 | $this->select('contribution_status_id', 'label=Completed'); |
60709d21 | 849 | $this->clickLink('_qf_Contribution_upload-bottom', '_qf_ParticipantView_cancel-bottom', FALSE); |
4e38284c | 850 | $this->waitForAjaxContent(); |
f9057553 PN |
851 | $this->verifyFinancialRecords($contributionID); |
852 | } | |
853 | ||
4cbe18b8 | 854 | /** |
100fef9d | 855 | * @param int $contributionID |
4cbe18b8 | 856 | */ |
f9057553 PN |
857 | function verifyFinancialRecords($contributionID) { |
858 | // check count for civicrm_contribution and civicrm_financial_item in civicrm_entity_financial_trxn | |
859 | $query = "SELECT COUNT(DISTINCT(c1.id)) civicrm_contribution, COUNT(c2.id) civicrm_financial_item FROM civicrm_entity_financial_trxn c1 | |
860 | LEFT JOIN civicrm_entity_financial_trxn c2 ON c1.financial_trxn_id = c2.financial_trxn_id AND c2.entity_table ='civicrm_financial_item' | |
861 | LEFT JOIN civicrm_financial_item cfi ON cfi.id = c2.entity_id | |
862 | WHERE c1.entity_table = 'civicrm_contribution' AND c1.entity_id = %1 AND cfi.status_id = 1"; | |
863 | $params = array(1 => array($contributionID, 'Integer')); | |
864 | $dao = CRM_Core_DAO::executeQuery($query, $params); | |
865 | $dao->fetch(); | |
866 | $this->assertEquals('2', $dao->civicrm_contribution, 'civicrm_financial_trxn count does not match'); | |
6712d671 | 867 | $this->assertEquals('8', $dao->civicrm_financial_item, 'civicrm_financial_item count does not match'); |
36b1f0cc | 868 | $query = "SELECT COUNT(cft.id) civicrm_financial_trxn FROM civicrm_entity_financial_trxn ceft |
869 | INNER JOIN civicrm_financial_trxn cft ON ceft.financial_trxn_id = cft.id | |
f9057553 PN |
870 | WHERE ceft.entity_id = %1 AND ceft.entity_table = 'civicrm_contribution'"; |
871 | $dao = CRM_Core_DAO::executeQuery($query, $params); | |
872 | $dao->fetch(); | |
873 | $this->assertEquals('2', $dao->civicrm_financial_trxn, 'civicrm_financial_trxn count does not match'); | |
874 | } | |
36b1f0cc | 875 | |
876 | function testEventApprovalRegistration() { | |
877 | $this->webtestLogin(); | |
878 | ||
879 | //Participant Status | |
880 | $this->openCiviPage("admin/participant_status", "reset=1&action=browse"); | |
881 | $this->_testEnableParticipantStatuses('Awaiting approval'); | |
882 | $this->isElementPresent("xpath=//td[@class='crm-particpant-label'][contains(text(), 'Awaiting approval')]/../td[9]/span/a[2][text()='Disable']"); | |
883 | $this->_testEnableParticipantStatuses('Pending from approval'); | |
884 | $this->isElementPresent("xpath=//td[@class='crm-particpant-label'][contains(text(), 'Pending from approval')]/../td[9]/span/a[2][text()='Disable']"); | |
885 | $this->_testEnableParticipantStatuses('Rejected'); | |
886 | $this->isElementPresent("xpath=//td[@class='crm-particpant-label'][contains(text(), 'Rejected')]/../td[9]/span/a[2][text()='Disable']"); | |
887 | ||
888 | //Create New Event | |
889 | ||
890 | $this->openCiviPage('event/add', 'reset=1&action=add', '_qf_EventInfo_upload-bottom'); | |
891 | $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7); | |
892 | $email = 'Smith' . substr(sha1(rand()), 0, 7) . '@example.com'; | |
893 | $eventDescription = 'Here is a description for this conference.'; | |
894 | $this->select('event_type_id', 'value=1'); | |
895 | ||
896 | // Attendee role s/b selected now. | |
897 | $this->select('default_role_id', 'value=1'); | |
898 | // Enter Event Title, Summary and Description | |
899 | $this->type('title', $eventTitle); | |
900 | $this->type('summary', 'This is a great conference. Sign up now!'); | |
901 | ||
902 | // Type description in ckEditor (fieldname, text to type, editor) | |
903 | $this->fillRichTextField('description', $eventDescription ); | |
904 | $this->type('max_participants', '50'); | |
905 | $this->click('is_map'); | |
906 | $this->click('_qf_EventInfo_upload-bottom'); | |
907 | ||
908 | // Wait for Location tab form to load | |
909 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
910 | ||
911 | // Go to Fees tab | |
912 | $this->click('link=Fees'); | |
913 | $id = $this->urlArg('id'); | |
914 | $this->waitForElementPresent('_qf_Fee_upload-bottom'); | |
915 | $this->click('CIVICRM_QFID_1_is_monetary'); | |
916 | $processorName = 'Test Processor'; | |
917 | $this->click("xpath=//tr[@class='crm-event-manage-fee-form-block-payment_processor']/td[2]/label[text()='$processorName']"); | |
918 | $this->select('financial_type_id','label=Event Fee'); | |
919 | $this->type("label[1]",'Junior Stars'); | |
920 | $this->type("value[1]",'500.00'); | |
921 | $this->type("label[2]",'Super Stars'); | |
922 | $this->type("value[2]",'1000.00'); | |
923 | $this->check('default'); | |
924 | $this->click('_qf_Fee_upload-bottom'); | |
60709d21 | 925 | $this->waitForText('crm-notification-container', "'Fees' information has been saved."); |
36b1f0cc | 926 | |
927 | // intro text for registration page | |
928 | $registerIntro = 'Fill in all the fields below and click Continue.'; | |
929 | ||
930 | // Go to Online Registration tab | |
931 | $this->click('link=Online Registration'); | |
932 | $this->waitForElementPresent('_qf_Registration_upload-bottom'); | |
02e08b2e | 933 | $this->click('is_online_registration'); |
36b1f0cc | 934 | $this->assertChecked('is_online_registration'); |
935 | ||
936 | //Requires Approvel | |
02e08b2e | 937 | $this->click('requires_approval'); |
36b1f0cc | 938 | $this->assertChecked('requires_approval'); |
939 | $this->click('_qf_Registration_upload-bottom'); | |
02e08b2e | 940 | $this->waitForText('crm-notification-container', "'Online Registration' information has been saved."); |
36b1f0cc | 941 | |
942 | // verify event input on info page | |
943 | // start at Manage Events listing | |
944 | $this->openCiviPage('event/manage', 'reset=1'); | |
945 | $this->click("link=$eventTitle"); | |
946 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
947 | $firstName = substr(sha1(rand()), 0, 7); | |
948 | $this->webtestAddContact($firstName, 'Anderson', TRUE); | |
949 | $contactName = "Anderson, $firstName"; | |
950 | $displayName = "$firstName Anderson"; | |
951 | $this->openCiviPage("event/register", "reset=1&id=$id", '_qf_Register_upload-bottom'); | |
952 | $this->type('first_name',$firstName); | |
953 | ||
954 | //fill in last name | |
955 | $lastName = 'Recuron'.substr(sha1(rand()), 0, 7); | |
956 | $this->type('last_name', $contactName); | |
957 | $email = $firstName . '@example.com'; | |
958 | $this->type('email-Primary', $email); | |
959 | $this->click('_qf_Register_upload'); | |
960 | $this->waitForElementPresent("_qf_Confirm_next"); | |
961 | $this->click('_qf_Confirm_next'); | |
962 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
963 | $this->waitForElementPresent("xpath=//div[@class='section']"); | |
964 | $this->assertTextPresent("Thank You for Registering"); | |
965 | ||
966 | } | |
967 | ||
4cbe18b8 EM |
968 | /** |
969 | * @param $status | |
970 | */ | |
971 | function _testEnableParticipantStatuses($status) { | |
36b1f0cc | 972 | // enable participant status |
60709d21 JP |
973 | if ($this->isElementPresent("xpath=//td[@class='crm-participant-label crm-editable crm-editable-enabled'][contains(text(), '{$status}')]/../td[9]/span/a[2][text()='Enable']")) { |
974 | $this->click("xpath=//td[@class='crm-participant-label crm-editable crm-editable-enabled'][contains(text(), '{$status}')]/../td[9]/span/a[2][text()='Enable']"); | |
975 | $this->waitForElementPresent("xpath=//td[@class='crm-participant-label crm-editable crm-editable-enabled'][contains(text(), '{$status}')]/../td[9]/span/a[2][text()='Disable']"); | |
36b1f0cc | 976 | } |
977 | } | |
42daf119 | 978 | } |