Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
4 | | CiviCRM version 4.3 | | |
5 | +--------------------------------------------------------------------+ | |
6 | | Copyright CiviCRM LLC (c) 2004-2013 | | |
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 | ||
6a488035 TO |
27 | require_once 'CiviTest/CiviSeleniumTestCase.php'; |
28 | class WebTest_Contribute_StandaloneAddTest extends CiviSeleniumTestCase { | |
29 | ||
30 | protected function setUp() { | |
31 | parent::setUp(); | |
32 | } | |
33 | ||
34 | function testStandaloneContributeAdd() { | |
6a488035 TO |
35 | $this->webtestLogin(); |
36 | ||
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); | |
41 | ||
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; | |
49 | $isActive = FALSE; | |
50 | $isTax = TRUE; | |
51 | $taxRate = 9.9999999; | |
52 | $isDefault = FALSE; | |
76e86fd8 | 53 | |
6a488035 TO |
54 | //Add new organisation |
55 | if($orgName) { | |
56 | $this->webtestAddOrganization($orgName); | |
57 | } | |
76e86fd8 | 58 | |
6a488035 TO |
59 | $this->_testAddFinancialAccount($financialAccountTitle, |
60 | $financialAccountDescription, | |
61 | $accountingCode, | |
62 | $orgName, | |
63 | $financialAccountType, | |
64 | $taxDeductible, | |
65 | $isActive, | |
66 | $isTax, | |
67 | $taxRate, | |
68 | $isDefault | |
69 | ); | |
70 | ||
42daf119 | 71 | $this->openCiviPage("contribute/add", "reset=1&context=standalone", "_qf_Contribution_upload"); |
6a488035 | 72 | |
6a488035 TO |
73 | // create new contact using dialog |
74 | $firstName = substr(sha1(rand()), 0, 7); | |
75 | $this->webtestNewDialogContact($firstName, "Contributor", $firstName . "@example.com"); | |
76e86fd8 | 76 | |
6a488035 TO |
77 | // select financial type |
78 | $this->select("financial_type_id", "value=1"); | |
76e86fd8 | 79 | |
6a488035 TO |
80 | // fill in Received Date |
81 | $this->webtestFillDate('receive_date'); | |
82 | ||
83 | // source | |
84 | $this->type("source", "Mailer 1"); | |
85 | ||
86 | // total amount | |
87 | $this->type("total_amount", "100"); | |
88 | ||
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"); | |
76e86fd8 | 93 | |
6a488035 TO |
94 | $this->type("trxn_id", "P20901X1" . rand(100, 10000)); |
95 | ||
96 | // soft credit | |
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"); | |
102 | ||
103 | //Custom Data | |
104 | //$this->click('CIVICRM_QFID_3_6'); | |
105 | ||
106 | //Additional Detail section | |
107 | $this->click("AdditionalDetail"); | |
108 | $this->waitForElementPresent("thankyou_date"); | |
109 | ||
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'); | |
116 | ||
117 | //Honoree section | |
118 | $this->click("Honoree"); | |
119 | $this->waitForElementPresent("honor_email"); | |
120 | ||
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"); | |
126 | ||
127 | //Premium section | |
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'); | |
133 | ||
134 | // Clicking save. | |
135 | $this->click("_qf_Contribution_upload"); | |
136 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
137 | ||
138 | // Is status message correct? | |
139 | $this->assertTrue($this->isTextPresent("The contribution record has been saved."), "Status message didn't show up after saving!"); | |
140 | ||
141 | // verify if Membership is created | |
142 | $this->waitForElementPresent("xpath=//div[@id='Contributions']//table//tbody/tr[1]/td[8]/span/a[text()='View']"); | |
143 | ||
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"); | |
147 | ||
148 | $expected = array( | |
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}", | |
155 | ); | |
156 | ||
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)); | |
159 | } | |
160 | ||
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}']"); | |
76e86fd8 | 163 | |
6a488035 TO |
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 ...)"); | |
168 | ||
169 | // verify soft credit details | |
170 | $expected = array( | |
171 | 3 => 'Donation', | |
172 | 2 => '100.00', | |
173 | 5 => 'Completed', | |
174 | 1 => "{$firstName} Contributor", | |
175 | ); | |
176 | foreach ($expected as $value => $label) { | |
177 | $this->verifyText("xpath=id('Search')/div[2]/table[2]/tbody/tr[2]/td[$value]", preg_quote($label)); | |
178 | } | |
179 | } | |
6a488035 | 180 | |
c4e6d4e8 PJ |
181 | function testAjaxCustomGroupLoad() { |
182 | $this->webtestLogin(); | |
183 | $triggerElement = array('name' => 'financial_type_id', 'type' => 'select'); | |
184 | $customSets = array( | |
185 | array('entity' => 'Contribution', 'subEntity' => 'Donation', 'triggerElement' => $triggerElement), | |
186 | array('entity' => 'Contribution', 'subEntity' => 'Member Dues', 'triggerElement' => $triggerElement) | |
187 | ); | |
188 | ||
189 | $pageUrl = array('url' => 'contribute/add', 'args' => 'reset=1&action=add&context=standalone'); | |
190 | $this->customFieldSetLoadOnTheFlyCheck($customSets, $pageUrl); | |
191 | } | |
192 | } |