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