3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.4 |
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->webtestFillAutocomplete("{$softCreditLname}, {$softCreditFname}", 'soft_credit_contact_1');
100 //$this->click('CIVICRM_QFID_3_6');
102 //Additional Detail section
103 $this->click("AdditionalDetail");
104 $this->waitForElementPresent("thankyou_date");
106 $this->type("note", "This is a test note.");
107 $this->type("non_deductible_amount", "10");
108 $this->type("fee_amount", "0");
109 $this->type("net_amount", "0");
110 $this->type("invoice_id", time());
111 $this->webtestFillDate('thankyou_date');
114 $this->click("Honoree");
115 $this->waitForElementPresent("honor_email");
117 $this->click("CIVICRM_QFID_1_2");
118 $this->select("honor_prefix_id", "label=Ms.");
119 $this->type("honor_first_name", "Foo");
120 $this->type("honor_last_name", "Bar");
121 $this->type("honor_email", "foo@bar.com");
124 $this->click("Premium");
125 $this->waitForElementPresent("fulfilled_date");
126 $this->select("product_name[0]", "label=Coffee Mug ( MUG-101 )");
127 $this->select("product_name[1]", "label=Black");
128 $this->webtestFillDate('fulfilled_date');
131 $this->click("_qf_Contribution_upload");
132 $this->waitForPageToLoad($this->getTimeoutMsec());
134 // Is status message correct?
135 $this->assertTrue($this->isTextPresent("The contribution record has been saved."), "Status message didn't show up after saving!");
137 // verify if Membership is created
138 $this->waitForElementPresent("xpath=//div[@id='Contributions']//table//tbody/tr[1]/td[8]/span/a[text()='View']");
140 //click through to the Membership view screen
141 $this->click("xpath=//div[@id='Contributions']//table/tbody/tr[1]/td[8]/span/a[text()='View']");
142 $this->waitForElementPresent("_qf_ContributionView_cancel-bottom");
145 'Financial Type' => 'Donation',
146 'Total Amount' => '$ 100.00',
147 'Contribution Status' => 'Completed',
148 'Paid By' => 'Check',
149 'Check Number' => 'check #1041',
152 foreach ($expected as $label => $value) {
153 $this->verifyText("xpath=id('ContributionView')/div[2]/table[1]/tbody//tr/td[1][text()='$label']/../td[2]", preg_quote($value));
156 // verify if soft credit was created successfully
158 'Soft Credit To' => "{$softCreditFname} {$softCreditLname}",
159 'Amount' => '100.00',
162 foreach ($expected as $value) {
163 $this->verifyText("css=table.crm-soft-credit-listing", preg_quote($value));
166 // go to first soft creditor contact view page
167 $this->click("css=table.crm-soft-credit-listing tbody tr td a");
169 // go to contribution tab
170 $this->waitForElementPresent("css=li#tab_contribute a");
171 $this->click("css=li#tab_contribute a");
172 $this->waitForElementPresent("link=Record Contribution (Check, Cash, EFT ...)");
174 // verify soft credit details
179 1 => "{$firstName} Contributor",
181 foreach ($expected as $value => $label) {
182 $this->verifyText("xpath=id('Search')/div[2]/table[2]/tbody/tr[2]/td[$value]", preg_quote($label));
186 function testAjaxCustomGroupLoad() {
187 $this->webtestLogin();
188 $triggerElement = array('name' => 'financial_type_id', 'type' => 'select');
190 array('entity' => 'Contribution', 'subEntity' => 'Donation', 'triggerElement' => $triggerElement),
191 array('entity' => 'Contribution', 'subEntity' => 'Member Dues', 'triggerElement' => $triggerElement)
194 $pageUrl = array('url' => 'contribute/add', 'args' => 'reset=1&action=add&context=standalone');
195 $this->customFieldSetLoadOnTheFlyCheck($customSets, $pageUrl);