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';
29 class WebTest_Financial_FinancialBatchExport
extends CiviSeleniumTestCase
{
31 protected function setUp() {
35 function testAddFinancialBatch() {
36 // Log in using webtestLogin() method
37 $this->webtestLogin('admin');
38 $this->openCiviPage("financial/batch", "reset=1&action=add", '_qf_FinancialBatch_next-botttom');
39 $setTitle = 'Batch ' . substr(sha1(rand()), 0, 7) . date('Y-m-d');
40 $setDescription = 'Test Batch Creation';
41 $setPaymentInstrument = 'Credit Card';
42 $numberOfTrxn = '10'; // can be 10, 25, 50, 100
44 $exportFormat = 'CSV';
45 $batchId = $this->_testAddBatch(
48 $setPaymentInstrument,
52 $this->_testAssignBatch($numberOfTrxn);
53 $this->_testExportBatch($setTitle, $batchId, $exportFormat);
56 function _testAddBatch($setTitle, $setDescription, $setPaymentInstrument, $numberOfTrxn, $totalAmt) {
57 // Enter Optional Constraints
58 $this->type('title', $setTitle);
59 $this->type('description', $setDescription);
60 if ($setPaymentInstrument == 'Credit Card') {
61 $this->select("payment_instrument_id", "value=1");
63 elseif ($setPaymentInstrument == 'Debit Card') {
64 $this->select("payment_instrument_id", "value=2");
66 elseif ($setPaymentInstrument == 'Cash') {
67 $this->select("payment_instrument_id", "value=3");
69 elseif ($setPaymentInstrument == 'Check') {
70 $this->select("payment_instrument_id", "value=4");
72 elseif ($setPaymentInstrument == 'EFT') {
73 $this->select("payment_instrument_id", "value=5");
75 $this->type('item_count', $numberOfTrxn);
76 $this->type('total', $totalAmt);
78 $this->click('_qf_FinancialBatch_next-botttom');
79 $this->waitForPageToLoad($this->getTimeoutMsec());
81 // parse URL to grab the batch ID
82 $batchId = $this->urlArg('bid');
86 function _testAssignBatch($numberOfTrxn) {
87 $this->select( "xpath=//div[@id='crm-transaction-selector-assign_length']/label/select[@name='crm-transaction-selector-assign_length']", "value=$numberOfTrxn" );
88 // Because it tends to cause problems, all uses of sleep() must be justified in comments
89 // Sleep should never be used for wait for anything to load from the server
90 // Justification for this instance: FIXME
92 $this->click('toggleSelect');
93 $this->select('trans_assign', 'value=Assign');
95 $this->waitForPageToLoad($this->getTimeoutMsec());
98 function _testExportBatch($setTitle, $batchId, $exportFormat) {
99 $this->openCiviPage("financial/batch", "reset=1&action=export&id=$batchId");
100 if ($exportFormat == 'CSV') {
101 $this->click("xpath=//form[@id='FinancialBatch']/div[2]/table[@class='form-layout']/tbody/tr/td/input[2]");
102 $this->click('_qf_FinancialBatch_next-botttom');
103 $this->waitForPageToLoad($this->getTimeoutMsec());
106 $this->click("xpath=//form[@id='FinancialBatch']/div[2]/table[@class='form-layout']/tbody/tr/td/input[1]");
107 $this->click('_qf_FinancialBatch_next-botttom');
108 $this->waitForPageToLoad($this->getTimeoutMsec());
110 $this->openCiviPage("dashboard", "reset=1");
111 $this->waitForPageToLoad($this->getTimeoutMsec());
113 $this->clickLink("xpath=//div[@id='recently-viewed']/ul/li[1]/a", "_qf_Activity_cancel-bottom");
114 $this->webtestVerifyTabularData(
116 'Current Attachment(s)' => 'Financial_Transactions_'