3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
27 require_once 'CiviTest/CiviSeleniumTestCase.php';
30 * Class WebTest_Event_AddPricesetTest
32 class WebTest_Event_AddPricesetTest
extends CiviSeleniumTestCase
{
34 protected function setUp() {
38 public function testAddPriceSet() {
40 // Log in using webtestLogin() method
41 $this->webtestLogin();
43 $setTitle = 'Conference Fees - ' . substr(sha1(rand()), 0, 7);
45 $setHelp = 'Select your conference options.';
46 $this->_testAddSet($setTitle, $usedFor, $setHelp);
48 // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form
49 // which is where we are after adding Price Set.
50 $sid = $this->urlArg('sid');
51 $this->assertType('numeric', $sid);
53 $validateStrings = array();
56 'Full Conference' => 'Text',
57 'Meal Choice' => 'Select',
58 'Pre-conference Meetup?' => 'Radio',
59 'Evening Sessions' => 'CheckBox',
61 $this->_testAddPriceFields($fields, $validateStrings);
63 // load the Price Set Preview and check for expected values
64 $this->_testVerifyPriceSet($validateStrings, $sid);
71 * @param string $financialType
73 public function _testAddSet($setTitle, $usedFor, $setHelp, $financialType = 'Event Fee') {
74 $this->openCiviPage('admin/price', 'reset=1&action=add', '_qf_Set_next-bottom');
76 // Enter Priceset fields (Title, Used For ...)
77 $this->type('title', $setTitle);
78 if ($usedFor == 'Event') {
79 $this->check('extends[1]');
81 elseif ($usedFor == 'Contribution') {
82 $this->check('extends[2]');
85 $this->select("financial_type_id", "label={$financialType}");
87 $this->type('help_pre', $setHelp);
89 $this->assertChecked('is_active', 'Verify that Is Active checkbox is set.');
90 $this->clickLink('_qf_Set_next-bottom');
95 * @param $validateStrings
96 * @param bool $dateSpecificFields
98 public function _testAddPriceFields(&$fields, &$validateStrings, $dateSpecificFields = FALSE) {
99 $this->clickLinkSuppressPopup('newPriceField');
100 foreach ($fields as $label => $type) {
101 $validateStrings[] = $label;
103 $this->type('label', $label);
104 $this->select('html_type', "value={$type}");
108 $validateStrings[] = '525.00';
109 $this->type('price', '525.00');
110 $this->select('financial_type_id', 'Donation');
111 if ($dateSpecificFields == TRUE) {
112 $this->webtestFillDateTime('active_on', '+1 week');
115 $this->check('is_required');
122 'label' => 'Chicken',
124 'financial_type_id' => 'Donation',
127 'label' => 'Vegetarian',
129 'financial_type_id' => 'Donation',
132 $this->addMultipleChoiceOptions($options, $validateStrings);
133 if ($dateSpecificFields == TRUE) {
134 $this->webtestFillDateTime('expire_on', '-1 week');
143 'financial_type_id' => 'Donation',
149 'financial_type_id' => 'Donation',
152 $this->addMultipleChoiceOptions($options, $validateStrings);
153 $this->click('is_required');
154 if ($dateSpecificFields == TRUE) {
155 $this->webtestFillDateTime('active_on', '-1 week');
162 'label' => 'First Night',
164 'financial_type_id' => 'Donation',
167 'label' => 'Second Night',
169 'financial_type_id' => 'Donation',
172 $this->addMultipleChoiceOptions($options, $validateStrings);
173 if ($dateSpecificFields == TRUE) {
174 $this->webtestFillDateTime('expire_on', '+1 week');
181 $this->clickLink('_qf_Field_next_new-bottom', '_qf_Field_next-bottom');
182 $this->waitForText('crm-notification-container', "Price Field '" . $label . "' has been saved.");
187 * @param $validateStrings
190 public function _testVerifyPriceSet($validateStrings, $sid) {
191 // verify Price Set at Preview page
192 // start at Manage Price Sets listing
193 $this->openCiviPage('admin/price', 'reset=1');
195 // Use the price set id ($sid) to pick the correct row
196 $this->clickLink("//*[@id='price_set-{$sid}']/td[4]/span[1]/a[2]", '_qf_Preview_cancel-bottom');
198 // Check for expected price set field strings
199 if ($this->isElementPresent("xpath=//*[@class ='select2-chosen']")) {
200 $this->clickAt("xpath=//*[@class ='select2-chosen']");
202 $this->assertStringsPresent($validateStrings);
205 public function testRegisterWithPriceSet() {
206 // Log in using webtestLogin() method
207 $this->webtestLogin();
209 $setTitle = 'Conference Fees - ' . substr(sha1(rand()), 0, 7);
211 $setHelp = 'Select your conference options.';
212 $this->_testAddSet($setTitle, $usedFor, $setHelp);
214 // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form
215 // which is where we are after adding Price Set.
216 $sid = $this->urlArg('sid');
217 $this->assertType('numeric', $sid);
219 $validStrings = array();
221 'Full Conference' => 'Text',
222 'Pre-conference Meetup?' => 'Radio',
223 'Evening Sessions' => 'CheckBox',
225 $this->_testAddPriceFields($fields, $validateStrings);
227 // load the Price Set Preview and check for expected values
228 $this->_testVerifyPriceSet($validateStrings, $sid);
230 // Use default payment processor
231 $processorName = 'Test Processor';
232 $this->webtestAddPaymentProcessor($processorName);
234 $this->openCiviPage('event/add', 'reset=1&action=add', '_qf_EventInfo_upload-bottom');
236 $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7);
237 $email = 'Smith' . substr(sha1(rand()), 0, 7) . '@example.com';
238 $eventDescription = 'Here is a description for this conference.';
240 $this->select('event_type_id', 'value=1');
242 // Attendee role s/b selected now.
243 $this->select('default_role_id', 'value=1');
245 // Enter Event Title, Summary and Description
246 $this->type('title', $eventTitle);
247 $this->type('summary', 'This is a great conference. Sign up now!');
249 // Type description in ckEditor (fieldname, text to type, editor)
250 $this->fillRichTextField('description', $eventDescription);
252 // Choose Start and End dates.
253 // Using helper webtestFillDate function.
254 $this->webtestFillDateTime("start_date", "+1 week");
255 $this->webtestFillDateTime("end_date", "+1 week 1 day 8 hours ");
257 $this->type('max_participants', '50');
258 $this->click('is_map');
259 $this->click('_qf_EventInfo_upload-bottom');
261 // Wait for Location tab form to load
262 $this->waitForElementPresent('_qf_Location_upload_done-bottom');
265 $this->click('link=Fees');
266 $this->waitForElementPresent('_qf_Fee_upload_done-bottom');
267 $this->click('CIVICRM_QFID_1_is_monetary');
268 $this->click("xpath=//table[@id='paymentProcessor']/tbody/tr[1]/td[2]/label[text()='$processorName']");
269 $this->select('financial_type_id', 'label=Event Fee');
270 $this->select('price_set_id', 'label=' . $setTitle);
272 // intro text for registration page
273 $registerIntro = 'Fill in all the fields below and click Continue.';
274 $this->clickLink('_qf_Fee_upload-bottom', 'link=Online Registration', FALSE);
276 // Go to Online Registration tab
277 $this->click('link=Online Registration');
278 $this->waitForElementPresent('_qf_Registration_upload-bottom');
280 $this->check('is_online_registration');
281 $this->assertChecked('is_online_registration');
283 $this->click('intro_text-plain');
284 $this->fillRichTextField('intro_text', $registerIntro);
286 // enable confirmation email
287 $this->click('CIVICRM_QFID_1_is_email_confirm');
288 $this->type('confirm_from_name', 'Jane Doe');
289 $this->type('confirm_from_email', 'jane.doe@example.org');
291 $this->click('_qf_Registration_upload-bottom');
292 $this->waitForTextPresent("'Online Registration' information has been saved.");
294 // verify event input on info page
295 // start at Manage Events listing
296 $this->openCiviPage('event/manage', 'reset=1');
297 $this->click("link=$eventTitle");
299 $this->waitForPageToLoad($this->getTimeoutMsec());
300 $eventInfoUrl = $this->getLocation();
302 $permissions = array("edit-1-register-for-events");
303 $this->changePermissions($permissions);
304 $this->webtestLogout();
305 $this->open($eventInfoUrl);
306 $this->click('link=Register Now');
307 $this->waitForElementPresent('_qf_Register_upload-bottom');
309 $this->type("xpath=//input[@class='four crm-form-text required']", "1");
310 $this->click("xpath=//input[@class='crm-form-radio']");
311 $this->click("xpath=//input[@class='crm-form-checkbox']");
312 $this->type("first_name", "Jane");
313 $lastName = "Smith" . substr(sha1(rand()), 0, 7);
314 $this->type("last_name", $lastName);
315 $this->type('email-Primary', $email);
317 $this->waitForElementPresent('credit_card_type');
318 $this->select('credit_card_type', 'value=Visa');
319 $this->type('credit_card_number', '4111111111111111');
320 $this->type('cvv2', '000');
321 $this->select('credit_card_exp_date[M]', 'value=1');
322 $this->select('credit_card_exp_date[Y]', 'value=2020');
323 $this->type('billing_first_name', 'Jane');
324 $this->type('billing_last_name', $lastName);
325 $this->type('billing_street_address-5', '15 Main St.');
326 $this->type(' billing_city-5', 'San Jose');
327 $this->select('billing_country_id-5', 'value=1228');
328 $this->select('billing_state_province_id-5', 'value=1004');
329 $this->type('billing_postal_code-5', '94129');
331 $this->clickLink('_qf_Register_upload-bottom', '_qf_Confirm_next-bottom');
332 $confirmStrings = array('Event Fee(s)', 'Billing Name and Address', 'Credit Card Information');
333 $this->assertStringsPresent($confirmStrings);
334 $this->click('_qf_Confirm_next-bottom');
335 $this->waitForPageToLoad($this->getTimeoutMsec());
336 $thankStrings = array('Thank You for Registering', 'Event Total', 'Transaction Date');
337 $this->assertStringsPresent($thankStrings);
339 // Log in using webtestLogin() method
340 $this->webtestLogin();
343 $this->openCiviPage('event/search', 'reset=1', '_qf_Search_refresh');
345 $this->type('sort_name', "$email");
346 $this->clickLink('_qf_Search_refresh', "xpath=id('participantSearch')/table/tbody/tr/td[11]/span/a[text()='View']");
347 $this->click("xpath=id('participantSearch')/table/tbody/tr/td[11]/span/a[text()='View']");
348 $this->waitForElementPresent('_qf_ParticipantView_cancel-bottom');
351 2 => 'Full Conference',
352 3 => 'Pre-conference Meetup? - Yes',
353 4 => 'Evening Sessions - First Night',
355 foreach ($expected as $value => $label) {
356 $this->verifyText("xpath=id('ParticipantView')/div[2]/table[1]/tbody/tr[8]/td[2]/table/tbody/tr[$value]/td", $label);
358 // Fixme: We can't asset full string like - "Event Total: $ 590.00" as it has special char
359 $this->assertStringsPresent(' 590.00');
360 $this->click('_qf_ParticipantView_cancel-bottom');
363 public function testParticipantWithDateSpecificPriceSet() {
365 // Log in using webtestLogin() method
366 $this->webtestLogin();
368 $setTitle = 'Conference Fees - ' . substr(sha1(rand()), 0, 7);
370 $setHelp = 'Select your conference options.';
371 $this->_testAddSet($setTitle, $usedFor, $setHelp);
373 // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form
374 // which is where we are after adding Price Set.
375 $sid = $this->urlArg('sid');
376 $this->assertType('numeric', $sid);
378 $validStrings = array();
380 'Full Conference' => 'Text',
381 'Pre-conference Meetup?' => 'Radio',
382 'Evening Sessions' => 'CheckBox',
384 $this->_testAddPriceFields($fields, $validateStrings, TRUE);
386 // load the Price Set Preview and check for expected values
387 $this->_testVerifyPriceSet($validateStrings, $sid);
389 // Use default payment processor
390 $processorName = 'Test Processor';
391 $this->webtestAddPaymentProcessor($processorName);
393 $this->openCiviPage('event/add', 'reset=1&action=add', '_qf_EventInfo_upload-bottom');
395 $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7);
396 $email = 'Smith' . substr(sha1(rand()), 0, 7) . '@example.com';
397 $eventDescription = 'Here is a description for this conference.';
399 $this->select('event_type_id', 'value=1');
401 // Attendee role s/b selected now.
402 $this->select('default_role_id', 'value=1');
404 // Enter Event Title, Summary and Description
405 $this->type('title', $eventTitle);
406 $this->type('summary', 'This is a great conference. Sign up now!');
408 // Type description in ckEditor (fieldname, text to type, editor)
409 $this->fillRichTextField('description', $eventDescription);
411 // Choose Start and End dates.
412 // Using helper webtestFillDate function.
413 $this->webtestFillDateTime("start_date", "+1 week");
414 $this->webtestFillDateTime("end_date", "+1 week 1 day 8 hours ");
416 $this->type('max_participants', '50');
417 $this->click('is_map');
418 $this->click('_qf_EventInfo_upload-bottom');
420 // Wait for Location tab form to load
421 $this->waitForPageToLoad($this->getTimeoutMsec());
424 $this->click('link=Fees');
425 $this->waitForElementPresent('_qf_Fee_upload-bottom');
426 $this->click('CIVICRM_QFID_1_is_monetary');
427 $this->click("xpath=//tr[@class='crm-event-manage-fee-form-block-payment_processor']/td[2]/label[text()='$processorName']");
428 $this->select('financial_type_id', 'label=Event Fee');
429 $this->select('price_set_id', 'label=' . $setTitle);
431 $this->clickLink('_qf_Fee_upload-bottom', 'link=Online Registration', FALSE);
433 // intro text for registration page
434 $registerIntro = 'Fill in all the fields below and click Continue.';
436 // Go to Online Registration tab
437 $this->click('link=Online Registration');
438 $this->waitForElementPresent('_qf_Registration_upload-bottom');
440 $this->check('is_online_registration');
441 $this->assertChecked('is_online_registration');
443 $this->click('intro_text-plain');
444 $this->fillRichTextField('intro_text', $registerIntro);
446 // enable confirmation email
447 $this->click('CIVICRM_QFID_1_is_email_confirm');
448 $this->type('confirm_from_name', 'Jane Doe');
449 $this->type('confirm_from_email', 'jane.doe@example.org');
451 $this->click('_qf_Registration_upload-bottom');
452 $this->waitForTextPresent("'Online Registration' information has been saved.");
454 // verify event input on info page
455 // start at Manage Events listing
456 $this->openCiviPage('event/manage', 'reset=1');
457 $this->click("link=$eventTitle");
459 $this->waitForPageToLoad($this->getTimeoutMsec());
460 // Adding contact with randomized first name (so we can then select that contact when creating event registration)
461 // We're using Quick Add block on the main page for this.
462 $firstName = substr(sha1(rand()), 0, 7);
463 $lastName = 'Anderson' . substr(sha1(rand()), 0, 7);
464 $this->webtestAddContact($firstName, $lastName, TRUE);
465 $contactName = "$lastName, $firstName";
466 $displayName = "$firstName $lastName";
468 $this->openCiviPage('participant/add', 'reset=1&action=add&context=standalone', '_qf_Participant_upload-bottom');
470 // Type contact last name in contact auto-complete, wait for dropdown and click first result
471 $this->webtestFillAutocomplete($firstName);
473 // Select event. Based on label for now.
474 $this->select2('event_id', "$eventTitle");
476 $this->multiselect2('role_id', array('Volunteer'));
478 $this->waitForElementPresent("xpath=//input[@class='crm-form-radio']");
479 $this->click("xpath=//input[@class='crm-form-radio']");
480 $this->click("xpath=//input[@class='crm-form-checkbox']");
482 // Choose Registration Date.
483 // Using helper webtestFillDate function.
484 $this->webtestFillDate('register_date', 'now');
485 $today = date('F jS, Y', strtotime('now'));
487 // Select participant status
488 $this->select('status_id', 'value=1');
491 $this->click('_qf_Participant_upload-bottom');
492 $this->waitForPageToLoad($this->getTimeoutMsec());
493 // Is status message correct?
494 $this->waitForText("crm-notification-container", "Event registration for $displayName has been added", "Status message didn't show up after saving!");
496 $this->waitForElementPresent("xpath=//form[@class='CRM_Event_Form_Search crm-search-form']/table//tbody/tr[1]/td[8]/span/a[text()='View']");
498 //click through to the participant view screen
499 $this->click("xpath=//form[@class='CRM_Event_Form_Search crm-search-form']/table/tbody/tr[1]/td[8]/span/a[text()='View']");
500 $this->waitForElementPresent("xpath=//button//span[contains(text(),'Done')]");
504 * Test to regiter participant for event with
505 * multiple price fields in price-set
509 public function testEventWithPriceSet() {
510 $this->markTestSkipped('Skipping for now as it works fine locally.');
511 // Log in using webtestLogin() method
512 $this->webtestLogin();
514 // Adding contact with randomized first name (so we can then select that contact when creating event registration)
515 // We're using Quick Add block on the main page for this.
516 $firstName = substr(sha1(rand()), 0, 7);
517 $lastName = 'Anderson' . substr(sha1(rand()), 0, 7);
518 $this->webtestAddContact($firstName, $lastName, TRUE);
519 $contactName = "$lastName, $firstName";
520 $displayName = "$firstName $lastName";
522 $setTitle = 'Conference Fees - ' . substr(sha1(rand()), 0, 7);
524 $setHelp = 'Select your conference options.';
525 $this->_testAddSet($setTitle, $usedFor, $setHelp);
527 // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form
528 // which is where we are after adding Price Set.
529 $sid = $this->urlArg('sid');
530 $this->assertType('numeric', $sid);
532 $validStrings = array();
534 'Full Conference' => 'Text',
535 'Pre-conference Meetup?' => 'Radio',
536 'Evening Sessions' => 'CheckBox',
538 $this->_testAddPriceFields($fields, $validateStrings);
540 // load the Price Set Preview and check for expected values
541 $this->_testVerifyPriceSet($validateStrings, $sid);
543 $this->openCiviPage('event/add', 'reset=1&action=add', '_qf_EventInfo_upload-bottom');
545 $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7);
546 $email = 'Smith' . substr(sha1(rand()), 0, 7) . '@example.com';
547 $eventDescription = 'Here is a description for this conference.';
549 $this->select('event_type_id', 'value=1');
551 // Attendee role s/b selected now.
552 $this->select('default_role_id', 'value=1');
554 // Enter Event Title, Summary and Description
555 $this->type('title', $eventTitle);
556 $this->type('summary', 'This is a great conference. Sign up now!');
558 // Type description in ckEditor (fieldname, text to type, editor)
559 $this->fillRichTextField('description', $eventDescription);
561 // Choose Start and End dates.
562 // Using helper webtestFillDate function.
563 $this->webtestFillDateTime("start_date", "+1 week");
564 $this->webtestFillDateTime("end_date", "+1 week 1 day 8 hours ");
566 $this->type('max_participants', '50');
567 $this->click('is_map');
568 $this->click('_qf_EventInfo_upload-bottom');
570 // Wait for Location tab form to load
571 $this->waitForPageToLoad($this->getTimeoutMsec());
574 $this->click('link=Fees');
575 $this->waitForElementPresent('_qf_Fee_upload-bottom');
576 $this->click('CIVICRM_QFID_1_is_monetary');
577 $this->select('financial_type_id', 'label=Event Fee');
578 $this->select('price_set_id', 'label=' . $setTitle);
580 $this->click('_qf_Fee_upload-bottom');
581 $this->waitForText("crm-notification-container", "'Fees' information has been saved.");
582 $this->waitForAjaxContent();
584 $this->openCiviPage('participant/add', 'reset=1&action=add&context=standalone', '_qf_Participant_upload-bottom');
586 // Type contact last name in contact auto-complete, wait for dropdown and click first result
587 $this->webtestFillAutocomplete($firstName);
588 $this->select2('event_id', $eventTitle);
590 $this->multiselect2('role_id', array('Volunteer'));
592 // Choose Registration Date.
593 // Using helper webtestFillDate function.
594 $this->webtestFillDate('register_date', 'now');
595 $today = date('F jS, Y', strtotime('now'));
598 // Select participant status
599 $this->select('status_id', 'value=1');
601 // Setting registration source
602 $this->type('source', 'Event StandaloneAddTest Webtest');
604 // Select an event fee
605 $this->waitForElementPresent("xpath=//div[@id='priceset']/div[2]/div[2]/input");
606 $this->type("xpath=//div[@id='priceset']/div[2]/div[2]/input", '5');
607 $this->fireEvent("xpath=//div[@id='priceset']/div[2]/div[2]/input", 'blur');
608 $this->waitForElementPresent("xpath=//div[@id='priceset']/div[3]/div[2]/div[1]/span/input");
609 $this->click("xpath=//div[@id='priceset']/div[3]/div[2]/div[1]/span/input");
610 $this->click("xpath=//div[@id='priceset']/div[4]/div[2]/div[1]/span/input");
611 $this->click("xpath=//div[@id='priceset']/div[4]/div[2]/div[2]/span/input");
613 // Select payment method = Check and enter chk number
614 $this->select('payment_instrument_id', 'value=4');
615 $this->waitForElementPresent('check_number');
616 $this->type('check_number', '1044');
619 $this->click('_qf_Participant_upload-bottom');
620 $this->waitForPageToLoad($this->getTimeoutMsec());
622 // Is status message correct?
623 $this->waitForText("crm-notification-container", "Event registration for $displayName has been added");
625 $this->waitForElementPresent("xpath=//form[@id='Search']/table/tbody/tr[1]/td[8]/span/a[text()='View']");
626 //click through to the participant view screen
627 $this->click("xpath=//form[@id='Search']/table/tbody/tr[1]/td[8]/span/a[text()='View']");
628 $this->waitForElementPresent('_qf_ParticipantView_cancel-bottom');
630 $this->webtestVerifyTabularData(
632 'Event' => $eventTitle,
633 'Participant Role' => 'Attendee',
634 'Status' => 'Registered',
635 'Event Source' => 'Event StandaloneAddTest Webtest',
638 $this->waitForElementPresent("xpath=//table/tbody/tr/td[text()='Fees']/following-sibling::td");
639 $this->verifyText("xpath=//table/tbody/tr/td[text()='Fees']/following-sibling::td/table/tbody/tr[2]/td", preg_quote('$ 2,705.00'));
640 $expectedLineItems = array(
642 1 => 'Full Conference',
653 1 => 'Evening Sessions - First Night',
659 1 => 'Evening Sessions - Second Night',
665 $this->_checkLineItems($expectedLineItems);
666 // check contribution record as well
667 // click through to the contribution view screen
668 $this->click("xpath=//*[@id='ParticipantView']/div[2]/table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='View']");
669 $this->waitForElementPresent('_qf_ContributionView_cancel-bottom');
671 $this->webtestVerifyTabularData(
673 'From' => $displayName,
674 'Financial Type' => 'Event Fee',
675 'Contribution Status' => 'Completed',
676 'Paid By' => 'Check',
677 'Check Number' => '1044',
678 'Received Into' => 'Deposit Bank Account',
681 $this->verifyText("xpath=//td[text()='Contribution Amount']/following-sibling::td//div/div", preg_quote('Contribution Total: $ 2,705.00'));
685 public function testDeletePriceSetforEventTemplate() {
686 $this->markTestSkipped('Skipping for now as it works fine locally.');
687 // Log in using webtestLogin() method
688 $this->webtestLogin();
690 $setTitle = 'Conference Fees - ' . substr(sha1(rand()), 0, 7);
692 $setHelp = 'Select your conference options.';
693 $this->_testAddSet($setTitle, $usedFor, $setHelp);
695 // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form
696 // which is where we are after adding Price Set.
697 $sid = $this->urlArg('sid');
698 $this->assertType('numeric', $sid);
700 $validStrings = array();
702 'Test Field' => 'Text',
704 $this->_testAddPriceFields($fields, $validateStrings);
706 // load the Price Set Preview and check for expected values
707 $this->_testVerifyPriceSet($validateStrings, $sid);
708 $this->openCiviPage('admin/eventTemplate', 'reset=1');
709 $this->clickLink('newEventTemplate');
710 $this->select("template_id", "value=6");
711 // Wait for event type to be filled in (since page reloads)
712 $this->waitForElementPresent("template_id");
713 // Enter Event Title, Summary and Description
714 $this->select("event_type_id", "value=4");
715 $this->select("default_role_id", "value=1");
716 $this->waitForAjaxContent();
717 $this->type("title", "Test Event");
718 $this->type("summary", "This is a great conference. Sign up now!");
720 $this->click("_qf_EventInfo_upload-bottom");
721 $this->waitForElementPresent('link=Fees');
723 $this->click('link=Fees');
724 $this->waitForElementPresent('_qf_Fee_upload-bottom');
725 $this->click('CIVICRM_QFID_1_is_monetary');
726 $this->select('financial_type_id', 'label=Event Fee');
727 $this->select('price_set_id', 'label=' . $setTitle);
728 $templateId = $this->urlArg('id');
729 $this->click('_qf_Fee_upload-bottom');
731 //check the delete for price field
732 $this->openCiviPage("admin/price/field", "reset=1&action=browse&sid={$sid}");
733 $this->waitForElementPresent("xpath=//table[@id='options']/tbody/tr/td[9]/span[2]");
734 $this->click("xpath=//table[@id='options']/tbody/tr/td[9]/span[2]/ul/li[2]/a");
736 $this->waitForText('price_set_used_by', "it is currently in use by one or more active events or contribution pages or contributions or event templates. If you no longer want to use this price set, click the event title below, and modify the fees for that event.");
738 //check the delete for priceset
739 $this->openCiviPage("admin/price", "reset=1");
740 $this->waitForElementPresent("xpath=//table[@class='display crm-price-set-listing dataTable no-footer']/tbody/tr/td[4]/span[2]");
741 $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody/tr/td[4]/span[2]/ul/li[3]/a");
742 // Check confirmation alert.
743 $this->assertTrue((bool) preg_match("/^Are you sure you want to delete this price set?/",
744 $this->getConfirmation()
746 $this->chooseOkOnNextConfirmation();
747 $this->waitForPageToLoad($this->getTimeoutMsec());
749 $this->waitForText('price_set_used_by',
750 "it is currently in use by one or more active events or contribution pages or contributions or event templates.");
754 * @param array $expectedLineItems
756 public function _checkLineItems($expectedLineItems) {
757 foreach ($expectedLineItems as $lineKey => $lineValue) {
758 foreach ($lineValue as $key => $value) {
759 $this->verifyText("xpath=//table/tbody//tr/td[text()='Selections']/following-sibling::td/table/tbody//tr[$lineKey]/td[$key]", preg_quote($value));