Merge pull request #11949 from magnolia61/Hide_waitinglist_for_past_and_registration_...
[civicrm-core.git] / tests / phpunit / WebTest / Contribute / AddPricesetTest.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2018 |
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
27 require_once 'CiviTest/CiviSeleniumTestCase.php';
28
29 /**
30 * Class WebTest_Contribute_AddPricesetTest
31 */
32 class WebTest_Contribute_AddPricesetTest extends CiviSeleniumTestCase {
33
34 protected function setUp() {
35 parent::setUp();
36 }
37
38 public function testAddPriceSet() {
39 // Log in using webtestLogin() method
40 $this->webtestLogin();
41
42 //add financial type of account type expense
43
44 $financialType = $this->_testAddFinancialType();
45
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);
50
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);
55
56 $validStrings = array();
57
58 $fields = array(
59 'Full Conference' => 'Text',
60 'Meal Choice' => 'Select',
61 'Pre-conference Meetup?' => 'Radio',
62 'Evening Sessions' => 'CheckBox',
63 );
64 $this->_testAddPriceFields($fields, $validateStrings, $financialType);
65 // var_dump($validateStrings);
66
67 // load the Price Set Preview and check for expected values
68 $this->_testVerifyPriceSet($validateStrings, $sid);
69 }
70
71 /**
72 * @return string
73 */
74 public function _testAddFinancialType() {
75 //Add new Financial Type
76 $financialType['name'] = 'FinancialType ' . substr(sha1(rand()), 0, 4);
77 $financialType['is_deductible'] = TRUE;
78 $financialType['is_reserved'] = FALSE;
79 $this->addeditFinancialType($financialType);
80 return $financialType['name'];
81 }
82
83 /**
84 * @param $validateStrings
85 * @param int $sid
86 */
87 public function _testVerifyPriceSet($validateStrings, $sid) {
88 // verify Price Set at Preview page
89 // start at Manage Price Sets listing
90 $this->openCiviPage("admin/price", "reset=1");
91
92 // Use the price set id ($sid) to pick the correct row
93 $this->clickLink("//*[@id='price_set-{$sid}']/td[4]/span[1]/a[1]", 'Link=Add Price Field');
94 // Check for expected price set field strings
95 $this->assertStringsPresent($validateStrings);
96 }
97
98 public function testContributeOfflineWithPriceSet() {
99 // Log in using webtestLogin() method
100 $this->webtestLogin();
101
102 //add financial type of account type expense
103 $financialType = $this->_testAddFinancialType();
104
105 $setTitle = 'Conference Fees - ' . substr(sha1(rand()), 0, 7);
106 $usedFor = 'Contribution';
107 $setHelp = 'Select your conference options.';
108 $this->_testAddSet($setTitle, $usedFor, $setHelp, $financialType);
109
110 // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form
111 // which is where we are after adding Price Set.
112 $sid = $this->urlArg('sid');
113 $this->assertType('numeric', $sid);
114
115 $validStrings = array();
116 $fields = array(
117 'Full Conference' => 'Text',
118 'Meal Choice' => 'Select',
119 'Pre-conference Meetup?' => 'Radio',
120 'Evening Sessions' => 'CheckBox',
121 );
122 $this->_testAddPriceFields($fields, $validateStrings, $financialType);
123
124 // load the Price Set Preview and check for expected values
125 $this->_testVerifyPriceSet($validateStrings, $sid);
126 $this->openCiviPage("contribute/add", "reset=1&action=add&context=standalone", '_qf_Contribution_upload');
127
128 // create new contact using dialog
129 $this->createDialogContact();
130
131 // select financial type
132 $this->select('financial_type_id', "label={$financialType}");
133
134 // fill in Received Date
135 $this->webtestFillDate('receive_date');
136
137 // source
138 $this->type('source', 'Mailer 1');
139
140 // select price set items
141 $this->select('price_set_id', "label=$setTitle");
142 $this->type("xpath=//input[@class='four crm-form-text required']", "1");
143 $this->click("xpath=//input[@class='crm-form-radio']");
144 $this->click("xpath=//input[@class='crm-form-checkbox']");
145 // select payment instrument type = Check and enter chk number
146 $this->select('payment_instrument_id', 'value=4');
147 $this->waitForElementPresent('check_number');
148 $this->type('check_number', 'check #1041');
149
150 $this->type('trxn_id', 'P20901X1' . rand(100, 10000));
151
152 //Additional Detail section
153 $this->click('AdditionalDetail');
154 $this->waitForElementPresent('thankyou_date');
155
156 $this->type('note', 'This is a test note.');
157 $this->type('non_deductible_amount', '10');
158 $this->type('fee_amount', '0');
159 $this->type('net_amount', '0');
160 $this->type('invoice_id', time());
161 $this->webtestFillDate('thankyou_date');
162
163 // Clicking save.
164 $this->click('_qf_Contribution_upload');
165 $this->waitForPageToLoad($this->getTimeoutMsec());
166
167 // Is status message correct?
168 $this->assertTrue($this->isTextPresent('The contribution record has been saved.'), "Status message didn't show up after saving!");
169 $this->waitForElementPresent("xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span//a[text()='View']");
170
171 //click through to the Membership view screen
172 $this->click("xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span//a[text()='View']");
173 $this->waitForElementPresent('_qf_ContributionView_cancel-bottom');
174 $expected = array(
175 2 => $financialType,
176 3 => '590.00',
177 9 => 'Completed',
178 10 => 'Check',
179 11 => 'check #1041',
180 );
181 foreach ($expected as $label => $value) {
182 $this->assertElementContainsText("xpath=id('ContributionView')/div[2]/table[1]/tbody/tr[$label]/td[2]", $value);
183 }
184
185 $exp = array(
186 2 => '$ 525.00',
187 3 => '$ 50.00',
188 4 => '$ 15.00',
189 );
190
191 foreach ($exp as $lab => $val) {
192 $this->assertElementContainsText("xpath=id('ContributionView')/div[2]/table[1]/tbody/tr[3]/td[2]/table/tbody/tr[$lab]/td[3]", $val);
193 }
194 }
195
196 public function testContributeOnlineWithPriceSet() {
197 $this->webtestLogin();
198
199 //add financial type of account type expense
200 $financialType = $this->_testAddFinancialType();
201
202 $setTitle = 'Conference Fees - ' . substr(sha1(rand()), 0, 7);
203 $usedFor = 'Contribution';
204 $setHelp = 'Select your conference options.';
205 $this->_testAddSet($setTitle, $usedFor, $setHelp, $financialType);
206
207 // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form
208 // which is where we are after adding Price Set.
209 $sid = $this->urlArg('sid');
210 $this->assertType('numeric', $sid);
211
212 $validStrings = array();
213 $fields = array(
214 'Full Conference' => 'Text',
215 'Meal Choice' => 'Select',
216 'Pre-conference Meetup?' => 'Radio',
217 'Evening Sessions' => 'CheckBox',
218 );
219
220 $this->_testAddPriceFields($fields, $validateStrings, $financialType);
221
222 // load the Price Set Preview and check for expected values
223 $this->_testVerifyPriceSet($validateStrings, $sid);
224
225 // Use default payment processor
226 $processorName = 'Test Processor';
227 $this->webtestAddPaymentProcessor($processorName);
228
229 $this->openCiviPage("admin/contribute/add", "reset=1&action=add");
230
231 $contributionTitle = substr(sha1(rand()), 0, 7);
232 $rand = 2 * rand(2, 50);
233
234 // fill in step 1 (Title and Settings)
235 $contributionPageTitle = "Title $contributionTitle";
236 $this->type('title', $contributionPageTitle);
237 $this->fillRichTextField('intro_text', 'This is Test Introductory Message', 'CKEditor');
238 $this->fillRichTextField('footer_text', 'This is Test Footer Message', 'CKEditor');
239
240 $this->select('financial_type_id', "label={$financialType}");
241
242 // Submit form
243 $this->clickLink('_qf_Settings_next', "_qf_Amount_next-bottom");
244
245 // Get contribution page id
246 $pageId = $this->urlArg('id');
247
248 //this contribution page for online contribution
249 $this->click("xpath=//tr[@class='crm-contribution-contributionpage-amount-form-block-payment_processor']/td/label[text()='$processorName']");
250 $this->select('price_set_id', 'label=' . $setTitle);
251 $this->click('_qf_Amount_next-bottom');
252 $this->waitForPageToLoad($this->getTimeoutMsec());
253
254 //logout
255 $this->webtestLogout();
256
257 //Open Live Contribution Page
258 $this->openCiviPage('contribute/transact', "reset=1&id=$pageId&action=preview", '_qf_Main_upload-bottom');
259
260 $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
261 $lastName = 'An' . substr(sha1(rand()), 0, 7);
262 $email = $firstName . "@example.com";
263 $this->waitForElementPresent('_qf_Main_upload-bottom');
264 $this->type("email-5", $email);
265 $this->type("xpath=//input[@class='four crm-form-text required']", "1");
266 $this->click("xpath=//input[@class='crm-form-radio']");
267 $this->click("xpath=//input[@class='crm-form-checkbox']");
268
269 $streetAddress = '100 Main Street';
270 $this->type('billing_street_address-5', $streetAddress);
271 $this->type('billing_city-5', 'San Francisco');
272 $this->type('billing_postal_code-5', '94117');
273 $this->waitForAjaxContent();
274 $this->select('billing_country_id-5', 'value=1228');
275 $this->select('billing_state_province_id-5', 'value=1001');
276
277 //Credit Card Info
278 $this->select('credit_card_type', 'value=Visa');
279 $this->type('credit_card_number', '4111111111111111');
280 $this->type('cvv2', '000');
281 $this->select('credit_card_exp_date[M]', 'value=1');
282 $this->select('credit_card_exp_date[Y]', 'value=2020');
283
284 //Billing Info
285 $this->type('billing_first_name', $firstName);
286 $this->type('billing_last_name', $lastName);
287 $this->type('billing_street_address-5', '15 Main St.');
288 $this->type('billing_city-5', 'San Jose');
289 $this->select('billing_country_id-5', 'value=1228');
290 $this->select('billing_state_province_id-5', 'value=1004');
291 $this->type('billing_postal_code-5', '94129');
292 $this->clickLink('_qf_Main_upload-bottom', '_qf_Confirm_next-bottom');
293
294 $this->click('_qf_Confirm_next-bottom');
295 $this->waitForPageToLoad($this->getTimeoutMsec());
296
297 //login to check contribution
298
299 // Log in using webtestLogin() method
300 $this->webtestLogin();
301
302 //Find Contribution
303 $this->openCiviPage("contribute/search", "reset=1", 'contribution_date_low');
304
305 $this->click("xpath=//tr/td[1]/label[contains(text(), 'Contribution is a Test?')]/../../td[2]/label[contains(text(), 'Yes')]/preceding-sibling::input[1]");
306 $this->type("sort_name", "$email");
307 $this->waitForAjaxContent();
308 $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]");
309 $this->clickLink('_qf_Search_refresh', "xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[10]/span//a[text()='View']");
310 $this->clickLink("xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[10]/span//a[text()='View']", "_qf_ContributionView_cancel-bottom", FALSE);
311
312 // View Contribution Record and test for expected values
313 $expected = array(
314 'From' => "{$firstName} {$lastName}",
315 'Financial Type' => $financialType,
316 // as per changes made in CRM-15407
317 'Fee Amount' => '$ 1.50',
318 'Net Amount' => '$ 588.50',
319 'Contribution Status' => 'Completed',
320 );
321 $this->webtestVerifyTabularData($expected);
322
323 }
324
325 public function testContributeWithDateSpecificPriceSet() {
326 $this->webtestLogin();
327
328 //add financial type of account type expense
329 $financialType = $this->_testAddFinancialType();
330
331 $setTitle = 'Conference Fees - ' . substr(sha1(rand()), 0, 7);
332 $usedFor = 'Contribution';
333 $setHelp = 'Select your conference options.';
334 $this->_testAddSet($setTitle, $usedFor, $setHelp, $financialType);
335
336 // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form
337 // which is where we are after adding Price Set.
338 $sid = $this->urlArg('sid');
339 $this->assertType('numeric', $sid);
340
341 $validStrings = array();
342 $fields = array(
343 'Full Conference' => 'Text',
344 'Meal Choice' => 'Select',
345 'Pre-conference Meetup?' => 'Radio',
346 'Evening Sessions' => 'CheckBox',
347 );
348 $this->_testAddPriceFields($fields, $validateStrings, $financialType, TRUE);
349
350 // load the Price Set Preview and check for expected values
351 $this->_testVerifyPriceSet($validateStrings, $sid);
352
353 // Use default payment processor
354 $processorName = 'Test Processor';
355 $this->webtestAddPaymentProcessor($processorName);
356
357 $this->openCiviPage("admin/contribute/add", "reset=1&action=add");
358
359 $contributionTitle = substr(sha1(rand()), 0, 7);
360 $rand = 2 * rand(2, 50);
361
362 // fill in step 1 (Title and Settings)
363 $contributionPageTitle = "Title $contributionTitle";
364 $this->type('title', $contributionPageTitle);
365 $this->select('financial_type_id', "label={$financialType}");
366 $this->fillRichTextField('intro_text', 'This is Test Introductory Message', 'CKEditor');
367 $this->fillRichTextField('footer_text', 'This is Test Footer Message', 'CKEditor');
368
369 // Submit form
370 $this->clickLink('_qf_Settings_next', "_qf_Amount_next-bottom");
371
372 // Get contribution page id
373 $pageId = $this->urlArg('id');
374
375 //this contribution page for online contribution
376 $this->waitForElementPresent("xpath=//tr[@class='crm-contribution-contributionpage-amount-form-block-payment_processor']/td");
377 $this->click("xpath=//tr[@class='crm-contribution-contributionpage-amount-form-block-payment_processor']/td/label[text()='$processorName']");
378 $this->select('price_set_id', 'label=' . $setTitle);
379 $this->clickLink('_qf_Amount_next-bottom');
380
381 //logout
382 $this->webtestLogout();
383
384 //Open Live Contribution Page
385 $this->openCiviPage('contribute/transact', "reset=1&id=$pageId&action=preview", '_qf_Main_upload-bottom');
386
387 $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
388 $lastName = 'An' . substr(sha1(rand()), 0, 7);
389 $email = $firstName . "@example.com";
390 $this->waitForElementPresent('_qf_Main_upload-bottom');
391 $this->type('email-5', $email);
392 $this->click("xpath=//input[@class='crm-form-radio']");
393 $this->click("xpath=//input[@class='crm-form-checkbox']");
394
395 $streetAddress = '100 Main Street';
396 $this->type('billing_street_address-5', $streetAddress);
397 $this->type('billing_city-5', 'San Francisco');
398 $this->type('billing_postal_code-5', '94117');
399 $this->select('billing_country_id-5', 'value=1228');
400 $this->select('billing_state_province_id-5', 'value=1001');
401
402 //Credit Card Info
403 $this->select('credit_card_type', 'value=Visa');
404 $this->type('credit_card_number', '4111111111111111');
405 $this->type('cvv2', '000');
406 $this->select('credit_card_exp_date[M]', 'value=1');
407 $this->select('credit_card_exp_date[Y]', 'value=2020');
408
409 //Billing Info
410 $this->type('billing_first_name', $firstName);
411 $this->type('billing_last_name', $lastName);
412 $this->type('billing_street_address-5', '15 Main St.');
413 $this->type(' billing_city-5', 'San Jose');
414 $this->select('billing_country_id-5', 'value=1228');
415 $this->select('billing_state_province_id-5', 'value=1004');
416 $this->type('billing_postal_code-5', '94129');
417 $this->clickLink('_qf_Main_upload-bottom', '_qf_Confirm_next-bottom');
418
419 $this->click('_qf_Confirm_next-bottom');
420 $this->waitForPageToLoad($this->getTimeoutMsec());
421
422 //login to check contribution
423 $this->webtestLogin();
424
425 //Find Contribution
426 $this->openCiviPage("contribute/search", "reset=1", 'contribution_date_low');
427 $this->click("xpath=//tr/td[1]/label[contains(text(), 'Contribution is a Test?')]/../../td[2]/label[contains(text(), 'Yes')]/preceding-sibling::input[1]");
428 $this->type("sort_name", "$email");
429 $this->waitForAjaxContent();
430 $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]");
431 $this->clickLink('_qf_Search_refresh', "xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[10]/span//a[text()='View']", FALSE);
432 $this->clickLink("xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[10]/span//a[text()='View']", '_qf_ContributionView_cancel-bottom', FALSE);
433
434 // View Contribution Record and test for expected values
435 $expected = array(
436 'From' => "{$firstName} {$lastName}",
437 'Financial Type' => $financialType,
438 // as per changes made in CRM-15407
439 'Fee Amount' => '$ 1.50',
440 'Net Amount' => '$ 63.50',
441 'Contribution Status' => 'Completed',
442 );
443 $this->webtestVerifyTabularData($expected);
444 }
445
446 public function testContributeOfflineforSoftcreditwithApi() {
447 // Log in using webtestLogin() method
448 $this->webtestLogin();
449
450 //create a contact and return the contact id
451 $firstNameSoft = "John_" . substr(sha1(rand()), 0, 5);
452 $lastNameSoft = "Doe_" . substr(sha1(rand()), 0, 5);
453 $this->webtestAddContact($firstNameSoft, $lastNameSoft);
454 $url = $this->parseURL();
455 $cid = $url['queryString']['cid'];
456 $this->assertType('numeric', $cid);
457
458 $setTitle = 'Conference Fees - ' . substr(sha1(rand()), 0, 7);
459 $usedFor = 'Contribution';
460 $setHelp = 'Select your conference options.';
461 $financialType = $this->_testAddFinancialType();
462 $this->_testAddSet($setTitle, $usedFor, $setHelp, $financialType);
463
464 // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form
465 // which is where we are after adding Price Set.
466 $sid = $this->urlArg('sid');
467 $this->assertType('numeric', $sid);
468
469 $validStrings = array();
470 $fields = array(
471 'Full Conference' => 'Text',
472 'Meal Choice' => 'Select',
473 'Pre-conference Meetup?' => 'Radio',
474 'Evening Sessions' => 'CheckBox',
475 );
476 $this->_testAddPriceFields($fields, $validateStrings, $financialType);
477
478 // load the Price Set Preview and check for expected values
479 $this->_testVerifyPriceSet($validateStrings, $sid);
480
481 $this->openCiviPage("contribute/add", "reset=1&action=add&context=standalone", '_qf_Contribution_upload');
482
483 // create new contact using dialog
484 $contact = $this->createDialogContact();
485
486 // select contribution type
487 $this->select('financial_type_id', "label={$financialType}");
488
489 // fill in Received Date
490 $this->webtestFillDate('receive_date');
491
492 // source
493 $this->type('source', 'Mailer 1');
494
495 // select price set items
496 $this->select('price_set_id', "label=$setTitle");
497 $this->type("xpath=//input[@class='four crm-form-text required']", "1");
498 $this->click("xpath=//input[@class='crm-form-radio']");
499 $this->click("xpath=//input[@class='crm-form-checkbox']");
500 // select payment instrument type = Check and enter chk number
501 $this->select('payment_instrument_id', 'value=4');
502 $this->waitForElementPresent('check_number');
503 $this->type('check_number', '1041');
504
505 $this->type('trxn_id', 'P20901X1' . rand(100, 10000));
506
507 $this->webtestFillAutocomplete("{$lastNameSoft}, {$firstNameSoft}", 'soft_credit_contact_id_1');
508
509 $this->type('soft_credit_amount_1', "65");
510 //Additional Detail section
511 $this->click('AdditionalDetail');
512 $this->waitForElementPresent('thankyou_date');
513
514 $this->type('note', 'This is a test note.');
515 $this->type('invoice_id', time());
516 $this->webtestFillDate('thankyou_date');
517
518 // Clicking save.
519 $this->clickLink('_qf_Contribution_upload', "xpath=//table[@class='selector row-highlight']//tbody/tr[1]/td[8]/span//a[text()='View']", FALSE);
520 $this->assertTrue($this->isTextPresent('The contribution record has been saved.'), "Status message didn't show up after saving!");
521
522 //click through to the Contribution view screen
523 $this->click("xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='View']");
524 $this->waitForElementPresent('_qf_ContributionView_cancel-bottom');
525
526 // View Contribution Record and test for expected values
527 $expected = array(
528 'From' => $contact['display_name'],
529 'Financial Type' => $financialType,
530 'Contribution Amount' => 'Contribution Total: $ 590.00',
531 'Payment Method' => 'Check',
532 'Check Number' => '1041',
533 'Contribution Status' => 'Completed',
534 );
535 $this->webtestVerifyTabularData($expected);
536
537 $exp = array(
538 2 => '$ 525.00',
539 3 => '$ 50.00',
540 4 => '$ 15.00',
541 );
542
543 foreach ($exp as $lab => $val) {
544 $this->assertElementContainsText("xpath=id('ContributionView')/div[2]/table[1]/tbody/tr[3]/td[2]/table/tbody/tr[$lab]/td[3]", $val);
545 }
546
547 // verify if soft credit was created successfully
548 $softCreditValues = array(
549 'Soft Credit To' => "{$firstNameSoft} {$lastNameSoft}",
550 'Amount' => '65.00',
551 );
552
553 foreach ($softCreditValues as $value) {
554 $this->assertElementContainsText("css=table.crm-soft-credit-listing", $value);
555 }
556
557 // Check for Soft contact created
558 $this->click("css=input#sort_name_navigation");
559 $this->type("css=input#sort_name_navigation", "$lastNameSoft, $firstNameSoft");
560 $this->typeKeys("css=input#sort_name_navigation", "$lastNameSoft, $firstNameSoft");
561 // wait for result list
562 $this->waitForElementPresent("css=ul.ui-autocomplete li");
563
564 // visit contact summary page
565 $this->click("css=ul.ui-autocomplete li");
566 $this->waitForPageToLoad($this->getTimeoutMsec());
567 $this->click('css=li#tab_contribute a');
568 $this->waitForElementPresent('link=Record Contribution (Check, Cash, EFT ...)');
569
570 $id = explode('id=', $this->getAttribute("xpath=//table[@class='selector row-highlight']/tbody//tr[@id='rowid']/td[8]/a[text()='View']@href"));
571 $id = substr($id[1], 0, strpos($id[1], '&'));
572 $this->click("xpath=//table[@class='selector row-highlight']/tbody//tr[@id='rowid']/td[8]/a");
573 $this->waitForElementPresent('_qf_ContributionView_cancel-bottom');
574
575 $this->webtestVerifyTabularData($expected);
576
577 $params = array(
578 'contribution_id' => $id,
579 'version' => 3,
580 );
581
582 // Retrieve contribution from the DB via api and verify DB values against view contribution page
583 $fields = $this->webtest_civicrm_api('contribution', 'get', $params);
584
585 $params['id'] = $params['contact_id'] = $fields['values'][$fields['id']]['soft_credit_to'];
586 $softCreditContact = CRM_Contact_BAO_Contact::retrieve($params, $defaults, TRUE);
587
588 // View Contribution Record and test for expected values
589 $expected = array(
590 'From' => $fields['values'][$fields['id']]['display_name'],
591 'Financial Type' => $fields['values'][$fields['id']]['financial_type'],
592 'Contribution Amount' => $fields['values'][$fields['id']]['total_amount'],
593 'Contribution Status' => $fields['values'][$fields['id']]['contribution_status'],
594 'Payment Method' => $fields['values'][$fields['id']]['payment_instrument'],
595 'Check Number' => $fields['values'][$fields['id']]['contribution_check_number'],
596 );
597
598 $this->webtestVerifyTabularData($expected);
599
600 // verify if soft credit
601 $softCreditValues = array(
602 'Soft Credit To' => $softCreditContact->display_name,
603 'Amount' => '65.00',
604 );
605
606 foreach ($softCreditValues as $value) {
607 $this->assertElementContainsText("css=table.crm-soft-credit-listing", $value);
608 }
609 }
610
611 }