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 +--------------------------------------------------------------------+
27 require_once 'CiviTest/CiviSeleniumTestCase.php';
28 class WebTest_Contribute_StandaloneAddTest
extends CiviSeleniumTestCase
{
30 protected function setUp() {
34 function testStandaloneContributeAdd() {
35 $this->webtestLogin();
37 // Create a contact to be used as soft creditor
38 $softCreditFname = substr(sha1(rand()), 0, 7);
39 $softCreditLname = substr(sha1(rand()), 0, 7);
40 $this->webtestAddContact($softCreditFname, $softCreditLname, FALSE);
42 // Add new Financial Account
43 $orgName = 'Alberta '.substr(sha1(rand()), 0, 7);
44 $financialAccountTitle = 'Financial Account '.substr(sha1(rand()), 0, 4);
45 $financialAccountDescription = "{$financialAccountTitle} Description";
46 $accountingCode = 1033;
47 $financialAccountType = 'Asset';
48 $taxDeductible = FALSE;
54 //Add new organisation
56 $this->webtestAddOrganization($orgName);
59 $this->_testAddFinancialAccount($financialAccountTitle,
60 $financialAccountDescription,
63 $financialAccountType,
71 $this->openCiviPage("contribute/add", "reset=1&context=standalone", "_qf_Contribution_upload");
73 // create new contact using dialog
74 $firstName = substr(sha1(rand()), 0, 7);
75 $this->webtestNewDialogContact($firstName, "Contributor", $firstName . "@example.com");
77 // select financial type
78 $this->select("financial_type_id", "value=1");
80 // fill in Received Date
81 $this->webtestFillDate('receive_date');
84 $this->type("source", "Mailer 1");
87 $this->type("total_amount", "100");
89 // select payment instrument type = Check and enter chk number
90 $this->select("payment_instrument_id", "value=4");
91 $this->waitForElementPresent("check_number");
92 $this->type("check_number", "check #1041");
94 $this->type("trxn_id", "P20901X1" . rand(100, 10000));
97 $this->click("soft_credit_to");
98 $this->type("soft_credit_to", $softCreditFname);
99 $this->typeKeys("soft_credit_to", $softCreditFname);
100 $this->waitForElementPresent("css=div.ac_results-inner li");
101 $this->click("css=div.ac_results-inner li");
104 //$this->click('CIVICRM_QFID_3_6');
106 //Additional Detail section
107 $this->click("AdditionalDetail");
108 $this->waitForElementPresent("thankyou_date");
110 $this->type("note", "This is a test note.");
111 $this->type("non_deductible_amount", "10");
112 $this->type("fee_amount", "0");
113 $this->type("net_amount", "0");
114 $this->type("invoice_id", time());
115 $this->webtestFillDate('thankyou_date');
118 $this->click("Honoree");
119 $this->waitForElementPresent("honor_email");
121 $this->click("CIVICRM_QFID_1_2");
122 $this->select("honor_prefix_id", "label=Ms.");
123 $this->type("honor_first_name", "Foo");
124 $this->type("honor_last_name", "Bar");
125 $this->type("honor_email", "foo@bar.com");
128 $this->click("Premium");
129 $this->waitForElementPresent("fulfilled_date");
130 $this->select("product_name[0]", "label=Coffee Mug ( MUG-101 )");
131 $this->select("product_name[1]", "label=Black");
132 $this->webtestFillDate('fulfilled_date');
135 $this->click("_qf_Contribution_upload");
136 $this->waitForPageToLoad($this->getTimeoutMsec());
138 // Is status message correct?
139 $this->assertTrue($this->isTextPresent("The contribution record has been saved."), "Status message didn't show up after saving!");
141 // verify if Membership is created
142 $this->waitForElementPresent("xpath=//div[@id='Contributions']//table//tbody/tr[1]/td[8]/span/a[text()='View']");
144 //click through to the Membership view screen
145 $this->click("xpath=//div[@id='Contributions']//table/tbody/tr[1]/td[8]/span/a[text()='View']");
146 $this->waitForElementPresent("_qf_ContributionView_cancel-bottom");
149 'Financial Type' => 'Donation',
150 'Total Amount' => '$ 100.00',
151 'Contribution Status' => 'Completed',
152 'Paid By' => 'Check',
153 'Check Number' => 'check #1041',
154 'Soft Credit To' => "{$softCreditFname} {$softCreditLname}",
157 foreach ($expected as $label => $value) {
158 $this->verifyText("xpath=id('ContributionView')/div[2]/table[1]/tbody//tr/td[1][text()='$label']/../td[2]", preg_quote($value));
161 // go to soft creditor contact view page
162 $this->click("xpath=id('ContributionView')/div[2]/table[1]/tbody//tr/td[1][text()='Soft Credit To']/../td[2]/a[text()='{$softCreditFname} {$softCreditLname}']");
164 // go to contribution tab
165 $this->waitForElementPresent("css=li#tab_contribute a");
166 $this->click("css=li#tab_contribute a");
167 $this->waitForElementPresent("link=Record Contribution (Check, Cash, EFT ...)");
169 // verify soft credit details
174 1 => "{$firstName} Contributor",
176 foreach ($expected as $value => $label) {
177 $this->verifyText("xpath=id('Search')/div[2]/table[2]/tbody/tr[2]/td[$value]", preg_quote($label));
181 function testAjaxCustomGroupLoad() {
182 $this->webtestLogin();
183 $triggerElement = array('name' => 'financial_type_id', 'type' => 'select');
185 array('entity' => 'Contribution', 'subEntity' => 'Donation', 'triggerElement' => $triggerElement),
186 array('entity' => 'Contribution', 'subEntity' => 'Member Dues', 'triggerElement' => $triggerElement)
189 $pageUrl = array('url' => 'contribute/add', 'args' => 'reset=1&action=add&context=standalone');
190 $this->customFieldSetLoadOnTheFlyCheck($customSets, $pageUrl);