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