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 +--------------------------------------------------------------------+
28 require_once 'CiviTest/CiviSeleniumTestCase.php';
29 class WebTest_Contribute_UpdateContributionTest
extends CiviSeleniumTestCase
{
31 protected function setUp() {
35 function testChangeContributionAmount() {
36 // This is the path where our testing install resides.
37 // The rest of URL is defined in CiviSeleniumTestCase base class, in
39 $this->open($this->sboxPath
);
40 // Logging in. Remember to wait for page to load. In most cases,
41 // you can rely on 30000 as the value that allows your test to pass, however,
42 // sometimes your test might fail because of this. In such cases, it's better to pick one element
43 // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole
44 // page contents loaded and you can continue your test execution.
45 $this->webtestLogin();
46 $firstName = substr(sha1(rand()), 0, 7);
47 $lastName = 'Contributor';
48 $email = $firstName . "@example.com";
50 //Offline Pay Later Contribution
51 $this->_testOfflineContribution($firstName, $lastName, $email, $amount, "Pending");
53 $this->open($this->sboxPath
. "civicrm/contribute/search?reset=1");
55 $this->waitForElementPresent("contribution_date_low");
57 $this->type("sort_name", "$lastName, $firstName");
58 $this->click("_qf_Search_refresh");
60 $this->waitForPageToLoad($this->getTimeoutMsec());
61 $contriIDOff = explode('&', $this->getAttribute("xpath=//div[@id='contributionSearch']/table/tbody/tr[1]/td[11]/span/a@href"));
62 if (!empty($contriIDOff)) {
63 $contriIDOff = substr($contriIDOff[1], (strrpos($contriIDOff[1], '=') +
1));
66 $this->click("xpath=//tr[@id='rowid{$contriIDOff}']/td[11]/span/a[2]");
67 $this->waitForElementPresent("total_amount");
68 $this->type("total_amount", "90");
69 $this->click('_qf_Contribution_upload');
70 $this->waitForPageToLoad($this->getTimeoutMsec());
72 // Is status message correct?
73 $this->assertTrue($this->isTextPresent("The contribution record has been saved."), "Status message didn't show up after saving!");
75 $searchParams = array('id' => $contriIDOff);
76 $compareParams = array('total_amount' => '90.00');
78 $lineItemSearchParams = array('entity_id' => $contriIDOff);
79 $lineItemCompareParams = array('line_total' => '90.00');
81 $this->assertDBCompareValues('CRM_Contribute_DAO_Contribution', $searchParams, $compareParams);
82 $this->assertDBCompareValues('CRM_Price_DAO_LineItem', $lineItemSearchParams, $lineItemCompareParams);
84 $total = $this->_getTotalContributedAmount($contriIDOff);
85 $compare = array('total_amount' => $total);
86 $this->assertDBCompareValues('CRM_Contribute_DAO_Contribution', $searchParams, $compare);
89 $amount = $this->_getFinancialItemAmount($contriIDOff);
90 $compare = array('total_amount' => $amount);
91 $this->assertDBCompareValues('CRM_Contribute_DAO_Contribution', $searchParams, $compare);
93 $financialTrxnAmount = $this->_getFinancialTrxnAmount($contriIDOff);
94 $compare = array('total_amount' => $financialTrxnAmount);
95 $this->assertDBCompareValues('CRM_Contribute_DAO_Contribution', $searchParams, $compare);
98 function testPayLater() {
99 // This is the path where our testing install resides.
100 // The rest of URL is defined in CiviSeleniumTestCase base class, in
102 $this->open($this->sboxPath
);
103 // Logging in. Remember to wait for page to load. In most cases,
104 // you can rely on 30000 as the value that allows your test to pass, however,
105 // sometimes your test might fail because of this. In such cases, it's better to pick one element
106 // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole
107 // page contents loaded and you can continue your test execution.
108 $this->webtestLogin();
109 $firstName = substr(sha1(rand()), 0, 7);
110 $lastName = 'Contributor';
111 $email = $firstName . "@example.com";
113 //Offline Pay Later Contribution
114 $this->_testOfflineContribution($firstName, $lastName, $email, $amount, "Pending");
115 $this->click("xpath=//div[@id='Contributions']//table/tbody/tr[1]/td[8]/span/a[text()='Edit']");
116 $this->waitForPageToLoad($this->getTimeoutMsec());
117 $elements = $this->parseURL();
118 $contId = $elements['queryString']['id'];
119 $this->select("contribution_status_id", "label=Completed");
120 $this->click("_qf_Contribution_upload");
121 $this->waitForPageToLoad($this->getTimeoutMsec());
123 $search = array('id' => $contId);
124 $compare = array('contribution_status_id' => 1);
125 $this->assertDBCompareValues('CRM_Contribute_DAO_Contribution', $search, $compare);
127 $lineItem = key(CRM_Price_BAO_LineItem
::getLineItems($contId, 'contribution'));
128 $search = array( 'entity_id' => $lineItem );
129 $compare = array( 'status_id' => 1 );
130 $this->assertDBCompareValues("CRM_Financial_DAO_FinancialItem", $search, $compare);
132 $status = $this->_getPremiumActualCost($contId, 'Accounts Receivable', 'Payment Processor Account', NULL, "'civicrm_contribution'", "ft.status_id as status");
133 $this->assertEquals($status, '1', "Verify Completed Status");
136 function testChangePremium() {
137 // This is the path where our testing install resides.
138 // The rest of URL is defined in CiviSeleniumTestCase base class, in
140 $this->open($this->sboxPath
);
141 // Logging in. Remember to wait for page to load. In most cases,
142 // you can rely on 30000 as the value that allows your test to pass, however,
143 // sometimes your test might fail because of this. In such cases, it's better to pick one element
144 // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole
145 // page contents loaded and you can continue your test execution.
146 $this->webtestLogin();
147 $firstName = substr(sha1(rand()), 0, 7);
148 $lastName = 'Contributor';
149 $email = $firstName . "@example.com";
151 $to = 'Premiums inventory';
152 $financialType = array(
153 'name' => 'Test Financial'.substr(sha1(rand()), 0, 7),
155 'is_deductible' => 1,
157 $this->addeditFinancialType($financialType);
158 $this->select("account_relationship", "label=Cost of Sales Account is");
159 $this->select("financial_account_id", "label=$from");
160 $this->click("_qf_FinancialTypeAccount_next_new-botttom");
161 $this->waitForPageToLoad($this->getTimeoutMsec());
162 $this->select("account_relationship", "label=Premiums Inventory Account is");
163 $this->select("financial_account_id", "label=$to");
164 $this->click("_qf_FinancialTypeAccount_next-botttom");
165 $premiumName = 'Premium'.substr(sha1(rand()), 0, 7);
170 $this->open($this->sboxPath
. "civicrm/admin/contribute/managePremiums?action=add&reset=1");
172 $this->addPremium($premiumName, $sku, $amount, $price, $cost, $financialType['name']);
175 $premiumName2 = 'Premium'.substr(sha1(rand()), 0, 7);
180 $this->open($this->sboxPath
. "civicrm/admin/contribute/managePremiums?action=add&reset=1");
181 $this->addPremium($premiumName2, $sku2, $amount2, $price2, $cost2, $financialType['name']);
183 // add contribution with premium
184 $this->open($this->sboxPath
. "civicrm/contribute/add?reset=1&action=add&context=standalone");
185 $this->waitForPageToLoad($this->getTimeoutMsec());
187 // create new contact using dialog
188 $this->webtestNewDialogContact($firstName, $lastName, $email);
189 // select financial type
190 $this->select( "financial_type_id", "value=1" );
192 $this->type("total_amount", "100");
193 // fill Premium information
194 $this->click("xpath=//div[@id='Premium']");
195 $this->waitForElementPresent("product_name_0");
196 $this->select('product_name_0', "label=$premiumName ( $sku )");
198 $this->click("_qf_Contribution_upload");
199 $this->waitForPageToLoad($this->getTimeoutMsec());
200 // Is status message correct?
201 $this->assertTrue($this->isTextPresent("The contribution record has been saved."), "Status message didn't show up after saving!");
202 // verify if Membership is created
203 $this->waitForElementPresent("xpath=//div[@id='Contributions']//table//tbody/tr[1]/td[8]/span/a[text()='View']");
204 //click through to the Contribution edit screen
205 $this->click("xpath=//div[@id='Contributions']//table/tbody/tr[1]/td[8]/span/a[text()='Edit']");
206 $this->waitForElementPresent("_qf_Contribution_upload-bottom");
207 $elements = $this->parseURL();
208 $contId = $elements['queryString']['id'];
209 $this->waitForElementPresent("product_name_0");
210 $this->select('product_name_0', "label=$premiumName2 ( $sku2 )");
212 $this->click("_qf_Contribution_upload");
213 $this->waitForPageToLoad($this->getTimeoutMsec());
216 $actualAmount = $this->_getPremiumActualCost($contId, $to, $from, $cost2, "'civicrm_contribution'");
217 $this->assertEquals($actualAmount, $cost2, "Verify actual cost for changed premium");
219 $deletedAmount = $this->_getPremiumActualCost($contId, $from, $to, $cost, "'civicrm_contribution'");
220 $this->assertEquals($deletedAmount, $cost, "Verify actual cost for deleted premium");
223 function testDeletePremium() {
224 // This is the path where our testing install resides.
225 // The rest of URL is defined in CiviSeleniumTestCase base class, in
227 $this->open($this->sboxPath
);
228 // Logging in. Remember to wait for page to load. In most cases,
229 // you can rely on 30000 as the value that allows your test to pass, however,
230 // sometimes your test might fail because of this. In such cases, it's better to pick one element
231 // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole
232 // page contents loaded and you can continue your test execution.
233 $this->webtestLogin();
234 $firstName = substr(sha1(rand()), 0, 7);
235 $lastName = 'Contributor';
236 $email = $firstName . "@example.com";
238 $to = 'Premiums inventory';
239 $financialType = array(
240 'name' => 'Test Financial'.substr(sha1(rand()), 0, 7),
242 'is_deductible' => 1,
244 $this->addeditFinancialType($financialType);
245 $this->select("account_relationship", "label=Cost of Sales Account is");
246 $this->select("financial_account_id", "label=$from");
247 $this->click("_qf_FinancialTypeAccount_next_new-botttom");
248 $this->waitForPageToLoad($this->getTimeoutMsec());
249 $this->select("account_relationship", "label=Premiums Inventory Account is");
250 $this->select("financial_account_id", "label=$to");
251 $this->click("_qf_FinancialTypeAccount_next-botttom");
252 $premiumName = 'Premium'.substr(sha1(rand()), 0, 7);
257 $this->open($this->sboxPath
. "civicrm/admin/contribute/managePremiums?action=add&reset=1");
259 $this->addPremium($premiumName, $sku, $amount, $price, $cost, $financialType['name']);
261 // add contribution with premium
262 $this->open($this->sboxPath
. "civicrm/contribute/add?reset=1&action=add&context=standalone");
263 $this->waitForPageToLoad($this->getTimeoutMsec());
265 // create new contact using dialog
266 $this->webtestNewDialogContact($firstName, $lastName, $email);
267 // select financial type
268 $this->select( "financial_type_id", "value=1" );
270 $this->type("total_amount", "100");
271 // fill Premium information
272 $this->click("xpath=//div[@id='Premium']");
273 $this->waitForElementPresent("product_name_0");
274 $this->select('product_name_0', "label=$premiumName ( $sku )");
276 $this->click("_qf_Contribution_upload");
277 $this->waitForPageToLoad($this->getTimeoutMsec());
278 // Is status message correct?
279 $this->assertTrue($this->isTextPresent("The contribution record has been saved."), "Status message didn't show up after saving!");
280 // verify if Membership is created
281 $this->waitForElementPresent("xpath=//div[@id='Contributions']//table//tbody/tr[1]/td[8]/span/a[text()='View']");
282 //click through to the Contribution edit screen
283 $this->click("xpath=//div[@id='Contributions']//table/tbody/tr[1]/td[8]/span/a[text()='Edit']");
284 $this->waitForElementPresent("_qf_Contribution_upload-bottom");
285 $elements = $this->parseURL();
286 $contId = $elements['queryString']['id'];
287 $this->waitForElementPresent("product_name_0");
288 $this->select('product_name_0', "value=0");
290 $this->click("_qf_Contribution_upload");
291 $this->waitForPageToLoad($this->getTimeoutMsec());
294 $actualAmount = $this->_getPremiumActualCost($contId, $from, $to, NULL, "'civicrm_contribution'");
295 $this->assertEquals($actualAmount, $cost, "Verify actual cost for deleted premium");
298 function testChangePaymentInstrument() {
299 // This is the path where our testing install resides.
300 // The rest of URL is defined in CiviSeleniumTestCase base class, in
302 $this->open($this->sboxPath
);
303 // Logging in. Remember to wait for page to load. In most cases,
304 // you can rely on 30000 as the value that allows your test to pass, however,
305 // sometimes your test might fail because of this. In such cases, it's better to pick one element
306 // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole
307 // page contents loaded and you can continue your test execution.
308 $this->webtestLogin();
309 $firstName = substr(sha1(rand()), 0, 7);
310 $lastName = 'Contributor';
311 $email = $firstName . "@example.com";
312 $label = 'TEST'.substr(sha1(rand()), 0, 7);
314 $financialAccount = CRM_Contribute_PseudoConstant
::financialAccount();
315 $to = array_search('Accounts Receivable', $financialAccount);
316 $from = array_search('Deposit Bank Account', $financialAccount);
317 $this->addPaymentInstrument($label, $to);
318 $this->_testOfflineContribution($firstName, $lastName, $email, $amount);
319 $this->click("xpath=//div[@id='Contributions']//table/tbody/tr[1]/td[8]/span/a[text()='Edit']");
320 $this->waitForPageToLoad($this->getTimeoutMsec());
321 $elements = $this->parseURL();
322 $contId = $elements['queryString']['id'];
323 //change payment processor to newly created value
324 $this->select("payment_instrument_id", "label=$label");
325 $this->click("_qf_Contribution_upload");
326 $this->waitForPageToLoad($this->getTimeoutMsec());
328 $totalAmount = $this->_getPremiumActualCost($contId, 'Payment Processor Account', 'Accounts Receivable');
329 $this->assertEquals($totalAmount, $amount, "Verify amount for newly inserted values");
332 function testRefundContribution() {
333 // This is the path where our testing install resides.
334 // The rest of URL is defined in CiviSeleniumTestCase base class, in
336 $this->open($this->sboxPath
);
337 // Logging in. Remember to wait for page to load. In most cases,
338 // you can rely on 30000 as the value that allows your test to pass, however,
339 // sometimes your test might fail because of this. In such cases, it's better to pick one element
340 // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole
341 // page contents loaded and you can continue your test execution.
342 $this->webtestLogin();
343 $firstName = substr(sha1(rand()), 0, 7);
344 $lastName = 'Contributor';
345 $email = $firstName . "@example.com";
346 $label = 'TEST'.substr(sha1(rand()), 0, 7);
348 $this->_testOfflineContribution($firstName, $lastName, $email, $amount);
349 $this->click("xpath=//div[@id='Contributions']//table/tbody/tr[1]/td[8]/span/a[text()='Edit']");
350 $this->waitForPageToLoad($this->getTimeoutMsec());
351 //Contribution status
352 $this->select("contribution_status_id", "label=Refunded");
353 $elements = $this->parseURL();
354 $contId = $elements['queryString']['id'];
355 $this->click("_qf_Contribution_upload");
356 $this->waitForPageToLoad($this->getTimeoutMsec());
359 $lineItem = key(CRM_Price_BAO_LineItem
::getLineItems($contId, 'contribution'));
360 $search = array('entity_id' => $lineItem);
362 'amount' => '100.00',
365 $this->assertDBCompareValues("CRM_Financial_DAO_FinancialItem", $search, $compare);
366 $amount = $this->_getPremiumActualCost($contId, NULL, 'Payment Processor Account', -100.00, "'civicrm_contribution'");
367 $this->assertEquals($amount, '-100.00', 'Verify Financial Trxn Amount.');
370 function testCancelPayLater() {
371 // This is the path where our testing install resides.
372 // The rest of URL is defined in CiviSeleniumTestCase base class, in
374 $this->open($this->sboxPath
);
375 // Logging in. Remember to wait for page to load. In most cases,
376 // you can rely on 30000 as the value that allows your test to pass, however,
377 // sometimes your test might fail because of this. In such cases, it's better to pick one element
378 // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole
379 // page contents loaded and you can continue your test execution.
380 $this->webtestLogin();
381 $firstName = substr(sha1(rand()), 0, 7);
382 $lastName = 'Contributor';
383 $email = $firstName . "@example.com";
384 $label = 'TEST'.substr(sha1(rand()), 0, 7);
386 $this->_testOfflineContribution($firstName, $lastName, $email, $amount, "Pending");
387 $this->click("xpath=//div[@id='Contributions']//table/tbody/tr[1]/td[8]/span/a[text()='Edit']");
388 $this->waitForPageToLoad($this->getTimeoutMsec());
389 //Contribution status
390 $this->select("contribution_status_id", "label=Cancelled");
391 $elements = $this->parseURL();
392 $contId = $elements['queryString']['id'];
393 $this->click("_qf_Contribution_upload");
394 $this->waitForPageToLoad($this->getTimeoutMsec());
397 $search = array('id' => $contId);
398 $compare = array('contribution_status_id' => 3);
399 $this->assertDBCompareValues('CRM_Contribute_DAO_Contribution', $search, $compare);
400 $lineItem = key(CRM_Price_BAO_LineItem
::getLineItems($contId, 'contribution'));
402 'amount' => '-100.00',
403 'entity_id' => $lineItem,
406 $items = CRM_Financial_BAO_FinancialItem
::retrieve($itemParams, $defaults);
407 $this->assertEquals($items->amount
, $itemParams['amount'], 'Verify Amount for financial Item');
408 $totalAmount = $this->_getPremiumActualCost($items->id
, 'Accounts Receivable', NULL, "-100.00", "'civicrm_financial_item'");
409 $this->assertEquals($totalAmount, "-$amount", 'Verify Amount for Financial Trxn');
410 $totalAmount = $this->_getPremiumActualCost($contId, 'Accounts Receivable', NULL, "-100.00", "'civicrm_contribution'");
411 $this->assertEquals($totalAmount, "-$amount", 'Verify Amount for Financial Trxn');
414 function testChangeFinancialType() {
415 // This is the path where our testing install resides.
416 // The rest of URL is defined in CiviSeleniumTestCase base class, in
418 $this->open($this->sboxPath
);
419 // Logging in. Remember to wait for page to load. In most cases,
420 // you can rely on 30000 as the value that allows your test to pass, however,
421 // sometimes your test might fail because of this. In such cases, it's better to pick one element
422 // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole
423 // page contents loaded and you can continue your test execution.
424 $this->webtestLogin();
425 $firstName = substr(sha1(rand()), 0, 7);
426 $lastName = 'Contributor';
427 $email = $firstName . "@example.com";
428 $label = 'TEST'.substr(sha1(rand()), 0, 7);
430 $this->_testOfflineContribution($firstName, $lastName, $email, $amount);
431 $this->click("xpath=//div[@id='Contributions']//table/tbody/tr[1]/td[8]/span/a[text()='Edit']");
432 $this->waitForPageToLoad($this->getTimeoutMsec());
433 //Contribution status
434 $this->select("financial_type_id", "value=3");
435 $elements = $this->parseURL();
436 $contId = $elements['queryString']['id'];
437 $this->click("_qf_Contribution_upload");
438 $this->waitForPageToLoad($this->getTimeoutMsec());
441 $search = array( 'id' => $contId );
442 $compare = array( 'financial_type_id' => 3 );
443 $this->assertDBCompareValues('CRM_Contribute_DAO_Contribution', $search, $compare);
445 $lineItem = key(CRM_Price_BAO_LineItem
::getLineItems($contId, 'contribution'));
447 'amount' => '-100.00',
448 'entity_id' => $lineItem,
450 $item1 = $item2 = array();
451 CRM_Financial_BAO_FinancialItem
::retrieve($itemParams, $item1);
452 $this->assertEquals($item1['amount'], "-100.00", "Verify Amount for New Financial Item");
453 $itemParams['amount'] = '100.00';
454 CRM_Financial_BAO_FinancialItem
::retrieve($itemParams, $item2);
455 $this->assertEquals($item2['amount'], "100.00", "Verify Amount for New Financial Item");
457 $cValue1 = $this->_getPremiumActualCost($contId, NULL, NULL, "-100.00", "'civicrm_contribution'");
458 $fValue1 = $this->_getPremiumActualCost($item1['id'], NULL, NULL, "-100.00", "'civicrm_financial_item'");
459 $this->assertEquals($cValue1, "-100.00", "Verify Amount");
460 $this->assertEquals($fValue1, "-100.00", "Verify Amount");
461 $cValue2 = $this->_getPremiumActualCost($contId, NULL, NULL, "100.00", "'civicrm_contribution'");
462 $fValue2 = $this->_getPremiumActualCost($item2['id'], NULL, NULL, "100.00", "'civicrm_financial_item'");
463 $this->assertEquals($cValue2, "100.00", "Verify Amount");
464 $this->assertEquals($fValue2, "100.00", "Verify Amount");
467 function _getPremiumActualCost($entityId, $from = NULL, $to = NULL, $cost = NULL, $entityTable = NULL, $select = "ft.total_amount AS amount") {
468 $financialAccount = CRM_Contribute_PseudoConstant
::financialAccount();
471 FROM civicrm_financial_trxn ft
472 INNER JOIN civicrm_entity_financial_trxn eft ON eft.financial_trxn_id = ft.id AND eft.entity_id = {$entityId}";
474 $query .= " AND eft.entity_table = {$entityTable}";
477 $to = array_search($to, $financialAccount);
478 $query .= " AND ft.to_financial_account_id = {$to}";
481 $from = array_search($from, $financialAccount);
482 $query .= " AND ft.from_financial_account_id = {$from}";
485 $query .= " AND eft.amount = {$cost}";
487 $result = CRM_Core_DAO
::singleValueQuery($query);
491 function _getFinancialTrxnAmount($contId) {
493 SUM( ft.total_amount ) AS total
494 FROM civicrm_financial_trxn AS ft
495 LEFT JOIN civicrm_entity_financial_trxn AS ceft ON ft.id = ceft.financial_trxn_id
496 WHERE ceft.entity_table = 'civicrm_contribution'
497 AND ceft.entity_id = {$contId}";
498 $result = CRM_Core_DAO
::singleValueQuery($query);
502 function _getFinancialItemAmount($contId) {
503 $lineItem = key(CRM_Price_BAO_LineItem
::getLineItems($contId, 'contribution'));
506 FROM civicrm_financial_item
507 WHERE entity_table = 'civicrm_line_item'
508 AND entity_id = {$lineItem}";
509 $result = CRM_Core_DAO
::singleValueQuery($query);
513 function _getTotalContributedAmount($contId) {
516 FROM civicrm_entity_financial_trxn
517 WHERE entity_table = 'civicrm_contribution'
518 AND entity_id = {$contId}";
519 $result = CRM_Core_DAO
::singleValueQuery($query);
523 function _testOfflineContribution($firstName, $lastName, $email, $amount, $status="Completed") {
524 // Go directly to the URL of the screen that you will be testing (New Contribution-standalone).
525 $this->open($this->sboxPath
. "civicrm/contribute/add?reset=1&context=standalone");
527 // As mentioned before, waitForPageToLoad is not always reliable. Below, we're waiting for the submit
528 // button at the end of this page to show up, to make sure it's fully loaded.
529 $this->waitForElementPresent("_qf_Contribution_upload");
531 // Let's start filling the form with values.
533 // create new contact using dialog
534 $this->webtestNewDialogContact($firstName, $lastName, $email);
536 // select financial type
537 $this->select( "financial_type_id", "value=1" );
539 //Contribution status
540 $this->select("contribution_status_id", "label=$status");
543 $this->type("total_amount", $amount);
545 // select payment instrument type
546 $this->select("payment_instrument_id", "label=Credit Card");
548 $this->type("trxn_id", "P20901X1" . rand(100, 10000));
551 //$this->click('CIVICRM_QFID_3_6');
554 $this->click("_qf_Contribution_upload");
555 $this->waitForPageToLoad($this->getTimeoutMsec());
557 // Is status message correct?
558 $this->assertTrue($this->isTextPresent("The contribution record has been saved."), "Status message didn't show up after saving!");
560 // verify if Membership is created
561 $this->waitForElementPresent("xpath=//div[@id='Contributions']//table//tbody/tr[1]/td[8]/span/a[text()='View']");
563 //click through to the Membership view screen
564 $this->click("xpath=//div[@id='Contributions']//table/tbody/tr[1]/td[8]/span/a[text()='View']");
565 $this->waitForElementPresent("_qf_ContributionView_cancel-bottom");
568 'Financial Type' => 'Donation',
569 'Total Amount' => '100.00',
570 'Contribution Status' => $status,
572 foreach ($expected as $label => $value) {
573 $this->verifyText("xpath=id('ContributionView')/div[2]/table[1]/tbody//tr/td[1][text()='$label']/../td[2]", preg_quote($value));
575 $this->click("_qf_ContributionView_cancel-top");
576 $this->waitForPageToLoad($this->getTimeoutMsec());