3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
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_Contribute_AddPricesetTest
32 class WebTest_Contribute_AddPricesetTest
extends CiviSeleniumTestCase
{
34 protected function setUp() {
38 public function testAddPriceSet() {
39 // Log in using webtestLogin() method
40 $this->webtestLogin();
42 //add financial type of account type expense
44 $financialType = $this->_testAddFinancialType();
46 $setTitle = 'Conference Fees - ' . substr(sha1(rand()), 0, 7);
47 $usedFor = 'Contribution';
48 $setHelp = 'Select your conference options.';
49 $this->_testAddSet($setTitle, $usedFor, $setHelp, $financialType);
51 // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form
52 // which is where we are after adding Price Set.
53 $sid = $this->urlArg('sid');
54 $this->assertType('numeric', $sid);
56 $validStrings = array();
59 'Full Conference' => 'Text',
60 'Meal Choice' => 'Select',
61 'Pre-conference Meetup?' => 'Radio',
62 'Evening Sessions' => 'CheckBox',
64 $this->_testAddPriceFields($fields, $validateStrings, $financialType);
65 // var_dump($validateStrings);
67 // load the Price Set Preview and check for expected values
68 $this->_testVerifyPriceSet($validateStrings, $sid);
75 * @param null $financialType
77 public function _testAddSet($setTitle, $usedFor, $setHelp, $financialType = NULL) {
78 $this->openCiviPage("admin/price", "reset=1&action=add", '_qf_Set_next-bottom');
80 // Enter Priceset fields (Title, Used For ...)
81 $this->type('title', $setTitle);
82 if ($usedFor == 'Event') {
83 $this->check('extends_1');
85 elseif ($usedFor == 'Contribution') {
86 $this->check('extends_2');
90 $this->select("financial_type_id", "label={$financialType}");
92 $this->type('help_pre', $setHelp);
94 $this->assertChecked('is_active', 'Verify that Is Active checkbox is set.');
95 $this->clickLink('_qf_Set_next-bottom');
100 * @param $validateString
101 * @param $financialType
102 * @param bool $dateSpecificFields
104 public function _testAddPriceFields(&$fields, &$validateString, $financialType, $dateSpecificFields = FALSE) {
105 $validateStrings[] = $financialType;
106 $sid = $this->urlArg('sid');
107 $this->openCiviPage('admin/price/field', "reset=1&action=add&sid=$sid", 'label');
108 foreach ($fields as $label => $type) {
109 $validateStrings[] = $label;
111 $this->type('label', $label);
112 $this->select('html_type', "value={$type}");
116 $validateStrings[] = '525.00';
117 $this->type('price', '525.00');
118 if ($dateSpecificFields == TRUE) {
119 $this->webtestFillDateTime('active_on', '+1 week');
122 $this->check('is_required');
129 'label' => 'Chicken',
133 'label' => 'Vegetarian',
137 $this->addMultipleChoiceOptions($options, $validateStrings);
138 if ($dateSpecificFields == TRUE) {
139 $this->webtestFillDateTime('expire_on', '-1 week');
154 $this->addMultipleChoiceOptions($options, $validateStrings);
155 $this->check('is_required');
156 if ($dateSpecificFields == TRUE) {
157 $this->webtestFillDateTime('active_on', '-1 week');
164 'label' => 'First Night',
168 'label' => 'Second Night',
172 $this->addMultipleChoiceOptions($options, $validateStrings);
173 if ($dateSpecificFields == TRUE) {
174 $this->webtestFillDateTime('expire_on', '+1 week');
181 $this->select('financial_type_id', "label={$financialType}");
182 $this->clickLink('_qf_Field_next_new-bottom', '_qf_Field_next-bottom', FALSE);
183 $this->waitForText('crm-notification-container', "Price Field '$label' has been saved.");
190 public function _testAddFinancialType() {
191 //Add new Financial Type
192 $financialType['name'] = 'FinancialType ' . substr(sha1(rand()), 0, 4);
193 $financialType['is_deductible'] = TRUE;
194 $financialType['is_reserved'] = FALSE;
195 $this->addeditFinancialType($financialType);
196 return $financialType['name'];
200 * @param $validateStrings
203 public function _testVerifyPriceSet($validateStrings, $sid) {
204 // verify Price Set at Preview page
205 // start at Manage Price Sets listing
206 $this->openCiviPage("admin/price", "reset=1");
208 // Use the price set id ($sid) to pick the correct row
209 $this->clickLink("//*[@id='price_set-{$sid}']/td[4]/span[1]/a[1]", 'Link=Add Price Field');
210 // Check for expected price set field strings
211 $this->assertStringsPresent($validateStrings);
214 public function testContributeOfflineWithPriceSet() {
215 // Log in using webtestLogin() method
216 $this->webtestLogin();
218 //add financial type of account type expense
219 $financialType = $this->_testAddFinancialType();
221 $setTitle = 'Conference Fees - ' . substr(sha1(rand()), 0, 7);
222 $usedFor = 'Contribution';
223 $setHelp = 'Select your conference options.';
224 $this->_testAddSet($setTitle, $usedFor, $setHelp, $financialType);
226 // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form
227 // which is where we are after adding Price Set.
228 $sid = $this->urlArg('sid');
229 $this->assertType('numeric', $sid);
231 $validStrings = array();
233 'Full Conference' => 'Text',
234 'Meal Choice' => 'Select',
235 'Pre-conference Meetup?' => 'Radio',
236 'Evening Sessions' => 'CheckBox',
238 $this->_testAddPriceFields($fields, $validateStrings, $financialType);
240 // load the Price Set Preview and check for expected values
241 $this->_testVerifyPriceSet($validateStrings, $sid);
242 $this->openCiviPage("contribute/add", "reset=1&action=add&context=standalone", '_qf_Contribution_upload');
244 // create new contact using dialog
245 $this->createDialogContact();
247 // select financial type
248 $this->select('financial_type_id', "label={$financialType}");
250 // fill in Received Date
251 $this->webtestFillDate('receive_date');
254 $this->type('source', 'Mailer 1');
256 // select price set items
257 $this->select('price_set_id', "label=$setTitle");
258 $this->type("xpath=//input[@class='four crm-form-text required']", "1");
259 $this->click("xpath=//input[@class='crm-form-radio']");
260 $this->click("xpath=//input[@class='crm-form-checkbox']");
261 // select payment instrument type = Check and enter chk number
262 $this->select('payment_instrument_id', 'value=4');
263 $this->waitForElementPresent('check_number');
264 $this->type('check_number', 'check #1041');
266 $this->type('trxn_id', 'P20901X1' . rand(100, 10000));
268 //Additional Detail section
269 $this->click('AdditionalDetail');
270 $this->waitForElementPresent('thankyou_date');
272 $this->type('note', 'This is a test note.');
273 $this->type('non_deductible_amount', '10');
274 $this->type('fee_amount', '0');
275 $this->type('net_amount', '0');
276 $this->type('invoice_id', time());
277 $this->webtestFillDate('thankyou_date');
280 $this->click('_qf_Contribution_upload');
281 $this->waitForPageToLoad($this->getTimeoutMsec());
283 // Is status message correct?
284 $this->assertTrue($this->isTextPresent('The contribution record has been saved.'), "Status message didn't show up after saving!");
286 $this->waitForElementPresent("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[8]/span/a[text()='View']");
288 //click through to the Membership view screen
289 $this->click("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[8]/span/a[text()='View']");
290 $this->waitForElementPresent('_qf_ContributionView_cancel-bottom');
298 foreach ($expected as $label => $value) {
299 $this->verifyText("xpath=id('ContributionView')/div[2]/table[1]/tbody/tr[$label]/td[2]", preg_quote($value));
308 foreach ($exp as $lab => $val) {
309 $this->verifyText("xpath=id('ContributionView')/div[2]/table[1]/tbody/tr[3]/td[2]/table/tbody/tr[$lab]/td[3]",
315 public function testContributeOnlineWithPriceSet() {
316 $this->webtestLogin();
318 //add financial type of account type expense
319 $financialType = $this->_testAddFinancialType();
321 $setTitle = 'Conference Fees - ' . substr(sha1(rand()), 0, 7);
322 $usedFor = 'Contribution';
323 $setHelp = 'Select your conference options.';
324 $this->_testAddSet($setTitle, $usedFor, $setHelp, $financialType);
326 // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form
327 // which is where we are after adding Price Set.
328 $sid = $this->urlArg('sid');
329 $this->assertType('numeric', $sid);
331 $validStrings = array();
333 'Full Conference' => 'Text',
334 'Meal Choice' => 'Select',
335 'Pre-conference Meetup?' => 'Radio',
336 'Evening Sessions' => 'CheckBox',
339 $this->_testAddPriceFields($fields, $validateStrings, $financialType);
341 // load the Price Set Preview and check for expected values
342 $this->_testVerifyPriceSet($validateStrings, $sid);
344 // Use default payment processor
345 $processorName = 'Test Processor';
346 $this->webtestAddPaymentProcessor($processorName);
348 $this->openCiviPage("admin/contribute/add", "reset=1&action=add");
350 $contributionTitle = substr(sha1(rand()), 0, 7);
351 $rand = 2 * rand(2, 50);
353 // fill in step 1 (Title and Settings)
354 $contributionPageTitle = "Title $contributionTitle";
355 $this->type('title', $contributionPageTitle);
356 $this->fillRichTextField('intro_text', 'This is Test Introductory Message', 'CKEditor');
357 $this->fillRichTextField('footer_text', 'This is Test Footer Message', 'CKEditor');
359 $this->select('financial_type_id', "label={$financialType}");
362 $this->clickLink('_qf_Settings_next', "_qf_Amount_next-bottom");
364 // Get contribution page id
365 $pageId = $this->urlArg('id');
367 //this contribution page for online contribution
368 $this->click("xpath=//tr[@class='crm-contribution-contributionpage-amount-form-block-payment_processor']/td/label[text()='$processorName']");
369 $this->select('price_set_id', 'label=' . $setTitle);
370 $this->click('_qf_Amount_next-bottom');
371 $this->waitForPageToLoad($this->getTimeoutMsec());
374 $this->webtestLogout();
376 //Open Live Contribution Page
377 $this->openCiviPage('contribute/transact', "reset=1&id=$pageId&action=preview", '_qf_Main_upload-bottom');
379 $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
380 $lastName = 'An' . substr(sha1(rand()), 0, 7);
381 $email = $firstName . "@example.com";
382 $this->waitForElementPresent('_qf_Main_upload-bottom');
383 $this->type("email-5", $email);
384 $this->type("xpath=//input[@class='four crm-form-text required']", "1");
385 $this->click("xpath=//input[@class='crm-form-radio']");
386 $this->click("xpath=//input[@class='crm-form-checkbox']");
388 $streetAddress = '100 Main Street';
389 $this->type('billing_street_address-5', $streetAddress);
390 $this->type('billing_city-5', 'San Francisco');
391 $this->type('billing_postal_code-5', '94117');
392 $this->select('billing_country_id-5', 'value=1228');
393 $this->select('billing_state_province_id-5', 'value=1001');
396 $this->select('credit_card_type', 'value=Visa');
397 $this->type('credit_card_number', '4111111111111111');
398 $this->type('cvv2', '000');
399 $this->select('credit_card_exp_date[M]', 'value=1');
400 $this->select('credit_card_exp_date[Y]', 'value=2020');
403 $this->type('billing_first_name', $firstName);
404 $this->type('billing_last_name', $lastName);
405 $this->type('billing_street_address-5', '15 Main St.');
406 $this->type('billing_city-5', 'San Jose');
407 $this->select('billing_country_id-5', 'value=1228');
408 $this->select('billing_state_province_id-5', 'value=1004');
409 $this->type('billing_postal_code-5', '94129');
410 $this->clickLink('_qf_Main_upload-bottom', '_qf_Confirm_next-bottom');
412 $this->click('_qf_Confirm_next-bottom');
413 $this->waitForPageToLoad($this->getTimeoutMsec());
415 //login to check contribution
417 // Log in using webtestLogin() method
418 $this->webtestLogin();
421 $this->openCiviPage("contribute/search", "reset=1", 'contribution_date_low');
423 $this->click("xpath=//tr/td[1]/label[contains(text(), 'Contribution is a Test?')]/../../td[2]/label[contains(text(), 'Yes')]/preceding-sibling::input[1]");
424 $this->type("sort_name", "$email");
425 $this->waitForAjaxContent();
426 $this->click("xpath=//div[@class='crm-accordion-wrapper crm-contribution_search_form-accordion ']/div[2]/table/tbody/tr[8]/td[1]/table/tbody/tr[3]/td[2]/label[1]");
427 $this->clickLink('_qf_Search_refresh', "xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
428 $this->clickLink("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", "_qf_ContributionView_cancel-bottom", FALSE);
430 // View Contribution Record and test for expected values
432 'From' => "{$email}",
433 'Financial Type' => $financialType,
434 // as per changes made in CRM-15407
435 'Fee Amount' => '$ 1.50',
436 'Net Amount' => '$ 588.50',
437 'Contribution Status' => 'Completed',
439 $this->webtestVerifyTabularData($expected);
443 public function testContributeWithDateSpecificPriceSet() {
444 $this->webtestLogin();
446 //add financial type of account type expense
447 $financialType = $this->_testAddFinancialType();
449 $setTitle = 'Conference Fees - ' . substr(sha1(rand()), 0, 7);
450 $usedFor = 'Contribution';
451 $setHelp = 'Select your conference options.';
452 $this->_testAddSet($setTitle, $usedFor, $setHelp, $financialType);
454 // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form
455 // which is where we are after adding Price Set.
456 $sid = $this->urlArg('sid');
457 $this->assertType('numeric', $sid);
459 $validStrings = array();
461 'Full Conference' => 'Text',
462 'Meal Choice' => 'Select',
463 'Pre-conference Meetup?' => 'Radio',
464 'Evening Sessions' => 'CheckBox',
466 $this->_testAddPriceFields($fields, $validateStrings, $financialType, TRUE);
468 // load the Price Set Preview and check for expected values
469 $this->_testVerifyPriceSet($validateStrings, $sid);
471 // Use default payment processor
472 $processorName = 'Test Processor';
473 $this->webtestAddPaymentProcessor($processorName);
475 $this->openCiviPage("admin/contribute/add", "reset=1&action=add");
477 $contributionTitle = substr(sha1(rand()), 0, 7);
478 $rand = 2 * rand(2, 50);
480 // fill in step 1 (Title and Settings)
481 $contributionPageTitle = "Title $contributionTitle";
482 $this->type('title', $contributionPageTitle);
483 $this->select('financial_type_id', "label={$financialType}");
484 $this->fillRichTextField('intro_text', 'This is Test Introductory Message', 'CKEditor');
485 $this->fillRichTextField('footer_text', 'This is Test Footer Message', 'CKEditor');
488 $this->clickLink('_qf_Settings_next', "_qf_Amount_next-bottom");
490 // Get contribution page id
491 $pageId = $this->urlArg('id');
493 //this contribution page for online contribution
494 $this->click("xpath=//tr[@class='crm-contribution-contributionpage-amount-form-block-payment_processor']/td/label[text()='$processorName']");
495 $this->select('price_set_id', 'label=' . $setTitle);
496 $this->clickLink('_qf_Amount_next-bottom');
499 $this->webtestLogout();
501 //Open Live Contribution Page
502 $this->openCiviPage('contribute/transact', "reset=1&id=$pageId&action=preview", '_qf_Main_upload-bottom');
504 $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
505 $lastName = 'An' . substr(sha1(rand()), 0, 7);
506 $email = $firstName . "@example.com";
507 $this->waitForElementPresent('_qf_Main_upload-bottom');
508 $this->type('email-5', $email);
509 $this->click("xpath=//input[@class='crm-form-radio']");
510 $this->click("xpath=//input[@class='crm-form-checkbox']");
512 $streetAddress = '100 Main Street';
513 $this->type('billing_street_address-5', $streetAddress);
514 $this->type('billing_city-5', 'San Francisco');
515 $this->type('billing_postal_code-5', '94117');
516 $this->select('billing_country_id-5', 'value=1228');
517 $this->select('billing_state_province_id-5', 'value=1001');
520 $this->select('credit_card_type', 'value=Visa');
521 $this->type('credit_card_number', '4111111111111111');
522 $this->type('cvv2', '000');
523 $this->select('credit_card_exp_date[M]', 'value=1');
524 $this->select('credit_card_exp_date[Y]', 'value=2020');
527 $this->type('billing_first_name', $firstName);
528 $this->type('billing_last_name', $lastName);
529 $this->type('billing_street_address-5', '15 Main St.');
530 $this->type(' billing_city-5', 'San Jose');
531 $this->select('billing_country_id-5', 'value=1228');
532 $this->select('billing_state_province_id-5', 'value=1004');
533 $this->type('billing_postal_code-5', '94129');
534 $this->clickLink('_qf_Main_upload-bottom', '_qf_Confirm_next-bottom');
536 $this->click('_qf_Confirm_next-bottom');
537 $this->waitForPageToLoad($this->getTimeoutMsec());
539 //login to check contribution
540 $this->webtestLogin();
543 $this->openCiviPage("contribute/search", "reset=1", 'contribution_date_low');
544 $this->click("xpath=//tr/td[1]/label[contains(text(), 'Contribution is a Test?')]/../../td[2]/label[contains(text(), 'Yes')]/preceding-sibling::input[1]");
545 $this->type("sort_name", "$email");
546 $this->waitForAjaxContent();
547 $this->click("xpath=//div[@class='crm-accordion-wrapper crm-contribution_search_form-accordion ']/div[2]/table/tbody/tr[8]/td[1]/table/tbody/tr[3]/td[2]/label[1]");
548 $this->clickLink('_qf_Search_refresh', "xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", FALSE);
549 $this->clickLink("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']", '_qf_ContributionView_cancel-bottom', FALSE);
551 // View Contribution Record and test for expected values
553 'From' => "{$firstName} {$lastName}",
554 'Financial Type' => $financialType,
555 // as per changes made in CRM-15407
556 'Fee Amount' => '$ 1.50',
557 'Net Amount' => '$ 63.50',
558 'Contribution Status' => 'Completed',
560 $this->webtestVerifyTabularData($expected);
563 public function testContributeOfflineforSoftcreditwithApi() {
564 // Log in using webtestLogin() method
565 $this->webtestLogin();
567 //create a contact and return the contact id
568 $firstNameSoft = "John_" . substr(sha1(rand()), 0, 5);
569 $lastNameSoft = "Doe_" . substr(sha1(rand()), 0, 5);
570 $this->webtestAddContact($firstNameSoft, $lastNameSoft);
571 $url = $this->parseURL();
572 $cid = $url['queryString']['cid'];
573 $this->assertType('numeric', $cid);
575 $setTitle = 'Conference Fees - ' . substr(sha1(rand()), 0, 7);
576 $usedFor = 'Contribution';
577 $setHelp = 'Select your conference options.';
578 $financialType = $this->_testAddFinancialType();
579 $this->_testAddSet($setTitle, $usedFor, $setHelp, $financialType);
581 // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form
582 // which is where we are after adding Price Set.
583 $sid = $this->urlArg('sid');
584 $this->assertType('numeric', $sid);
586 $validStrings = array();
588 'Full Conference' => 'Text',
589 'Meal Choice' => 'Select',
590 'Pre-conference Meetup?' => 'Radio',
591 'Evening Sessions' => 'CheckBox',
593 $this->_testAddPriceFields($fields, $validateStrings, $financialType);
595 // load the Price Set Preview and check for expected values
596 $this->_testVerifyPriceSet($validateStrings, $sid);
598 $this->openCiviPage("contribute/add", "reset=1&action=add&context=standalone", '_qf_Contribution_upload');
600 // create new contact using dialog
601 $contact = $this->createDialogContact();
603 // select contribution type
604 $this->select('financial_type_id', "label={$financialType}");
606 // fill in Received Date
607 $this->webtestFillDate('receive_date');
610 $this->type('source', 'Mailer 1');
612 // select price set items
613 $this->select('price_set_id', "label=$setTitle");
614 $this->type("xpath=//input[@class='four crm-form-text required']", "1");
615 $this->click("xpath=//input[@class='crm-form-radio']");
616 $this->click("xpath=//input[@class='crm-form-checkbox']");
617 // select payment instrument type = Check and enter chk number
618 $this->select('payment_instrument_id', 'value=4');
619 $this->waitForElementPresent('check_number');
620 $this->type('check_number', '1041');
622 $this->type('trxn_id', 'P20901X1' . rand(100, 10000));
624 $this->webtestFillAutocomplete("{$lastNameSoft}, {$firstNameSoft}", 'soft_credit_contact_id_1');
626 $this->type('soft_credit_amount_1', "65");
627 //Additional Detail section
628 $this->click('AdditionalDetail');
629 $this->waitForElementPresent('thankyou_date');
631 $this->type('note', 'This is a test note.');
632 $this->type('invoice_id', time());
633 $this->webtestFillDate('thankyou_date');
636 $this->clickLink('_qf_Contribution_upload', "xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[8]/span/a[text()='View']", FALSE);
637 $this->assertTrue($this->isTextPresent('The contribution record has been saved.'), "Status message didn't show up after saving!");
639 //click through to the Contribution view screen
640 $this->click("xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='View']");
641 $this->waitForElementPresent('_qf_ContributionView_cancel-bottom');
643 // View Contribution Record and test for expected values
645 'From' => $contact['display_name'],
646 'Financial Type' => $financialType,
647 'Contribution Amount' => 'Contribution Total: $ 590.00',
648 'Payment Method' => 'Check',
649 'Check Number' => '1041',
650 'Contribution Status' => 'Completed',
652 $this->webtestVerifyTabularData($expected);
660 foreach ($exp as $lab => $val) {
661 $this->verifyText("xpath=id('ContributionView')/div[2]/table[1]/tbody/tr[3]/td[2]/table/tbody/tr[$lab]/td[3]",
666 // verify if soft credit was created successfully
667 $softCreditValues = array(
668 'Soft Credit To' => "{$firstNameSoft} {$lastNameSoft}",
672 foreach ($softCreditValues as $value) {
673 $this->verifyText("css=table.crm-soft-credit-listing", preg_quote($value));
676 // Check for Soft contact created
677 $this->click("css=input#sort_name_navigation");
678 $this->type("css=input#sort_name_navigation", "$lastNameSoft, $firstNameSoft");
679 $this->typeKeys("css=input#sort_name_navigation", "$lastNameSoft, $firstNameSoft");
680 // wait for result list
681 $this->waitForElementPresent("css=ul.ui-autocomplete li");
683 // visit contact summary page
684 $this->click("css=ul.ui-autocomplete li");
685 $this->waitForPageToLoad($this->getTimeoutMsec());
686 $this->click('css=li#tab_contribute a');
687 $this->waitForElementPresent('link=Record Contribution (Check, Cash, EFT ...)');
689 $id = explode('id=', $this->getAttribute("xpath=//table[@class='selector row-highlight']/tbody//tr[@id='rowid']/td[8]/a[text()='View']@href"));
690 $id = substr($id[1], 0, strpos($id[1], '&'));
691 $this->click("xpath=//table[@class='selector row-highlight']/tbody//tr[@id='rowid']/td[8]/a");
692 $this->waitForElementPresent('_qf_ContributionView_cancel-bottom');
694 $this->webtestVerifyTabularData($expected);
697 'contribution_id' => $id,
701 // Retrieve contribution from the DB via api and verify DB values against view contribution page
702 $fields = $this->webtest_civicrm_api('contribution', 'get', $params);
704 $params['id'] = $params['contact_id'] = $fields['values'][$fields['id']]['soft_credit_to'];
705 $softCreditContact = CRM_Contact_BAO_Contact
::retrieve($params, $defaults, TRUE);
707 // View Contribution Record and test for expected values
709 'From' => $fields['values'][$fields['id']]['display_name'],
710 'Financial Type' => $fields['values'][$fields['id']]['financial_type'],
711 'Contribution Amount' => $fields['values'][$fields['id']]['total_amount'],
712 'Contribution Status' => $fields['values'][$fields['id']]['contribution_status'],
713 'Payment Method' => $fields['values'][$fields['id']]['payment_instrument'],
714 'Check Number' => $fields['values'][$fields['id']]['contribution_check_number'],
717 $this->webtestVerifyTabularData($expected);
719 // verify if soft credit
720 $softCreditValues = array(
721 'Soft Credit To' => $softCreditContact->display_name
,
725 foreach ($softCreditValues as $value) {
726 $this->verifyText("css=table.crm-soft-credit-listing", preg_quote($value));