3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
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';
31 * Class WebTest_Contribute_UpdateContributionTest
33 class WebTest_Contribute_UpdateContributionTest
extends CiviSeleniumTestCase
{
35 protected function setUp() {
39 function testChangeContributionAmount() {
40 $this->webtestLogin();
41 $firstName = substr(sha1(rand()), 0, 7);
42 $lastName = 'Contributor';
43 $email = $firstName . "@example.com";
45 //Offline Pay Later Contribution
46 $this->_testOfflineContribution($firstName, $lastName, $email, $amount, "Pending");
48 $this->openCiviPage("contribute/search", "reset=1", "contribution_date_low");
50 $this->type("sort_name", "$lastName, $firstName");
51 $this->click("_qf_Search_refresh");
53 $this->waitForElementPresent("xpath=//*[@id='Search']//div[@id='contributionSearch']");
54 $contriIDOff = explode('&', $this->getAttribute("xpath=//div[@id='contributionSearch']//table[@class='selector row-highlight']/tbody/tr[1]/td[11]/span/a[1]@href"));
55 if (!empty($contriIDOff)) {
56 $contriIDOff = substr($contriIDOff[1], (strrpos($contriIDOff[1], '=') +
1));
59 $this->clickLink("xpath=//tr[@id='rowid{$contriIDOff}']/td[11]/span/a[2]", "total_amount", FALSE);
60 $this->type("total_amount", "90");
61 $this->clickLink('_qf_Contribution_upload','',FALSE);
63 // Is status message correct?
64 $this->waitForText('crm-notification-container', "The contribution record has been saved.");
67 $searchParams = array('id' => $contriIDOff);
68 $compareParams = array('total_amount' => '90.00');
70 $lineItemSearchParams = array('entity_id' => $contriIDOff);
71 $lineItemCompareParams = array('line_total' => '90.00');
73 $this->assertDBCompareValues('CRM_Contribute_DAO_Contribution', $searchParams, $compareParams);
74 $this->assertDBCompareValues('CRM_Price_DAO_LineItem', $lineItemSearchParams, $lineItemCompareParams);
76 $total = $this->_getTotalContributedAmount($contriIDOff);
77 $compare = array('total_amount' => $total);
78 $this->assertDBCompareValues('CRM_Contribute_DAO_Contribution', $searchParams, $compare);
80 $amount = $this->_getFinancialItemAmount($contriIDOff);
81 $compare = array('total_amount' => $amount);
82 $this->assertDBCompareValues('CRM_Contribute_DAO_Contribution', $searchParams, $compare);
84 $financialTrxnAmount = $this->_getFinancialTrxnAmount($contriIDOff);
85 $compare = array('total_amount' => $financialTrxnAmount);
86 $this->assertDBCompareValues('CRM_Contribute_DAO_Contribution', $searchParams, $compare);
89 function testPayLater() {
90 $this->webtestLogin();
91 $firstName = substr(sha1(rand()), 0, 7);
92 $lastName = 'Contributor';
93 $email = $firstName . "@example.com";
95 //Offline Pay Later Contribution
96 $this->_testOfflineContribution($firstName, $lastName, $email, $amount, "Pending");
97 $this->waitForElementPresent("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']");
98 $contId = explode('&id=', $this->getAttribute("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']@href"));
99 $contId = explode('&', $contId[1]);
100 $contId = $contId[0];
101 $this->clickLink("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']", '_qf_Contribution_cancel-bottom', FALSE);
102 $this->select("contribution_status_id", "label=Completed");
103 $this->clickLink("_qf_Contribution_upload", "xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']", FALSE);
104 $this->waitForText('crm-notification-container', "The contribution record has been saved.");
107 $search = array('id' => $contId);
108 $compare = array('contribution_status_id' => 1);
109 $this->assertDBCompareValues('CRM_Contribute_DAO_Contribution', $search, $compare);
111 $lineItem = key(CRM_Price_BAO_LineItem
::getLineItems($contId, 'contribution'));
112 $search = array( 'entity_id' => $lineItem );
113 $compare = array( 'status_id' => 1 );
114 $this->assertDBCompareValues("CRM_Financial_DAO_FinancialItem", $search, $compare);
116 $status = $this->_getPremiumActualCost($contId, 'Accounts Receivable', 'Payment Processor Account', NULL, "'civicrm_contribution'", "ft.status_id as status");
117 $this->assertEquals($status, '1', "Verify Completed Status");
120 function testChangePremium() {
121 $this->webtestLogin();
122 $firstName = substr(sha1(rand()), 0, 7);
123 $lastName = 'Contributor';
124 $email = $firstName . "@example.com";
126 $to = 'Premiums inventory';
127 $financialType = array(
128 'name' => 'Test Financial'.substr(sha1(rand()), 0, 7),
130 'is_deductible' => 1,
132 $this->addeditFinancialType($financialType);
133 $this->waitForElementPresent("xpath=//div[@id='ltype']/div/table/tbody//tr/td[text()='".$financialType['name']."']/../td[7]/span/a[text()='Accounts']");
134 $this->click("xpath=//div[@id='ltype']/div/table/tbody//tr/td[text()='".$financialType['name']."']/../td[7]/span/a[text()='Accounts']");
135 $this->waitForElementPresent("xpath=//a[@id='newfinancialTypeAccount']");
136 $this->clickLink("xpath=//a[@id='newfinancialTypeAccount']", "_qf_FinancialTypeAccount_cancel-botttom", FALSE);
137 $this->select("account_relationship", "label=Premiums Inventory Account is");
138 $this->waitForElementPresent("xpath=//select[@id='financial_account_id']/option[3][text()='Deposit Bank Account']");
139 $this->select("financial_account_id", "label=$to");
140 $this->clickLink("_qf_FinancialTypeAccount_next-botttom", "xpath=//a[@id='newfinancialTypeAccount']", FALSE);
142 $premiumName = 'Premium'.substr(sha1(rand()), 0, 7);
147 $this->openCiviPage("admin/contribute/managePremiums", "action=add&reset=1");
149 $this->addPremium($premiumName, $sku, $amount, $price, $cost, $financialType['name']);
152 $premiumName2 = 'Premium'.substr(sha1(rand()), 0, 7);
157 $this->openCiviPage("admin/contribute/managePremiums", "action=add&reset=1");
158 $this->addPremium($premiumName2, $sku2, $amount2, $price2, $cost2, $financialType['name']);
160 // add contribution with premium
161 $this->openCiviPage("contribute/add", "reset=1&action=add&context=standalone");
163 // create new contact using dialog
164 $this->webtestNewDialogContact($firstName, $lastName, $email);
165 // select financial type
166 $this->select( "financial_type_id", "value=1" );
168 $this->type("total_amount", "100");
169 // fill Premium information
170 $this->clickLink("xpath=//div[@id='Premium']", "product_name_0", FALSE);
171 $this->select('product_name_0', "label=$premiumName ( $sku )");
173 $this->clickLink("_qf_Contribution_upload");
174 // Is status message correct?
175 $this->waitForText('crm-notification-container', "The contribution record has been saved.");
176 // verify if Contribution is created
177 $this->waitForElementPresent("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[8]/span/a[text()='View']");
178 //click through to the Contribution edit screen
179 $contId = explode('&id=', $this->getAttribute("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']@href"));
180 $contId = explode('&', $contId[1]);
181 $contId = $contId[0];
182 $this->clickLink("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']", "_qf_Contribution_upload-bottom", FALSE);
183 $this->waitForElementPresent("product_name_0");
184 $this->select('product_name_0', "label=$premiumName2 ( $sku2 )");
186 $this->clickLink("_qf_Contribution_upload", "xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[7][text()='$premiumName2']", FALSE);
187 $this->assertSuccessMsg("The contribution record has been saved.");
190 $actualAmount = $this->_getPremiumActualCost($contId, $to, $from, $cost2, "'civicrm_contribution'");
191 $this->assertEquals($actualAmount, $cost2, "Verify actual cost for changed premium");
193 $deletedAmount = $this->_getPremiumActualCost($contId, $from, $to, $cost, "'civicrm_contribution'");
194 $this->assertEquals($deletedAmount, $cost, "Verify actual cost for deleted premium");
197 function testDeletePremium() {
198 $this->webtestLogin();
199 $firstName = substr(sha1(rand()), 0, 7);
200 $lastName = 'Contributor';
201 $email = $firstName . "@example.com";
203 $to = 'Premiums inventory';
204 $financialType = array(
205 'name' => 'Test Financial' . substr(sha1(rand()), 0, 7),
207 'is_deductible' => 1,
209 $this->addeditFinancialType($financialType);
210 $this->waitForElementPresent("xpath=//div[@id='ltype']/div/table/tbody//tr/td[text()='".$financialType['name']."']/../td[7]/span/a[text()='Accounts']");
211 $this->click("xpath=//div[@id='ltype']/div/table/tbody//tr/td[text()='".$financialType['name']."']/../td[7]/span/a[text()='Accounts']");
212 $this->waitForElementPresent("xpath=//a[@id='newfinancialTypeAccount']");
213 $this->clickLink("xpath=//a[@id='newfinancialTypeAccount']", "_qf_FinancialTypeAccount_cancel-botttom", FALSE);
215 $this->select("account_relationship", "label=Premiums Inventory Account is");
216 $this->waitForElementPresent("xpath=//select[@id='financial_account_id']/option[3][text()='Deposit Bank Account']");
217 $this->select("financial_account_id", "label=$to");
218 $this->clickLink("_qf_FinancialTypeAccount_next-botttom", "xpath=//a[@id='newfinancialTypeAccount']", FALSE);
219 $premiumName = 'Premium' . substr(sha1(rand()), 0, 7);
224 $this->openCiviPage("admin/contribute/managePremiums", "action=add&reset=1");
226 $this->addPremium($premiumName, $sku, $amount, $price, $cost, $financialType['name']);
228 // add contribution with premium
229 $this->openCiviPage("contribute/add", "reset=1&action=add&context=standalone");
231 // create new contact using dialog
232 $this->webtestNewDialogContact($firstName, $lastName, $email);
233 // select financial type
234 $this->select("financial_type_id", "value=1");
236 $this->type("total_amount", "100");
237 // fill Premium information
238 $this->click("xpath=//div[@id='Premium']");
239 $this->waitForElementPresent("product_name_0");
240 $this->select('product_name_0', "label=$premiumName ( $sku )");
242 $this->clickLink("_qf_Contribution_upload");
243 // Is status message correct?
244 $this->waitForText('crm-notification-container', "The contribution record has been saved.");
245 // verify if Contribution is created
246 $this->waitForElementPresent("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[8]/span/a[text()='View']");
247 //click through to the Contribution edit screen
248 $contId = explode('&id=', $this->getAttribute("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']@href"));
249 $contId = explode('&', $contId[1]);
250 $contId = $contId[0];
251 $this->clickLink("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']", "_qf_Contribution_upload-bottom", FALSE);
252 $this->waitForElementPresent("product_name_0");
253 $this->select('product_name_0', "value=0");
255 $this->clickLink("_qf_Contribution_upload", "xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[7][not(text())]", FALSE);
258 $actualAmount = $this->_getPremiumActualCost($contId, $from, $to, NULL, "'civicrm_contribution'");
259 $this->assertEquals($actualAmount, $cost, "Verify actual cost for deleted premium");
262 function testChangePaymentInstrument() {
263 $this->webtestLogin();
264 $firstName = substr(sha1(rand()), 0, 7);
265 $lastName = 'Contributor';
266 $email = $firstName . "@example.com";
267 $label = 'TEST'.substr(sha1(rand()), 0, 7);
269 $financialAccount = CRM_Contribute_PseudoConstant
::financialAccount();
270 $to = array_search('Accounts Receivable', $financialAccount);
271 $from = array_search('Deposit Bank Account', $financialAccount);
272 $this->addPaymentInstrument($label, $to);
273 $this->_testOfflineContribution($firstName, $lastName, $email, $amount);
274 $this->waitForElementPresent("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']");
275 $this->clickLink("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']", '_qf_Contribution_cancel-bottom', FALSE);
276 $contId = explode('&id=', $this->getAttribute("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']@href"));
277 $contId = explode('&', $contId[1]);
278 $contId = $contId[0];
279 //change payment processor to newly created value
280 $this->select("payment_instrument_id", "label=$label");
281 $this->clickLink("_qf_Contribution_upload", "xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']", FALSE);
283 $subtractedTotal = $this->_getPremiumActualCost($contId, NULL, 'Payment Processor Account');
284 $this->assertEquals($subtractedTotal, -$amount, "Verify amount deleted from old account");
285 $totalAmount = $this->_getPremiumActualCost($contId, NULL, 'Accounts Receivable');
286 $this->assertEquals($totalAmount, $amount, "Verify amount for newly inserted values");
289 function testRefundContribution() {
290 $this->webtestLogin();
291 $firstName = substr(sha1(rand()), 0, 7);
292 $lastName = 'Contributor';
293 $email = $firstName . "@example.com";
294 $label = 'TEST'.substr(sha1(rand()), 0, 7);
296 $this->_testOfflineContribution($firstName, $lastName, $email, $amount);
297 $this->waitForElementPresent("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']");
298 $this->clickLink("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']", '_qf_Contribution_cancel-bottom', FALSE);
299 //Contribution status
300 $this->select("contribution_status_id", "label=Refunded");
301 $contId = explode('&id=', $this->getAttribute("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']@href"));
302 $contId = explode('&', $contId[1]);
303 $contId = $contId[0];
304 $this->clickLink("_qf_Contribution_upload", "xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[6][text()='Refunded']", FALSE);
307 $lineItem = key(CRM_Price_BAO_LineItem
::getLineItems($contId, 'contribution'));
308 $search = array('entity_id' => $lineItem);
310 'amount' => '100.00',
313 $this->assertDBCompareValues("CRM_Financial_DAO_FinancialItem", $search, $compare);
314 $amount = $this->_getPremiumActualCost($contId, NULL, 'Payment Processor Account', -100.00, "'civicrm_contribution'");
315 $this->assertEquals($amount, '-100.00', 'Verify Financial Trxn Amount.');
318 function testCancelPayLater() {
319 $this->webtestLogin();
320 $firstName = substr(sha1(rand()), 0, 7);
321 $lastName = 'Contributor';
322 $email = $firstName . "@example.com";
323 $label = 'TEST'.substr(sha1(rand()), 0, 7);
325 $this->_testOfflineContribution($firstName, $lastName, $email, $amount, "Pending");
326 $this->waitForElementPresent("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']");
327 $this->clickLink("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']", '_qf_Contribution_cancel-bottom', FALSE);
328 //Contribution status
329 $this->select("contribution_status_id", "label=Cancelled");
330 $contId = explode('&id=', $this->getAttribute("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']@href"));
331 $contId = explode('&', $contId[1]);
332 $contId = $contId[0];
333 $this->clickLink("_qf_Contribution_upload", "xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']", FALSE);
334 $this->waitForText('crm-notification-container', "The contribution record has been saved.");
337 $search = array('id' => $contId);
338 $compare = array('contribution_status_id' => 3);
339 $this->assertDBCompareValues('CRM_Contribute_DAO_Contribution', $search, $compare);
340 $lineItem = key(CRM_Price_BAO_LineItem
::getLineItems($contId, 'contribution'));
342 'amount' => '-100.00',
343 'entity_id' => $lineItem,
346 $items = CRM_Financial_BAO_FinancialItem
::retrieve($itemParams, $defaults);
347 $this->assertEquals($items->amount
, $itemParams['amount'], 'Verify Amount for financial Item');
348 $totalAmount = $this->_getPremiumActualCost($items->id
, 'Accounts Receivable', NULL, "-100.00", "'civicrm_financial_item'");
349 $this->assertEquals($totalAmount, "-$amount", 'Verify Amount for Financial Trxn');
350 $totalAmount = $this->_getPremiumActualCost($contId, 'Accounts Receivable', NULL, "-100.00", "'civicrm_contribution'");
351 $this->assertEquals($totalAmount, "-$amount", 'Verify Amount for Financial Trxn');
354 function testChangeFinancialType() {
355 $this->webtestLogin();
356 $firstName = substr(sha1(rand()), 0, 7);
357 $lastName = 'Contributor';
358 $email = $firstName . "@example.com";
359 $label = 'TEST'.substr(sha1(rand()), 0, 7);
361 $this->_testOfflineContribution($firstName, $lastName, $email, $amount);
362 $this->waitForElementPresent("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']");
363 $this->clickLink("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']", '_qf_Contribution_cancel-bottom', FALSE);
364 //Contribution status
365 $this->select("financial_type_id", "value=3");
366 $contId = explode('&id=', $this->getAttribute("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']@href"));
367 $contId = explode('&', $contId[1]);
368 $contId = $contId[0];
369 $this->clickLink("_qf_Contribution_upload", "xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']", FALSE);
370 $this->waitForText('crm-notification-container', "The contribution record has been saved.");
373 $search = array( 'id' => $contId );
374 $compare = array( 'financial_type_id' => 3 );
375 $this->assertDBCompareValues('CRM_Contribute_DAO_Contribution', $search, $compare);
377 $lineItem = key(CRM_Price_BAO_LineItem
::getLineItems($contId, 'contribution'));
379 'amount' => '-100.00',
380 'entity_id' => $lineItem,
382 $item1 = $item2 = array();
383 CRM_Financial_BAO_FinancialItem
::retrieve($itemParams, $item1);
384 $this->assertEquals($item1['amount'], "-100.00", "Verify Amount for New Financial Item");
385 $itemParams['amount'] = '100.00';
386 CRM_Financial_BAO_FinancialItem
::retrieve($itemParams, $item2);
387 $this->assertEquals($item2['amount'], "100.00", "Verify Amount for New Financial Item");
389 $cValue1 = $this->_getPremiumActualCost($contId, NULL, NULL, "-100.00", "'civicrm_contribution'");
390 $fValue1 = $this->_getPremiumActualCost($item1['id'], NULL, NULL, "-100.00", "'civicrm_financial_item'");
391 $this->assertEquals($cValue1, "-100.00", "Verify Amount");
392 $this->assertEquals($fValue1, "-100.00", "Verify Amount");
393 $cValue2 = $this->_getPremiumActualCost($contId, NULL, NULL, "100.00", "'civicrm_contribution'");
394 $fValue2 = $this->_getPremiumActualCost($item2['id'], NULL, NULL, "100.00", "'civicrm_financial_item'");
395 $this->assertEquals($cValue2, "100.00", "Verify Amount");
396 $this->assertEquals($fValue2, "100.00", "Verify Amount");
404 * @param null $entityTable
405 * @param string $select
407 * @return null|string
408 */function _getPremiumActualCost($entityId, $from = NULL, $to = NULL, $cost = NULL, $entityTable = NULL, $select = "ft.total_amount AS amount") {
409 $financialAccount = CRM_Contribute_PseudoConstant
::financialAccount();
412 FROM civicrm_financial_trxn ft
413 INNER JOIN civicrm_entity_financial_trxn eft ON eft.financial_trxn_id = ft.id AND eft.entity_id = {$entityId}";
415 $query .= " AND eft.entity_table = {$entityTable}";
418 $to = array_search($to, $financialAccount);
419 $query .= " AND ft.to_financial_account_id = {$to}";
422 $from = array_search($from, $financialAccount);
423 $query .= " AND ft.from_financial_account_id = {$from}";
426 $query .= " AND eft.amount = {$cost}";
428 $query .= " ORDER BY ft.id DESC LIMIT 1";
429 $result = CRM_Core_DAO
::singleValueQuery($query);
436 * @return null|string
437 */function _getFinancialTrxnAmount($contId) {
439 SUM( ft.total_amount ) AS total
440 FROM civicrm_financial_trxn AS ft
441 LEFT JOIN civicrm_entity_financial_trxn AS ceft ON ft.id = ceft.financial_trxn_id
442 WHERE ceft.entity_table = 'civicrm_contribution'
443 AND ceft.entity_id = {$contId}";
444 $result = CRM_Core_DAO
::singleValueQuery($query);
451 * @return null|string
452 */function _getFinancialItemAmount($contId) {
453 $lineItem = key(CRM_Price_BAO_LineItem
::getLineItems($contId, 'contribution'));
456 FROM civicrm_financial_item
457 WHERE entity_table = 'civicrm_line_item'
458 AND entity_id = {$lineItem}";
459 $result = CRM_Core_DAO
::singleValueQuery($query);
466 * @return null|string
467 */function _getTotalContributedAmount($contId) {
470 FROM civicrm_entity_financial_trxn
471 WHERE entity_table = 'civicrm_contribution'
472 AND entity_id = {$contId}";
473 $result = CRM_Core_DAO
::singleValueQuery($query);
482 * @param string $status
484 function _testOfflineContribution($firstName, $lastName, $email, $amount, $status="Completed") {
486 $this->openCiviPage("contribute/add", "reset=1&context=standalone", "_qf_Contribution_upload");
488 // create new contact using dialog
489 $this->webtestNewDialogContact($firstName, $lastName, $email);
491 // select financial type
492 $this->select( "financial_type_id", "value=1" );
494 //Contribution status
495 $this->select("contribution_status_id", "label=$status");
498 $this->type("total_amount", $amount);
500 // select payment instrument type
501 $this->select("payment_instrument_id", "label=Credit Card");
504 $this->type("trxn_id", "P20901X1" . rand(100, 10000));
508 //$this->click('CIVICRM_QFID_3_6');
511 $this->clickLink("_qf_Contribution_upload");
513 // Is status message correct?
514 $this->waitForText('crm-notification-container', "The contribution record has been saved.");
516 $this->waitForElementPresent("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[8]/span/a[text()='View']");
517 // verify if Membership is created
519 //click through to the Membership view screen
520 $this->click("xpath=//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='View']");
523 'Financial Type' => 'Donation',
524 'Total Amount' => '100.00',
525 'Contribution Status' => $status,
527 $this->webtestVerifyTabularData($expected);
528 $this->click("_qf_ContributionView_cancel-bottom");