Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
6a488035 TO |
2 | /* |
3 | +--------------------------------------------------------------------+ | |
81621fee | 4 | | CiviCRM version 4.7 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
fa938177 | 6 | | Copyright CiviCRM LLC (c) 2004-2016 | |
6a488035 TO |
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 | +--------------------------------------------------------------------+ | |
d25dd0ee | 25 | */ |
6a488035 TO |
26 | |
27 | require_once 'CiviTest/CiviSeleniumTestCase.php'; | |
28 | ||
e9479dcf EM |
29 | /** |
30 | * Class WebTest_Contribute_OfflineContributionTest | |
31 | */ | |
6a488035 TO |
32 | class WebTest_Contribute_OfflineContributionTest extends CiviSeleniumTestCase { |
33 | ||
6a488035 TO |
34 | protected function setUp() { |
35 | parent::setUp(); | |
36 | } | |
76e86fd8 | 37 | |
00be9182 | 38 | public function testStandaloneContributeAdd() { |
6a488035 TO |
39 | $this->webtestLogin(); |
40 | ||
41 | // Create a contact to be used as soft creditor | |
42 | $softCreditFname = substr(sha1(rand()), 0, 7); | |
43 | $softCreditLname = substr(sha1(rand()), 0, 7); | |
06321b47 | 44 | $this->webtestAddContact($softCreditFname, $softCreditLname, FALSE); |
76e86fd8 | 45 | |
6a488035 | 46 | //financial account for check |
118e964e | 47 | $this->openCiviPage("admin/options/payment_instrument", "reset=1"); |
5c80555f | 48 | $financialAccount = $this->getText("xpath=//div[@id='payment_instrument']/table/tbody//tr/td[1]/div[text()='Check']/../../td[3]"); |
76e86fd8 | 49 | |
6a488035 | 50 | // Add new Financial Account |
06321b47 | 51 | $orgName = 'Alberta ' . substr(sha1(rand()), 0, 7); |
52 | $financialAccountTitle = 'Financial Account ' . substr(sha1(rand()), 0, 4); | |
6a488035 TO |
53 | $financialAccountDescription = "{$financialAccountTitle} Description"; |
54 | $accountingCode = 1033; | |
55 | $financialAccountType = 'Asset'; | |
56 | $taxDeductible = FALSE; | |
57 | $isActive = FALSE; | |
58 | $isTax = TRUE; | |
59 | $taxRate = 9; | |
60 | $isDefault = FALSE; | |
76e86fd8 | 61 | |
6a488035 | 62 | //Add new organisation |
06321b47 | 63 | if ($orgName) { |
6a488035 TO |
64 | $this->webtestAddOrganization($orgName); |
65 | } | |
76e86fd8 | 66 | |
6a488035 TO |
67 | $this->_testAddFinancialAccount($financialAccountTitle, |
68 | $financialAccountDescription, | |
69 | $accountingCode, | |
70 | $orgName, | |
71 | $financialAccountType, | |
72 | $taxDeductible, | |
73 | $isActive, | |
74 | $isTax, | |
75 | $taxRate, | |
76 | $isDefault | |
77 | ); | |
78 | ||
06321b47 | 79 | $firstName = 'John' . substr(sha1(rand()), 0, 7); |
80 | $lastName = 'Dsouza' . substr(sha1(rand()), 0, 7); | |
6a488035 | 81 | $this->webtestAddContact($firstName, $lastName); |
76e86fd8 | 82 | |
6a488035 TO |
83 | $this->waitForElementPresent("css=li#tab_contribute a"); |
84 | $this->click("css=li#tab_contribute a"); | |
85 | $this->waitForElementPresent("link=Record Contribution (Check, Cash, EFT ...)"); | |
3bbf7318 | 86 | $this->clickLink("link=Record Contribution (Check, Cash, EFT ...)", "_qf_Contribution_cancel-bottom", FALSE); |
6a488035 TO |
87 | |
88 | // select financial type | |
89 | $this->select("financial_type_id", "value=1"); | |
76e86fd8 | 90 | |
6a488035 TO |
91 | // fill in Received Date |
92 | $this->webtestFillDate('receive_date'); | |
76e86fd8 | 93 | |
6a488035 TO |
94 | // source |
95 | $this->type("source", "Mailer 1"); | |
76e86fd8 | 96 | |
6a488035 TO |
97 | // total amount |
98 | $this->type("total_amount", "100"); | |
99 | ||
100 | // select payment instrument type = Check and enter chk number | |
101 | $this->select("payment_instrument_id", "value=4"); | |
102 | $this->waitForElementPresent("check_number"); | |
103 | $this->type("check_number", "check #1041"); | |
104 | ||
105 | $this->type("trxn_id", "P20901X1" . rand(100, 10000)); | |
76e86fd8 | 106 | |
5d48a234 | 107 | // create first soft credit |
3bbf7318 | 108 | $this->click("softCredit"); |
109 | $this->waitForElementPresent("soft_credit_amount_1"); | |
110 | $this->webtestFillAutocomplete("{$softCreditLname}, {$softCreditFname}", 's2id_soft_credit_contact_id_1'); | |
5d48a234 | 111 | $this->type("soft_credit_amount_1", "50"); |
06321b47 | 112 | |
5d48a234 S |
113 | // add second soft credit field |
114 | $this->click("addMoreSoftCredit"); | |
115 | $this->waitForElementPresent("soft_credit_amount_2"); | |
51fa20cb | 116 | // create new individual via soft credit |
5d48a234 | 117 | $softCreditSecondFname = substr(sha1(rand()), 0, 7); |
06321b47 | 118 | $softCreditSecondLname = substr(sha1(rand()), 0, 7); |
3bbf7318 | 119 | $this->webtestNewDialogContact($softCreditSecondFname, $softCreditSecondLname, NULL, 4, 's2id_soft_credit_contact_id_2', 'soft_credit_1'); |
5d48a234 | 120 | // enter the second soft credit |
06321b47 | 121 | $this->verifyText("soft_credit_amount_2", ""); // it should be blank cause first soft credit != total_amount |
122 | $this->type("soft_credit_amount_2", "100"); //the sum of the soft credit amounts can exceed total_amount | |
51fa20cb | 123 | $this->select("soft_credit_type[2]", "In Honor of"); |
6a488035 TO |
124 | |
125 | //Custom Data | |
126 | // $this->click('CIVICRM_QFID_3_6'); | |
127 | ||
128 | //Additional Detail section | |
129 | $this->click("AdditionalDetail"); | |
130 | $this->waitForElementPresent("thankyou_date"); | |
131 | ||
132 | $this->type("note", "This is a test note."); | |
133 | $this->type("non_deductible_amount", "10.00"); | |
134 | $this->type("fee_amount", "0"); | |
135 | $this->type("net_amount", "0"); | |
136 | $this->type("invoice_id", time()); | |
137 | $this->webtestFillDate('thankyou_date'); | |
76e86fd8 | 138 | |
6a488035 TO |
139 | //Premium section |
140 | $this->click("Premium"); | |
141 | $this->waitForElementPresent("fulfilled_date"); | |
142 | $this->select("product_name[0]", "label=Coffee Mug ( MUG-101 )"); | |
143 | $this->select("product_name[1]", "label=Black"); | |
144 | $this->webtestFillDate('fulfilled_date'); | |
145 | ||
146 | // Clicking save. | |
147 | $this->click("_qf_Contribution_upload"); | |
6a488035 TO |
148 | |
149 | // Is status message correct? | |
5d48a234 | 150 | //$this->assertTrue($this->isTextPresent("The contribution record has been saved."), "Status message didn't show up after saving!"); |
76e86fd8 | 151 | |
5d48a234 | 152 | // verify if Contribution is created |
3bbf7318 | 153 | $this->waitForElementPresent("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[8]/span/a[text()='View']"); |
76e86fd8 | 154 | |
5d48a234 | 155 | //click through to the Contribution view screen |
3bbf7318 | 156 | $this->click("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[8]/span/a[text()='View']"); |
6a488035 | 157 | $this->waitForElementPresent("_qf_ContributionView_cancel-bottom"); |
76e86fd8 | 158 | |
06321b47 | 159 | $expected = array( |
160 | 'Financial Type' => 'Donation', | |
161 | 'Total Amount' => '100.00', | |
6a488035 | 162 | 'Contribution Status' => 'Completed', |
4db803dd | 163 | 'Payment Method' => 'Check', |
06321b47 | 164 | 'Check Number' => 'check #1041', |
6a488035 | 165 | 'Non-deductible Amount' => '10.00', |
06321b47 | 166 | 'Received Into' => $financialAccount, |
6a488035 | 167 | ); |
06321b47 | 168 | |
3bbf7318 | 169 | $this->waitForElementPresent("xpath=//*[@id='ContributionView']/div[2]"); |
06321b47 | 170 | foreach ($expected as $value) { |
e684c1ae | 171 | $this->assertElementContainsText("xpath=//*[@id='ContributionView']/div[2]", $value); |
6a488035 TO |
172 | } |
173 | ||
06321b47 | 174 | // verify if soft credit was created successfully |
175 | $expected = array( | |
176 | 'Soft Credit To 1' => "{$softCreditFname} {$softCreditLname}", | |
177 | 'Soft Credit To 2' => "{$softCreditSecondFname} {$softCreditSecondLname}", | |
51fa20cb | 178 | 'Amount (Soft Credit Type)' => '100.00 (In Honor of)', |
06321b47 | 179 | ); |
180 | ||
181 | foreach ($expected as $value) { | |
e684c1ae | 182 | $this->assertElementContainsText("css=table.crm-soft-credit-listing", $value); |
06321b47 | 183 | } |
184 | ||
185 | // go to first soft creditor contact view page | |
3bbf7318 | 186 | $this->clickLink("xpath=//*[@id='ContributionView']/div[2]/div[2]/div[2]/table/tbody/tr[1]/td[1]/a", "css=li#tab_contribute a"); |
6a488035 TO |
187 | |
188 | // go to contribution tab | |
6a488035 TO |
189 | $this->click("css=li#tab_contribute a"); |
190 | $this->waitForElementPresent("link=Record Contribution (Check, Cash, EFT ...)"); | |
191 | ||
192 | // verify soft credit details | |
06321b47 | 193 | $expected = array( |
51fa20cb | 194 | 3 => 'Solicited', |
195 | 4 => 'Donation', | |
06321b47 | 196 | 2 => '50.00', |
51fa20cb | 197 | 6 => 'Completed', |
21dfd5f5 | 198 | 1 => "{$firstName} {$lastName}", |
6a488035 | 199 | ); |
06321b47 | 200 | foreach ($expected as $value => $label) { |
e684c1ae | 201 | $this->assertElementContainsText("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[2]/td[$value]", $label); |
6a488035 TO |
202 | } |
203 | } | |
76e86fd8 | 204 | |
00be9182 | 205 | public function testDeductibleAmount() { |
6a488035 TO |
206 | $this->webtestLogin(); |
207 | ||
c432c016 | 208 | // disable verify ssl when using authorize .net |
209 | $this->openCiviPage("admin/setting/url", "reset=1"); | |
210 | $this->click("id=CIVICRM_QFID_0_verifySSL"); | |
211 | $this->click("id=_qf_Url_next-bottom"); | |
212 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
213 | ||
6a488035 TO |
214 | //add authorize .net payment processor |
215 | $processorName = 'Webtest AuthNet' . substr(sha1(rand()), 0, 7); | |
216 | $this->webtestAddPaymentProcessor($processorName, 'AuthNet'); | |
76e86fd8 | 217 | |
071a6d2e | 218 | $this->openCiviPage("admin/contribute/managePremiums", "action=add&reset=1"); |
6a488035 TO |
219 | $premiumName = 'test Premium' . substr(sha1(rand()), 0, 7); |
220 | $this->addPremium($premiumName, 'SKU', 3, 12, NULL, NULL); | |
76e86fd8 | 221 | |
06321b47 | 222 | $firstName = 'John' . substr(sha1(rand()), 0, 7); |
223 | $lastName = 'Dsouza' . substr(sha1(rand()), 0, 7); | |
6a488035 TO |
224 | $this->webtestAddContact($firstName, $lastName); |
225 | ||
226 | //scenario 1 : is_deductible = 0 and non deductible amount is entered | |
227 | $scenario1 = array( | |
228 | 'financial_type' => 'Campaign Contribution', | |
229 | 'total_amount' => 111, | |
646957a3 | 230 | 'non_deductible_amount' => 15, |
231 | 'sort_name' => "$lastName, $firstName", | |
6a488035 TO |
232 | ); |
233 | $this->_doOfflineContribution($scenario1, $firstName, $lastName, $processorName); | |
76e86fd8 | 234 | |
6a488035 TO |
235 | $checkScenario1 = array( |
236 | 'From' => "{$firstName} {$lastName}", | |
237 | 'Financial Type' => 'Campaign Contribution', | |
238 | 'Total Amount' => 111, | |
646957a3 | 239 | 'Non-deductible Amount' => 15, |
240 | 'sort_name' => "$lastName, $firstName", | |
6a488035 TO |
241 | ); |
242 | $this->_verifyAmounts($checkScenario1); | |
76e86fd8 | 243 | |
6a488035 TO |
244 | //scenario 2 : is_deductible = TRUE and premium is set and premium is greater than total amount |
245 | $scenario2 = array( | |
246 | 'financial_type' => 'Donation', | |
247 | 'total_amount' => 10, | |
646957a3 | 248 | 'premium' => "{$premiumName} ( SKU )", |
249 | 'sort_name' => "$lastName, $firstName", | |
6a488035 TO |
250 | ); |
251 | $this->_doOfflineContribution($scenario2, $firstName, $lastName, $processorName); | |
76e86fd8 | 252 | |
6a488035 TO |
253 | $checkScenario2 = array( |
254 | 'From' => "{$firstName} {$lastName}", | |
255 | 'Financial Type' => 'Donation', | |
256 | 'Total Amount' => 10, | |
646957a3 | 257 | 'Non-deductible Amount' => 10, |
258 | 'sort_name' => "$lastName, $firstName", | |
6a488035 TO |
259 | ); |
260 | $this->_verifyAmounts($checkScenario2); | |
76e86fd8 | 261 | |
6a488035 TO |
262 | //scenario 3 : is_deductible = TRUE and premium is set and premium is less than total amount |
263 | $scenario3 = array( | |
264 | 'financial_type' => 'Donation', | |
265 | 'total_amount' => 123, | |
646957a3 | 266 | 'premium' => "{$premiumName} ( SKU )", |
267 | 'sort_name' => "$lastName, $firstName", | |
6a488035 TO |
268 | ); |
269 | $this->_doOfflineContribution($scenario3, $firstName, $lastName, $processorName); | |
76e86fd8 | 270 | |
6a488035 TO |
271 | $checkScenario3 = array( |
272 | 'From' => "{$firstName} {$lastName}", | |
273 | 'Financial Type' => 'Donation', | |
274 | 'Total Amount' => 123, | |
646957a3 | 275 | 'Non-deductible Amount' => 12, |
276 | 'sort_name' => "$lastName, $firstName", | |
6a488035 TO |
277 | ); |
278 | $this->_verifyAmounts($checkScenario3); | |
76e86fd8 | 279 | |
6a488035 TO |
280 | //scenario 4 : is_deductible = TRUE and premium is not set |
281 | $scenario4 = array( | |
282 | 'financial_type' => 'Donation', | |
283 | 'total_amount' => 123, | |
646957a3 | 284 | 'sort_name' => "$lastName, $firstName", |
6a488035 TO |
285 | ); |
286 | $this->_doOfflineContribution($scenario4, $firstName, $lastName, $processorName); | |
76e86fd8 | 287 | |
6a488035 TO |
288 | $checkScenario4 = array( |
289 | 'From' => "{$firstName} {$lastName}", | |
290 | 'Financial Type' => 'Donation', | |
291 | 'Total Amount' => 123, | |
e42cfe9d | 292 | 'Non-deductible Amount' => '0.00', |
646957a3 | 293 | 'sort_name' => "$lastName, $firstName", |
6a488035 TO |
294 | ); |
295 | $this->_verifyAmounts($checkScenario4); | |
296 | ||
297 | //scenario 5 : is_deductible = FALSE, non_deductible_amount = the total amount | |
298 | $scenario5 = array( | |
299 | 'financial_type' => 'Campaign Contribution', | |
300 | 'total_amount' => 555, | |
646957a3 | 301 | 'sort_name' => "$lastName, $firstName", |
6a488035 TO |
302 | ); |
303 | $this->_doOfflineContribution($scenario5, $firstName, $lastName, $processorName); | |
76e86fd8 | 304 | |
6a488035 TO |
305 | $checkScenario5 = array( |
306 | 'From' => "{$firstName} {$lastName}", | |
307 | 'Financial Type' => 'Campaign Contribution', | |
308 | 'Total Amount' => 555, | |
646957a3 | 309 | 'Non-deductible Amount' => 555, |
310 | 'sort_name' => "$lastName, $firstName", | |
6a488035 TO |
311 | ); |
312 | $this->_verifyAmounts($checkScenario5); | |
313 | } | |
76e86fd8 | 314 | |
4cbe18b8 | 315 | /** |
eceb18cc | 316 | * common function for doing offline contribution. |
c490a46a | 317 | * @param array $params |
100fef9d CW |
318 | * @param string $firstName |
319 | * @param string $lastName | |
4cbe18b8 EM |
320 | * @param $processorName |
321 | */ | |
00be9182 | 322 | public function _doOfflineContribution($params, $firstName, $lastName, $processorName) { |
76e86fd8 | 323 | |
6a488035 TO |
324 | $this->waitForElementPresent("css=li#tab_contribute a"); |
325 | $this->click("css=li#tab_contribute a"); | |
7542b691 | 326 | $this->waitForElementPresent("link=Record Contribution (Check, Cash, EFT ...)"); |
6a488035 TO |
327 | |
328 | // since we don't have live credentials we will switch to test mode | |
7542b691 | 329 | $url = $this->getAttribute("xpath=//*[@id='Search']/div[2]/div[2]/a[1]@href"); |
2e21c7ba | 330 | $url .= '&mode=test'; |
6a488035 | 331 | $this->open($url); |
a471a3b6 | 332 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
6a488035 TO |
333 | |
334 | // start filling out contribution form | |
335 | $this->waitForElementPresent('payment_processor_id'); | |
336 | $this->select('payment_processor_id', "label={$processorName}"); | |
337 | ||
338 | // select financial type | |
339 | $this->select("financial_type_id", "label={$params['financial_type']}"); | |
340 | ||
341 | // total amount | |
342 | $this->type("total_amount", "{$params['total_amount']}"); | |
343 | ||
344 | // enter credit card info on form | |
345 | $this->webtestAddCreditCardDetails(); | |
346 | ||
347 | // billing address | |
348 | $this->webtestAddBillingDetails($firstName, NULL, $lastName); | |
76e86fd8 | 349 | |
6a488035 TO |
350 | if ($nonDeductibleAmt = CRM_Utils_Array::value('non_deductible_amount', $params)) { |
351 | $this->click("AdditionalDetail"); | |
352 | $this->waitForElementPresent("thankyou_date"); | |
353 | $this->type("note", "This is a test note."); | |
354 | $this->type("non_deductible_amount", "{$nonDeductibleAmt}"); | |
355 | } | |
356 | ||
a7488080 | 357 | if (!empty($params['premium'])) { |
6a488035 TO |
358 | //Premium section |
359 | $this->click("Premium"); | |
360 | $this->waitForElementPresent("fulfilled_date"); | |
361 | $this->select("product_name[0]", "label={$params['premium']}"); | |
362 | } | |
363 | // Clicking save. | |
7542b691 | 364 | $this->click("_qf_Contribution_upload-bottom"); |
6a488035 TO |
365 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
366 | ||
367 | // Is status message correct? | |
c432c016 | 368 | $this->assertTrue($this->isTextPresent("The contribution record has been saved."), "Status message didn't show up after saving!"); |
6a488035 | 369 | } |
76e86fd8 | 370 | |
4cbe18b8 | 371 | /** |
4f1f1f2a | 372 | * common function for verifing total_amount, and non_deductible_amount |
4cbe18b8 EM |
373 | * @param $verifyData |
374 | */ | |
00be9182 | 375 | public function _verifyAmounts($verifyData) { |
646957a3 | 376 | // since we are doing test contributions we need to search for test contribution and select first contribution |
377 | // record for the contact | |
378 | $this->openCiviPage("contribute/search", "reset=1", "contribution_date_low"); | |
379 | $this->type("sort_name", $verifyData['sort_name']); | |
380 | ||
381 | // select show test contributions | |
382 | $this->click("contribution_test", "value=1"); | |
deeea38d WA |
383 | $this->clickLink("_qf_Search_refresh", "xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[10]/span//a[text()='View']", FALSE); |
384 | $this->clickLink("xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[10]/span//a[text()='View']", "_qf_ContributionView_cancel-bottom", FALSE); | |
6a488035 TO |
385 | |
386 | foreach ($verifyData as $label => $value) { | |
481a74f4 | 387 | if ($label == 'sort_name') { |
646957a3 | 388 | continue; |
389 | } | |
6a488035 TO |
390 | $this->verifyText("xpath=//form[@id='ContributionView']//table/tbody/tr/td[text()='{$label}']/following-sibling::td", |
391 | preg_quote($value) | |
392 | ); | |
393 | } | |
394 | ||
646957a3 | 395 | // now find contact and go back to contact summary |
396 | $this->openCiviPage("contact/search", "reset=1", "sort_name"); | |
397 | $this->type("sort_name", $verifyData['sort_name']); | |
398 | $this->clickLink("_qf_Basic_refresh", | |
399 | "xpath=//form[@id='Basic']/div[3]/div[1]/div[2]/table/tbody/tr[1]/td[11]/span/a[text()='View']"); | |
400 | ||
401 | $this->clickLink("xpath=//form[@id='Basic']/div[3]/div[1]/div[2]/table/tbody/tr[1]/td[11]/span/a[text()='View']", | |
92915c55 | 402 | 'crm-contact-actions-link', FALSE); |
6a488035 | 403 | } |
3fb990f4 | 404 | |
00be9182 | 405 | public function testOnlineContributionWithZeroAmount() { |
3fb990f4 RN |
406 | $this->webtestLogin(); |
407 | ||
408 | // Create a contact to be used as soft creditor | |
06321b47 | 409 | $firstName = 'John' . substr(sha1(rand()), 0, 7); |
410 | $lastName = 'Peterson' . substr(sha1(rand()), 0, 7); | |
411 | $this->webtestAddContact($firstName, $lastName); | |
3fb990f4 RN |
412 | $this->waitForElementPresent("css=li#tab_contribute a"); |
413 | $this->click("css=li#tab_contribute a"); | |
414 | $this->waitForElementPresent("link=Record Contribution (Check, Cash, EFT ...)"); | |
3bbf7318 | 415 | $this->clickLink("link=Record Contribution (Check, Cash, EFT ...)", "_qf_Contribution_cancel-bottom", FALSE); |
3fb990f4 | 416 | |
06321b47 | 417 | // select financial type |
3fb990f4 RN |
418 | $this->select("financial_type_id", "value=1"); |
419 | ||
420 | // total amount | |
421 | $this->type("total_amount", "0.00"); | |
422 | ||
423 | // select payment instrument | |
424 | $this->select("payment_instrument_id", "value=1"); | |
425 | ||
426 | $this->type("trxn_id", "X20901X1" . rand(100, 10000)); | |
3bbf7318 | 427 | $this->click('_qf_Contribution_upload-bottom'); |
3fb990f4 RN |
428 | $this->waitForText("crm-notification-container", "The contribution record has been saved."); |
429 | ||
3bbf7318 | 430 | $this->waitForElementPresent("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[8]/span/a[text()='View']"); |
431 | $this->clickLink("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[8]/span/a[text()='View']", "_qf_ContributionView_cancel-bottom", FALSE); | |
3fb990f4 | 432 | $expected = array( |
06321b47 | 433 | 'Financial Type' => 'Donation', |
434 | 'Total Amount' => '0.00', | |
3fb990f4 | 435 | 'Contribution Status' => 'Completed', |
4db803dd | 436 | 'Payment Method' => 'Credit Card', |
3fb990f4 RN |
437 | ); |
438 | $this->webtestVerifyTabularData($expected); | |
439 | } | |
96025800 | 440 | |
b25b6f70 WA |
441 | public function testDefaultCurrancy() { |
442 | $this->webtestLogin(); | |
443 | $this->enableCurrency(array('GBP', 'EUR')); | |
444 | ||
445 | //Create a contact. | |
446 | $firstName = 'John' . substr(sha1(rand()), 0, 7); | |
447 | $lastName = 'Peterson' . substr(sha1(rand()), 0, 7); | |
448 | $this->webtestAddContact($firstName, $lastName); | |
449 | ||
450 | //Create contribution for contact | |
451 | $this->waitForElementPresent("css=li#tab_contribute a"); | |
452 | $this->click("css=li#tab_contribute a"); | |
453 | $this->waitForElementPresent("link=Record Contribution (Check, Cash, EFT ...)"); | |
454 | $this->click("link=Record Contribution (Check, Cash, EFT ...)"); | |
455 | $this->waitForElementPresent("financial_type_id"); | |
456 | $this->select("financial_type_id", "value=1"); | |
457 | $this->select("currency", "value=GBP"); | |
458 | $this->type("total_amount", "100"); | |
459 | $this->click("xpath=//div[@class='ui-dialog-buttonset']//button//span[text()='Save']"); | |
460 | $this->waitForAjaxContent(); | |
461 | $this->waitForElementPresent("xpath=//table[@class='selector row-highlight']"); | |
462 | $this->assertElementContainsText("xpath=//table[@class='selector row-highlight']/tbody/tr//td/a", "£ 100.00"); | |
463 | $this->click("xpath=//table[@class='selector row-highlight']/tbody/tr//td/a", "£ 100.00"); | |
464 | $this->waitForElementPresent("xpath=//table[@id='info']"); | |
465 | $this->assertElementContainsText("xpath=//table[@id='info']/tbody/tr[2]/td[1]", "£ 100.00"); | |
466 | } | |
467 | ||
42daf119 | 468 | } |