3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2016 |
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!");
285 $this->waitForElementPresent("xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span//a[text()='View']");
287 //click through to the Membership view screen
288 $this->click("xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span//a[text()='View']");
289 $this->waitForElementPresent('_qf_ContributionView_cancel-bottom');
297 foreach ($expected as $label => $value) {
298 $this->assertElementContainsText("xpath=id('ContributionView')/div[2]/table[1]/tbody/tr[$label]/td[2]", $value);
307 foreach ($exp as $lab => $val) {
308 $this->assertElementContainsText("xpath=id('ContributionView')/div[2]/table[1]/tbody/tr[3]/td[2]/table/tbody/tr[$lab]/td[3]", $val);
312 public function testContributeOnlineWithPriceSet() {
313 $this->webtestLogin();
315 //add financial type of account type expense
316 $financialType = $this->_testAddFinancialType();
318 $setTitle = 'Conference Fees - ' . substr(sha1(rand()), 0, 7);
319 $usedFor = 'Contribution';
320 $setHelp = 'Select your conference options.';
321 $this->_testAddSet($setTitle, $usedFor, $setHelp, $financialType);
323 // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form
324 // which is where we are after adding Price Set.
325 $sid = $this->urlArg('sid');
326 $this->assertType('numeric', $sid);
328 $validStrings = array();
330 'Full Conference' => 'Text',
331 'Meal Choice' => 'Select',
332 'Pre-conference Meetup?' => 'Radio',
333 'Evening Sessions' => 'CheckBox',
336 $this->_testAddPriceFields($fields, $validateStrings, $financialType);
338 // load the Price Set Preview and check for expected values
339 $this->_testVerifyPriceSet($validateStrings, $sid);
341 // Use default payment processor
342 $processorName = 'Test Processor';
343 $this->webtestAddPaymentProcessor($processorName);
345 $this->openCiviPage("admin/contribute/add", "reset=1&action=add");
347 $contributionTitle = substr(sha1(rand()), 0, 7);
348 $rand = 2 * rand(2, 50);
350 // fill in step 1 (Title and Settings)
351 $contributionPageTitle = "Title $contributionTitle";
352 $this->type('title', $contributionPageTitle);
353 $this->fillRichTextField('intro_text', 'This is Test Introductory Message', 'CKEditor');
354 $this->fillRichTextField('footer_text', 'This is Test Footer Message', 'CKEditor');
356 $this->select('financial_type_id', "label={$financialType}");
359 $this->clickLink('_qf_Settings_next', "_qf_Amount_next-bottom");
361 // Get contribution page id
362 $pageId = $this->urlArg('id');
364 //this contribution page for online contribution
365 $this->click("xpath=//tr[@class='crm-contribution-contributionpage-amount-form-block-payment_processor']/td/label[text()='$processorName']");
366 $this->select('price_set_id', 'label=' . $setTitle);
367 $this->click('_qf_Amount_next-bottom');
368 $this->waitForPageToLoad($this->getTimeoutMsec());
371 $this->webtestLogout();
373 //Open Live Contribution Page
374 $this->openCiviPage('contribute/transact', "reset=1&id=$pageId&action=preview", '_qf_Main_upload-bottom');
376 $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
377 $lastName = 'An' . substr(sha1(rand()), 0, 7);
378 $email = $firstName . "@example.com";
379 $this->waitForElementPresent('_qf_Main_upload-bottom');
380 $this->type("email-5", $email);
381 $this->type("xpath=//input[@class='four crm-form-text required']", "1");
382 $this->click("xpath=//input[@class='crm-form-radio']");
383 $this->click("xpath=//input[@class='crm-form-checkbox']");
385 $streetAddress = '100 Main Street';
386 $this->type('billing_street_address-5', $streetAddress);
387 $this->type('billing_city-5', 'San Francisco');
388 $this->type('billing_postal_code-5', '94117');
389 $this->waitForAjaxContent();
390 $this->select('billing_country_id-5', 'value=1228');
391 $this->select('billing_state_province_id-5', 'value=1001');
394 $this->select('credit_card_type', 'value=Visa');
395 $this->type('credit_card_number', '4111111111111111');
396 $this->type('cvv2', '000');
397 $this->select('credit_card_exp_date[M]', 'value=1');
398 $this->select('credit_card_exp_date[Y]', 'value=2020');
401 $this->type('billing_first_name', $firstName);
402 $this->type('billing_last_name', $lastName);
403 $this->type('billing_street_address-5', '15 Main St.');
404 $this->type('billing_city-5', 'San Jose');
405 $this->select('billing_country_id-5', 'value=1228');
406 $this->select('billing_state_province_id-5', 'value=1004');
407 $this->type('billing_postal_code-5', '94129');
408 $this->clickLink('_qf_Main_upload-bottom', '_qf_Confirm_next-bottom');
410 $this->click('_qf_Confirm_next-bottom');
411 $this->waitForPageToLoad($this->getTimeoutMsec());
413 //login to check contribution
415 // Log in using webtestLogin() method
416 $this->webtestLogin();
419 $this->openCiviPage("contribute/search", "reset=1", 'contribution_date_low');
421 $this->click("xpath=//tr/td[1]/label[contains(text(), 'Contribution is a Test?')]/../../td[2]/label[contains(text(), 'Yes')]/preceding-sibling::input[1]");
422 $this->type("sort_name", "$email");
423 $this->waitForAjaxContent();
424 $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]");
425 $this->clickLink('_qf_Search_refresh', "xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[10]/span//a[text()='View']");
426 $this->clickLink("xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[10]/span//a[text()='View']", "_qf_ContributionView_cancel-bottom", FALSE);
428 // View Contribution Record and test for expected values
430 'From' => "{$firstName} {$lastName}",
431 'Financial Type' => $financialType,
432 // as per changes made in CRM-15407
433 'Fee Amount' => '$ 1.50',
434 'Net Amount' => '$ 588.50',
435 'Contribution Status' => 'Completed',
437 $this->webtestVerifyTabularData($expected);
441 public function testContributeWithDateSpecificPriceSet() {
442 $this->webtestLogin();
444 //add financial type of account type expense
445 $financialType = $this->_testAddFinancialType();
447 $setTitle = 'Conference Fees - ' . substr(sha1(rand()), 0, 7);
448 $usedFor = 'Contribution';
449 $setHelp = 'Select your conference options.';
450 $this->_testAddSet($setTitle, $usedFor, $setHelp, $financialType);
452 // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form
453 // which is where we are after adding Price Set.
454 $sid = $this->urlArg('sid');
455 $this->assertType('numeric', $sid);
457 $validStrings = array();
459 'Full Conference' => 'Text',
460 'Meal Choice' => 'Select',
461 'Pre-conference Meetup?' => 'Radio',
462 'Evening Sessions' => 'CheckBox',
464 $this->_testAddPriceFields($fields, $validateStrings, $financialType, TRUE);
466 // load the Price Set Preview and check for expected values
467 $this->_testVerifyPriceSet($validateStrings, $sid);
469 // Use default payment processor
470 $processorName = 'Test Processor';
471 $this->webtestAddPaymentProcessor($processorName);
473 $this->openCiviPage("admin/contribute/add", "reset=1&action=add");
475 $contributionTitle = substr(sha1(rand()), 0, 7);
476 $rand = 2 * rand(2, 50);
478 // fill in step 1 (Title and Settings)
479 $contributionPageTitle = "Title $contributionTitle";
480 $this->type('title', $contributionPageTitle);
481 $this->select('financial_type_id', "label={$financialType}");
482 $this->fillRichTextField('intro_text', 'This is Test Introductory Message', 'CKEditor');
483 $this->fillRichTextField('footer_text', 'This is Test Footer Message', 'CKEditor');
486 $this->clickLink('_qf_Settings_next', "_qf_Amount_next-bottom");
488 // Get contribution page id
489 $pageId = $this->urlArg('id');
491 //this contribution page for online contribution
492 $this->waitForElementPresent("xpath=//tr[@class='crm-contribution-contributionpage-amount-form-block-payment_processor']/td");
493 $this->click("xpath=//tr[@class='crm-contribution-contributionpage-amount-form-block-payment_processor']/td/label[text()='$processorName']");
494 $this->select('price_set_id', 'label=' . $setTitle);
495 $this->clickLink('_qf_Amount_next-bottom');
498 $this->webtestLogout();
500 //Open Live Contribution Page
501 $this->openCiviPage('contribute/transact', "reset=1&id=$pageId&action=preview", '_qf_Main_upload-bottom');
503 $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
504 $lastName = 'An' . substr(sha1(rand()), 0, 7);
505 $email = $firstName . "@example.com";
506 $this->waitForElementPresent('_qf_Main_upload-bottom');
507 $this->type('email-5', $email);
508 $this->click("xpath=//input[@class='crm-form-radio']");
509 $this->click("xpath=//input[@class='crm-form-checkbox']");
511 $streetAddress = '100 Main Street';
512 $this->type('billing_street_address-5', $streetAddress);
513 $this->type('billing_city-5', 'San Francisco');
514 $this->type('billing_postal_code-5', '94117');
515 $this->select('billing_country_id-5', 'value=1228');
516 $this->select('billing_state_province_id-5', 'value=1001');
519 $this->select('credit_card_type', 'value=Visa');
520 $this->type('credit_card_number', '4111111111111111');
521 $this->type('cvv2', '000');
522 $this->select('credit_card_exp_date[M]', 'value=1');
523 $this->select('credit_card_exp_date[Y]', 'value=2020');
526 $this->type('billing_first_name', $firstName);
527 $this->type('billing_last_name', $lastName);
528 $this->type('billing_street_address-5', '15 Main St.');
529 $this->type(' billing_city-5', 'San Jose');
530 $this->select('billing_country_id-5', 'value=1228');
531 $this->select('billing_state_province_id-5', 'value=1004');
532 $this->type('billing_postal_code-5', '94129');
533 $this->clickLink('_qf_Main_upload-bottom', '_qf_Confirm_next-bottom');
535 $this->click('_qf_Confirm_next-bottom');
536 $this->waitForPageToLoad($this->getTimeoutMsec());
538 //login to check contribution
539 $this->webtestLogin();
542 $this->openCiviPage("contribute/search", "reset=1", 'contribution_date_low');
543 $this->click("xpath=//tr/td[1]/label[contains(text(), 'Contribution is a Test?')]/../../td[2]/label[contains(text(), 'Yes')]/preceding-sibling::input[1]");
544 $this->type("sort_name", "$email");
545 $this->waitForAjaxContent();
546 $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]");
547 $this->clickLink('_qf_Search_refresh', "xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[10]/span//a[text()='View']", FALSE);
548 $this->clickLink("xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[10]/span//a[text()='View']", '_qf_ContributionView_cancel-bottom', FALSE);
550 // View Contribution Record and test for expected values
552 'From' => "{$firstName} {$lastName}",
553 'Financial Type' => $financialType,
554 // as per changes made in CRM-15407
555 'Fee Amount' => '$ 1.50',
556 'Net Amount' => '$ 63.50',
557 'Contribution Status' => 'Completed',
559 $this->webtestVerifyTabularData($expected);
562 public function testContributeOfflineforSoftcreditwithApi() {
563 // Log in using webtestLogin() method
564 $this->webtestLogin();
566 //create a contact and return the contact id
567 $firstNameSoft = "John_" . substr(sha1(rand()), 0, 5);
568 $lastNameSoft = "Doe_" . substr(sha1(rand()), 0, 5);
569 $this->webtestAddContact($firstNameSoft, $lastNameSoft);
570 $url = $this->parseURL();
571 $cid = $url['queryString']['cid'];
572 $this->assertType('numeric', $cid);
574 $setTitle = 'Conference Fees - ' . substr(sha1(rand()), 0, 7);
575 $usedFor = 'Contribution';
576 $setHelp = 'Select your conference options.';
577 $financialType = $this->_testAddFinancialType();
578 $this->_testAddSet($setTitle, $usedFor, $setHelp, $financialType);
580 // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form
581 // which is where we are after adding Price Set.
582 $sid = $this->urlArg('sid');
583 $this->assertType('numeric', $sid);
585 $validStrings = array();
587 'Full Conference' => 'Text',
588 'Meal Choice' => 'Select',
589 'Pre-conference Meetup?' => 'Radio',
590 'Evening Sessions' => 'CheckBox',
592 $this->_testAddPriceFields($fields, $validateStrings, $financialType);
594 // load the Price Set Preview and check for expected values
595 $this->_testVerifyPriceSet($validateStrings, $sid);
597 $this->openCiviPage("contribute/add", "reset=1&action=add&context=standalone", '_qf_Contribution_upload');
599 // create new contact using dialog
600 $contact = $this->createDialogContact();
602 // select contribution type
603 $this->select('financial_type_id', "label={$financialType}");
605 // fill in Received Date
606 $this->webtestFillDate('receive_date');
609 $this->type('source', 'Mailer 1');
611 // select price set items
612 $this->select('price_set_id', "label=$setTitle");
613 $this->type("xpath=//input[@class='four crm-form-text required']", "1");
614 $this->click("xpath=//input[@class='crm-form-radio']");
615 $this->click("xpath=//input[@class='crm-form-checkbox']");
616 // select payment instrument type = Check and enter chk number
617 $this->select('payment_instrument_id', 'value=4');
618 $this->waitForElementPresent('check_number');
619 $this->type('check_number', '1041');
621 $this->type('trxn_id', 'P20901X1' . rand(100, 10000));
623 $this->webtestFillAutocomplete("{$lastNameSoft}, {$firstNameSoft}", 'soft_credit_contact_id_1');
625 $this->type('soft_credit_amount_1', "65");
626 //Additional Detail section
627 $this->click('AdditionalDetail');
628 $this->waitForElementPresent('thankyou_date');
630 $this->type('note', 'This is a test note.');
631 $this->type('invoice_id', time());
632 $this->webtestFillDate('thankyou_date');
635 $this->clickLink('_qf_Contribution_upload', "xpath=//table[@class='selector row-highlight']//tbody/tr[1]/td[8]/span//a[text()='View']", FALSE);
636 $this->assertTrue($this->isTextPresent('The contribution record has been saved.'), "Status message didn't show up after saving!");
638 //click through to the Contribution view screen
639 $this->click("xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='View']");
640 $this->waitForElementPresent('_qf_ContributionView_cancel-bottom');
642 // View Contribution Record and test for expected values
644 'From' => $contact['display_name'],
645 'Financial Type' => $financialType,
646 'Contribution Amount' => 'Contribution Total: $ 590.00',
647 'Payment Method' => 'Check',
648 'Check Number' => '1041',
649 'Contribution Status' => 'Completed',
651 $this->webtestVerifyTabularData($expected);
659 foreach ($exp as $lab => $val) {
660 $this->assertElementContainsText("xpath=id('ContributionView')/div[2]/table[1]/tbody/tr[3]/td[2]/table/tbody/tr[$lab]/td[3]", $val);
663 // verify if soft credit was created successfully
664 $softCreditValues = array(
665 'Soft Credit To' => "{$firstNameSoft} {$lastNameSoft}",
669 foreach ($softCreditValues as $value) {
670 $this->assertElementContainsText("css=table.crm-soft-credit-listing", $value);
673 // Check for Soft contact created
674 $this->click("css=input#sort_name_navigation");
675 $this->type("css=input#sort_name_navigation", "$lastNameSoft, $firstNameSoft");
676 $this->typeKeys("css=input#sort_name_navigation", "$lastNameSoft, $firstNameSoft");
677 // wait for result list
678 $this->waitForElementPresent("css=ul.ui-autocomplete li");
680 // visit contact summary page
681 $this->click("css=ul.ui-autocomplete li");
682 $this->waitForPageToLoad($this->getTimeoutMsec());
683 $this->click('css=li#tab_contribute a');
684 $this->waitForElementPresent('link=Record Contribution (Check, Cash, EFT ...)');
686 $id = explode('id=', $this->getAttribute("xpath=//table[@class='selector row-highlight']/tbody//tr[@id='rowid']/td[8]/a[text()='View']@href"));
687 $id = substr($id[1], 0, strpos($id[1], '&'));
688 $this->click("xpath=//table[@class='selector row-highlight']/tbody//tr[@id='rowid']/td[8]/a");
689 $this->waitForElementPresent('_qf_ContributionView_cancel-bottom');
691 $this->webtestVerifyTabularData($expected);
694 'contribution_id' => $id,
698 // Retrieve contribution from the DB via api and verify DB values against view contribution page
699 $fields = $this->webtest_civicrm_api('contribution', 'get', $params);
701 $params['id'] = $params['contact_id'] = $fields['values'][$fields['id']]['soft_credit_to'];
702 $softCreditContact = CRM_Contact_BAO_Contact
::retrieve($params, $defaults, TRUE);
704 // View Contribution Record and test for expected values
706 'From' => $fields['values'][$fields['id']]['display_name'],
707 'Financial Type' => $fields['values'][$fields['id']]['financial_type'],
708 'Contribution Amount' => $fields['values'][$fields['id']]['total_amount'],
709 'Contribution Status' => $fields['values'][$fields['id']]['contribution_status'],
710 'Payment Method' => $fields['values'][$fields['id']]['payment_instrument'],
711 'Check Number' => $fields['values'][$fields['id']]['contribution_check_number'],
714 $this->webtestVerifyTabularData($expected);
716 // verify if soft credit
717 $softCreditValues = array(
718 'Soft Credit To' => $softCreditContact->display_name
,
722 foreach ($softCreditValues as $value) {
723 $this->assertElementContainsText("css=table.crm-soft-credit-listing", $value);