3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.3 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
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 +--------------------------------------------------------------------+
28 require_once 'CiviTest/CiviSeleniumTestCase.php';
29 class WebTest_Contribute_AddPricesetTest
extends CiviSeleniumTestCase
{
31 protected function setUp() {
35 function testAddPriceSet() {
36 // Log in using webtestLogin() method
37 $this->webtestLogin();
39 //add financial type of account type expense
41 $financialType = $this->_testAddFinancialType();
43 $setTitle = 'Conference Fees - ' . substr(sha1(rand()), 0, 7);
44 $usedFor = 'Contribution';
45 $setHelp = 'Select your conference options.';
46 $this->_testAddSet($setTitle, $usedFor, $setHelp, $financialType);
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 $elements = $this->parseURL();
51 $sid = $elements['queryString']['sid'];
52 $this->assertType('numeric', $sid);
54 $validStrings = array();
57 'Full Conference' => 'Text',
58 'Meal Choice' => 'Select',
59 'Pre-conference Meetup?' => 'Radio',
60 'Evening Sessions' => 'CheckBox',
62 $this->_testAddPriceFields( $fields, $validateStrings, $financialType );
63 // var_dump($validateStrings);
65 // load the Price Set Preview and check for expected values
66 $this->_testVerifyPriceSet($validateStrings, $sid);
69 function _testAddSet($setTitle, $usedFor, $setHelp, $financialType = NULL) {
70 $this->openCiviPage("admin/price", "reset=1&action=add", '_qf_Set_next-bottom');
72 // Enter Priceset fields (Title, Used For ...)
73 $this->type('title', $setTitle);
74 if ($usedFor == 'Event') {
75 $this->check('extends_1');
77 elseif ($usedFor == 'Contribution') {
78 $this->check('extends_2');
82 $this->select("financial_type_id", "label={$financialType}");
84 $this->type('help_pre', $setHelp);
86 $this->assertChecked('is_active', 'Verify that Is Active checkbox is set.');
87 $this->click('_qf_Set_next-bottom');
89 $this->waitForPageToLoad($this->getTimeoutMsec());
90 $this->waitForElementPresent('_qf_Field_next-bottom');
93 function _testAddPriceFields(&$fields, &$validateString, $financialType, $dateSpecificFields = FALSE) {
94 $validateStrings[] = $financialType;
95 foreach ($fields as $label => $type) {
96 $validateStrings[] = $label;
98 $this->type('label', $label);
99 $this->select('html_type', "value={$type}");
103 $validateStrings[] = '525.00';
104 $this->type('price', '525.00');
105 if ($dateSpecificFields == TRUE) {
106 $this->webtestFillDateTime('active_on', '+1 week');
109 $this->check('is_required');
115 1 => array('label' => 'Chicken',
119 'label' => 'Vegetarian',
123 $this->addMultipleChoiceOptions($options, $validateStrings);
124 if ($dateSpecificFields == TRUE) {
125 $this->webtestFillDateTime('expire_on', '-1 week');
131 1 => array('label' => 'Yes',
139 $this->addMultipleChoiceOptions($options, $validateStrings);
140 $this->check('is_required');
141 if ($dateSpecificFields == TRUE) {
142 $this->webtestFillDateTime('active_on', '-1 week');
148 1 => array('label' => 'First Night',
152 'label' => 'Second Night',
156 $this->addMultipleChoiceOptions($options, $validateStrings);
157 if ($dateSpecificFields == TRUE) {
158 $this->webtestFillDateTime('expire_on', '+1 week');
165 $this->select('financial_type_id', "label={$financialType}");
166 $this->click('_qf_Field_next_new-bottom');
167 $this->waitForPageToLoad($this->getTimeoutMsec());
168 $this->waitForElementPresent('_qf_Field_next-bottom');
172 function _testAddFinancialType() {
173 // Add new Financial Account
174 $orgName = 'Alberta '.substr(sha1(rand()), 0, 7);
175 $financialAccountTitle = 'Financial Account '.substr(sha1(rand()), 0, 4);
176 $financialAccountDescription = "{$financialAccountTitle} Description";
177 $accountingCode = 1033;
178 $financialAccountType = 'Revenue';
179 $taxDeductible = FALSE;
185 //Add new organisation
187 $this->webtestAddOrganization($orgName);
190 $this->_testAddFinancialAccount($financialAccountTitle,
191 $financialAccountDescription,
194 $financialAccountType,
201 $this->waitForElementPresent("xpath=//table/tbody//tr/td[1][text()='{$financialAccountTitle}']/../td[9]/span/a[text()='Edit']");
203 //Add new Financial Type
204 $financialType['name'] = 'FinancialType '.substr(sha1(rand()), 0, 4);
205 $financialType['is_deductible'] = TRUE;
206 $financialType['is_reserved'] = FALSE;
207 $this->addeditFinancialType($financialType);
209 $accountRelationship = "Income Account is";
210 $expected[] = array('financial_account' => $financialAccountTitle,
211 'account_relationship' => $accountRelationship
214 $this->select('account_relationship', "label={$accountRelationship}");
215 // Because it tends to cause problems, all uses of sleep() must be justified in comments
216 // Sleep should never be used for wait for anything to load from the server
217 // Justification for this instance: FIXME
219 $this->select('financial_account_id', "label={$financialAccountTitle}");
220 $this->click('_qf_FinancialTypeAccount_next');
221 $this->waitForPageToLoad($this->getTimeoutMsec());
222 $text = 'The financial type Account has been saved.';
223 $this->assertTrue($this->isTextPresent($text), 'Missing text: ' . $text);
224 return $financialType['name'];
227 function _testVerifyPriceSet($validateStrings, $sid) {
228 // verify Price Set at Preview page
229 // start at Manage Price Sets listing
230 $this->openCiviPage("admin/price", "reset=1");
232 // Use the price set id ($sid) to pick the correct row
233 $this->click("css=tr#row_{$sid} a[title='View and Edit Price Fields']");
235 $this->waitForPageToLoad($this->getTimeoutMsec());
236 // Look for Register button
237 $this->waitForElementPresent('Link=Add Price Field');
238 // Check for expected price set field strings
239 $this->assertStringsPresent($validateStrings);
242 function testContributeOfflineWithPriceSet() {
243 // Log in using webtestLogin() method
244 $this->webtestLogin();
246 //add financial type of account type expense
247 $financialType = $this->_testAddFinancialType();
249 $setTitle = 'Conference Fees - ' . substr(sha1(rand()), 0, 7);
250 $usedFor = 'Contribution';
251 $setHelp = 'Select your conference options.';
252 $this->_testAddSet($setTitle, $usedFor, $setHelp, $financialType);
254 // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form
255 // which is where we are after adding Price Set.
256 $elements = $this->parseURL();
257 $sid = $elements['queryString']['sid'];
258 $this->assertType('numeric', $sid);
260 $validStrings = array();
262 'Full Conference' => 'Text',
263 'Meal Choice' => 'Select',
264 'Pre-conference Meetup?' => 'Radio',
265 'Evening Sessions' => 'CheckBox',
267 $this->_testAddPriceFields($fields, $validateStrings, $financialType);
269 // load the Price Set Preview and check for expected values
270 $this->_testVerifyPriceSet($validateStrings, $sid);
271 $this->openCiviPage("contribute/add", "reset=1&action=add&context=standalone", '_qf_Contribution_upload');
274 // create new contact using dialog
275 $firstName = substr(sha1(rand()), 0, 7);
276 $this->webtestNewDialogContact($firstName, 'Contributor', $firstName . '@example.com');
278 // select financial type
279 $this->select('financial_type_id', "label={$financialType}");
281 // fill in Received Date
282 $this->webtestFillDate('receive_date');
285 $this->type('source', 'Mailer 1');
287 // select price set items
288 $this->select('price_set_id', "label=$setTitle");
289 $this->type("xpath=//input[@class='form-text four required']", "1");
290 $this->click("xpath=//input[@class='form-radio']");
291 $this->click("xpath=//input[@class='form-checkbox']");
292 // select payment instrument type = Check and enter chk number
293 $this->select('payment_instrument_id', 'value=4');
294 $this->waitForElementPresent('check_number');
295 $this->type('check_number', 'check #1041');
297 $this->type('trxn_id', 'P20901X1' . rand(100, 10000));
299 //Additional Detail section
300 $this->click('AdditionalDetail');
301 $this->waitForElementPresent('thankyou_date');
303 $this->type('note', 'This is a test note.');
304 $this->type('non_deductible_amount', '10');
305 $this->type('fee_amount', '0');
306 $this->type('net_amount', '0');
307 $this->type('invoice_id', time());
308 $this->webtestFillDate('thankyou_date');
311 $this->click('_qf_Contribution_upload');
312 $this->waitForPageToLoad($this->getTimeoutMsec());
314 // Is status message correct?
315 $this->assertTrue($this->isTextPresent('The contribution record has been saved.'), "Status message didn't show up after saving!");
317 $this->waitForElementPresent("xpath=//div[@id='Contributions']//table//tbody/tr[1]/td[8]/span/a[text()='View']");
319 //click through to the Membership view screen
320 $this->click("xpath=//div[@id='Contributions']//table/tbody/tr[1]/td[8]/span/a[text()='View']");
321 $this->waitForElementPresent('_qf_ContributionView_cancel-bottom');
329 foreach ($expected as $label => $value) {
330 $this->verifyText("xpath=id('ContributionView')/div[2]/table[1]/tbody/tr[$label]/td[2]", preg_quote($value));
339 foreach ($exp as $lab => $val) {
340 $this->verifyText("xpath=id('ContributionView')/div[2]/table[1]/tbody/tr[3]/td[2]/table/tbody/tr[$lab]/td[3]",
346 function _testVerifyRegisterPage($contributionPageTitle) {
347 $this->openCiviPage("admin/contribute", "reset=1", '_qf_SearchContribution_refresh');
348 $this->type('title', $contributionPageTitle);
349 $this->click('_qf_SearchContribution_refresh');
350 $this->waitForPageToLoad('50000');
351 $id = $this->getAttribute("//div[@id='configure_contribution_page']//div[@class='dataTables_wrapper']/table/tbody/tr@id");
352 $id = explode('_', $id);
353 $registerUrl = "civicrm/contribute/transact?reset=1&id=$id[1]";
357 function testContributeOnlineWithPriceSet() {
358 $this->webtestLogin();
360 //add financial type of account type expense
361 $financialType = $this->_testAddFinancialType();
363 $setTitle = 'Conference Fees - ' . substr(sha1(rand()), 0, 7);
364 $usedFor = 'Contribution';
365 $setHelp = 'Select your conference options.';
366 $this->_testAddSet($setTitle, $usedFor, $setHelp, $financialType);
368 // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form
369 // which is where we are after adding Price Set.
370 $elements = $this->parseURL();
371 $sid = $elements['queryString']['sid'];
372 $this->assertType('numeric', $sid);
374 $validStrings = array();
376 'Full Conference' => 'Text',
377 'Meal Choice' => 'Select',
378 'Pre-conference Meetup?' => 'Radio',
379 'Evening Sessions' => 'CheckBox',
382 $this->_testAddPriceFields($fields, $validateStrings, $financialType);
384 // load the Price Set Preview and check for expected values
385 $this->_testVerifyPriceSet($validateStrings, $sid);
387 // We need a payment processor
388 $processorName = 'Webtest Dummy' . substr(sha1(rand()), 0, 7);
389 $this->webtestAddPaymentProcessor($processorName);
391 $this->openCiviPage("admin/contribute/add", "reset=1&action=add");
393 $contributionTitle = substr(sha1(rand()), 0, 7);
394 $rand = 2 * rand(2, 50);
396 // fill in step 1 (Title and Settings)
397 $contributionPageTitle = "Title $contributionTitle";
398 $this->type('title', $contributionPageTitle);
399 $this->fillRichTextField('intro_text', 'This is Test Introductory Message', 'CKEditor');
400 $this->fillRichTextField('footer_text', 'This is Test Footer Message', 'CKEditor');
402 $this->select('financial_type_id', "label={$financialType}");
404 $this->click('_qf_Settings_next');
405 $this->waitForElementPresent('_qf_Amount_next-bottom');
407 //this contribution page for online contribution
408 //$this->select( 'payment_processor_id', 'label=' . $processorName );
409 $this->click("xpath=//tr[@class='crm-contribution-contributionpage-amount-form-block-payment_processor']/td/label[text()='$processorName']");
410 $this->select('price_set_id', 'label=' . $setTitle);
411 $this->click('_qf_Amount_next-bottom');
412 $this->waitForPageToLoad($this->getTimeoutMsec());
414 //get Url for Live Contribution Page
415 $registerUrl = $this->_testVerifyRegisterPage($contributionPageTitle);
418 $this->webtestLogout();
420 //Open Live Contribution Page
421 $this->open($this->sboxPath
. $registerUrl);
422 $this->waitForElementPresent('_qf_Main_upload-bottom');
424 $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
425 $lastName = 'An' . substr(sha1(rand()), 0, 7);
426 $this->waitForElementPresent('_qf_Main_upload-bottom');
427 $this->type('email-5', $firstName . '@example.com');
428 $this->type("xpath=//input[@class='form-text four required']", "1");
429 $this->click("xpath=//input[@class='form-radio']");
430 $this->click("xpath=//input[@class='form-checkbox']");
432 $streetAddress = '100 Main Street';
433 $this->type('billing_street_address-5', $streetAddress);
434 $this->type('billing_city-5', 'San Francisco');
435 $this->type('billing_postal_code-5', '94117');
436 $this->select('billing_country_id-5', 'value=1228');
437 $this->select('billing_state_province_id-5', 'value=1001');
440 $this->select('credit_card_type', 'value=Visa');
441 $this->type('credit_card_number', '4111111111111111');
442 $this->type('cvv2', '000');
443 $this->select('credit_card_exp_date[M]', 'value=1');
444 $this->select('credit_card_exp_date[Y]', 'value=2020');
447 $this->type('billing_first_name', $firstName);
448 $this->type('billing_last_name', $lastName);
449 $this->type('billing_street_address-5', '15 Main St.');
450 $this->type('billing_city-5', 'San Jose');
451 $this->select('billing_country_id-5', 'value=1228');
452 $this->select('billing_state_province_id-5', 'value=1004');
453 $this->type('billing_postal_code-5', '94129');
454 $this->click('_qf_Main_upload-bottom');
456 $this->waitForPageToLoad($this->getTimeoutMsec());
457 $this->waitForElementPresent('_qf_Confirm_next-bottom');
459 $this->click('_qf_Confirm_next-bottom');
460 $this->waitForPageToLoad($this->getTimeoutMsec());
462 //login to check contribution
464 // Log in using webtestLogin() method
465 $this->webtestLogin();
468 $this->openCiviPage("contribute/search", "reset=1", 'contribution_date_low');
470 $this->type('sort_name', "$firstName $lastName");
471 $this->click('_qf_Search_refresh');
473 $this->waitForPageToLoad($this->getTimeoutMsec());
475 $this->waitForElementPresent("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
476 $this->click("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
477 $this->waitForPageToLoad($this->getTimeoutMsec());
478 $this->waitForElementPresent("_qf_ContributionView_cancel-bottom");
480 // View Contribution Record and test for expected values
482 'From' => "{$firstName} {$lastName}",
483 'Financial Type' => $financialType,
484 'Net Amount' => '$ 590.00',
485 'Contribution Status' => 'Completed',
487 $this->webtestVerifyTabularData($expected);
491 function testContributeWithDateSpecificPriceSet() {
492 $this->webtestLogin();
494 //add financial type of account type expense
495 $financialType= $this->_testAddFinancialType();
497 $setTitle = 'Conference Fees - ' . substr(sha1(rand()), 0, 7);
498 $usedFor = 'Contribution';
499 $setHelp = 'Select your conference options.';
500 $this->_testAddSet($setTitle, $usedFor, $setHelp, $financialType);
502 // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form
503 // which is where we are after adding Price Set.
504 $elements = $this->parseURL();
505 $sid = $elements['queryString']['sid'];
506 $this->assertType('numeric', $sid);
508 $validStrings = array();
510 'Full Conference' => 'Text',
511 'Meal Choice' => 'Select',
512 'Pre-conference Meetup?' => 'Radio',
513 'Evening Sessions' => 'CheckBox',
515 $this->_testAddPriceFields($fields, $validateStrings, $financialType, TRUE);
517 // load the Price Set Preview and check for expected values
518 $this->_testVerifyPriceSet($validateStrings, $sid);
520 // We need a payment processor
521 $processorName = 'Webtest Dummy' . substr(sha1(rand()), 0, 7);
522 $this->webtestAddPaymentProcessor($processorName);
524 $this->openCiviPage("admin/contribute/add", "reset=1&action=add");
526 $contributionTitle = substr(sha1(rand()), 0, 7);
527 $rand = 2 * rand(2, 50);
529 // fill in step 1 (Title and Settings)
530 $contributionPageTitle = "Title $contributionTitle";
531 $this->type('title', $contributionPageTitle);
532 $this->select('financial_type_id', "label={$financialType}");
533 $this->fillRichTextField('intro_text', 'This is Test Introductory Message', 'CKEditor');
534 $this->fillRichTextField('footer_text', 'This is Test Footer Message', 'CKEditor');
537 $this->click('_qf_Settings_next');
538 $this->waitForElementPresent('_qf_Amount_next-bottom');
540 //this contribution page for online contribution
541 //$this->select( 'payment_processor_id', 'label=' . $processorName );
542 $this->click("xpath=//tr[@class='crm-contribution-contributionpage-amount-form-block-payment_processor']/td/label[text()='$processorName']");
543 $this->select('price_set_id', 'label=' . $setTitle);
544 $this->click('_qf_Amount_next-bottom');
545 $this->waitForPageToLoad($this->getTimeoutMsec());
547 //get Url for Live Contribution Page
548 $registerUrl = $this->_testVerifyRegisterPage($contributionPageTitle);
551 $this->webtestLogout();
553 //Open Live Contribution Page
554 $this->open($this->sboxPath
. $registerUrl);
555 $this->waitForElementPresent('_qf_Main_upload-bottom');
557 $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
558 $lastName = 'An' . substr(sha1(rand()), 0, 7);
559 $this->waitForElementPresent('_qf_Main_upload-bottom');
560 $this->type('email-5', $firstName . '@example.com');
561 $this->click("xpath=//input[@class='form-radio']");
562 $this->click("xpath=//input[@class='form-checkbox']");
564 $streetAddress = '100 Main Street';
565 $this->type('billing_street_address-5', $streetAddress);
566 $this->type('billing_city-5', 'San Francisco');
567 $this->type('billing_postal_code-5', '94117');
568 $this->select('billing_country_id-5', 'value=1228');
569 $this->select('billing_state_province_id-5', 'value=1001');
572 $this->select('credit_card_type', 'value=Visa');
573 $this->type('credit_card_number', '4111111111111111');
574 $this->type('cvv2', '000');
575 $this->select('credit_card_exp_date[M]', 'value=1');
576 $this->select('credit_card_exp_date[Y]', 'value=2020');
579 $this->type('billing_first_name', $firstName);
580 $this->type('billing_last_name', $lastName);
581 $this->type('billing_street_address-5', '15 Main St.');
582 $this->type(' billing_city-5', 'San Jose');
583 $this->select('billing_country_id-5', 'value=1228');
584 $this->select('billing_state_province_id-5', 'value=1004');
585 $this->type('billing_postal_code-5', '94129');
586 $this->click('_qf_Main_upload-bottom');
588 $this->waitForPageToLoad($this->getTimeoutMsec());
589 $this->waitForElementPresent('_qf_Confirm_next-bottom');
591 $this->click('_qf_Confirm_next-bottom');
592 $this->waitForPageToLoad($this->getTimeoutMsec());
594 //login to check contribution
596 // Log in using webtestLogin() method
597 $this->webtestLogin();
600 $this->openCiviPage("contribute/search", "reset=1", 'contribution_date_low');
602 $this->type('sort_name', "$firstName $lastName");
603 $this->click('_qf_Search_refresh');
605 $this->waitForPageToLoad($this->getTimeoutMsec());
607 $this->waitForElementPresent("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
608 $this->click("xpath=//div[@id='contributionSearch']//table//tbody/tr[1]/td[11]/span/a[text()='View']");
609 $this->waitForPageToLoad($this->getTimeoutMsec());
610 $this->waitForElementPresent('_qf_ContributionView_cancel-bottom');
612 // View Contribution Record and test for expected values
614 'From' => "{$firstName} {$lastName}",
615 'Financial Type' => $financialType,
616 'Net Amount' => '$ 65.00',
617 'Contribution Status' => 'Completed',
619 $this->webtestVerifyTabularData($expected);
622 function testContributeOfflineforSoftcreditwithApi() {
623 // Log in using webtestLogin() method
624 $this->webtestLogin();
626 //create a contact and return the contact id
627 $firstNameSoft = "John_".substr(sha1(rand()), 0, 5);
628 $lastNameSoft = "Doe_".substr(sha1(rand()), 0, 5);
629 $this->webtestAddContact($firstNameSoft, $lastNameSoft);
630 $url = $this->parseURL();
631 $cid = $url['queryString']['cid'];
632 $this->assertType('numeric', $cid);
634 $setTitle = 'Conference Fees - ' . substr(sha1(rand()), 0, 7);
635 $usedFor = 'Contribution';
636 $setHelp = 'Select your conference options.';
637 $financialType = $this->_testAddFinancialType();
638 $this->_testAddSet($setTitle, $usedFor, $setHelp, $financialType);
640 // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form
641 // which is where we are after adding Price Set.
642 $elements = $this->parseURL();
643 $sid = $elements['queryString']['sid'];
644 $this->assertType('numeric', $sid);
646 $validStrings = array();
648 'Full Conference' => 'Text',
649 'Meal Choice' => 'Select',
650 'Pre-conference Meetup?' => 'Radio',
651 'Evening Sessions' => 'CheckBox',
653 $this->_testAddPriceFields($fields, $validateStrings, $financialType);
655 // load the Price Set Preview and check for expected values
656 $this->_testVerifyPriceSet($validateStrings, $sid);
658 $this->openCiviPage("contribute/add", "reset=1&action=add&context=standalone", '_qf_Contribution_upload');
661 // create new contact using dialog
662 $firstName = substr(sha1(rand()), 0, 7);
663 $this->webtestNewDialogContact($firstName, 'Contributor', $firstName . '@example.com');
665 // select contribution type
666 $this->select('financial_type_id', "label={$financialType}");
668 // fill in Received Date
669 $this->webtestFillDate('receive_date');
672 $this->type('source', 'Mailer 1');
674 // select price set items
675 $this->select('price_set_id', "label=$setTitle");
676 $this->type("xpath=//input[@class='form-text four required']", "1");
677 $this->click("xpath=//input[@class='form-radio']");
678 $this->click("xpath=//input[@class='form-checkbox']");
679 // select payment instrument type = Check and enter chk number
680 $this->select('payment_instrument_id', 'value=4');
681 $this->waitForElementPresent('check_number');
682 $this->type('check_number', '1041');
684 $this->type('trxn_id', 'P20901X1' . rand(100, 10000));
686 $this->type('soft_credit_to', "$lastNameSoft, $firstNameSoft");
687 $this->click('soft_credit_to');
688 $this->waitForElementPresent("css=div.ac_results-inner li");
689 $this->click("css=div.ac_results-inner li");
690 //Additional Detail section
691 $this->click('AdditionalDetail');
692 $this->waitForElementPresent('thankyou_date');
694 $this->type('note', 'This is a test note.');
695 $this->type('invoice_id', time());
696 $this->webtestFillDate('thankyou_date');
699 $this->click('_qf_Contribution_upload');
700 $this->waitForPageToLoad($this->getTimeoutMsec());
702 // Is status message correct?
703 $this->waitForElementPresent("xpath=//div[@id='Contributions']//table//tbody/tr[1]/td[8]/span/a[text()='View']");
704 $this->assertTrue($this->isTextPresent('The contribution record has been saved.'), "Status message didn't show up after saving!");
706 //click through to the Contribution view screen
707 $this->click("xpath=//div[@id='Contributions']//table/tbody/tr[1]/td[8]/span/a[text()='View']");
708 $this->waitForElementPresent('_qf_ContributionView_cancel-bottom');
710 // View Contribution Record and test for expected values
712 'From' => "{$firstName} Contributor",
713 'Financial Type' => $financialType,
714 'Contribution Amount' => 'Contribution Total: $ 590.00',
715 'Paid By' => 'Check',
716 'Check Number' => '1041',
717 'Contribution Status' => 'Completed',
718 'Soft Credit To' => "$firstNameSoft $lastNameSoft",
720 $this->webtestVerifyTabularData($expected);
728 foreach ($exp as $lab => $val) {
729 $this->verifyText("xpath=id('ContributionView')/div[2]/table[1]/tbody/tr[3]/td[2]/table/tbody/tr[$lab]/td[3]",
734 // Check for Soft contact created
735 $this->click("css=input#sort_name_navigation");
736 $this->type("css=input#sort_name_navigation", "$lastNameSoft, $firstNameSoft");
737 $this->typeKeys("css=input#sort_name_navigation", "$lastNameSoft, $firstNameSoft");
738 // wait for result list
739 $this->waitForElementPresent("css=div.ac_results-inner li");
741 // visit contact summary page
742 $this->click("css=div.ac_results-inner li");
743 $this->waitForPageToLoad($this->getTimeoutMsec());
744 $this->click( 'css=li#tab_contribute a' );
745 $this->waitForElementPresent('link=Record Contribution (Check, Cash, EFT ...)');
747 $id = explode('id=', $this->getAttribute("xpath=id('rowid')/td[7]/a[text()='View']@href"));
748 $id = substr($id[1], 0, strpos($id[1], '&'));
749 $this->click("xpath=id('rowid')/td[7]/a");
750 $this->waitForElementPresent('_qf_ContributionView_cancel-bottom');
752 $this->webtestVerifyTabularData($expected);
754 $params = array('contribution_id' => $id,
758 // Retrieve contribution from the DB via api and verify DB values against view contribution page
759 require_once 'api/api.php';
760 $fields = $this->webtest_civicrm_api('contribution','get',$params );
762 $params['id'] = $params['contact_id'] = $fields['values'][$fields['id']]['soft_credit_to'];
763 $softCreditContact = CRM_Contact_BAO_Contact
::retrieve($params, $defaults, TRUE);
765 // View Contribution Record and test for expected values
767 'From' => $fields['values'][$fields['id']]['display_name'],
768 'Financial Type' => $fields['values'][$fields['id']]['financial_type'],
769 'Contribution Amount' => $fields['values'][$fields['id']]['total_amount'],
770 'Contribution Status' => $fields['values'][$fields['id']]['contribution_status'],
771 'Paid By' => $fields['values'][$fields['id']]['contribution_payment_instrument'],
772 'Check Number' => $fields['values'][$fields['id']]['contribution_check_number'],
773 'Soft Credit To' => $softCreditContact->display_name
,
775 $this->webtestVerifyTabularData($expected);