3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2018 |
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_Financial_FinancialBatchExport
33 class WebTest_Financial_FinancialBatchExport
extends CiviSeleniumTestCase
{
35 protected function setUp() {
39 public function testAddFinancialBatch() {
40 // Log in using webtestLogin() method
41 $this->webtestLogin('admin');
42 $this->openCiviPage("financial/batch", "reset=1&action=add", '_qf_FinancialBatch_next-botttom');
43 $setTitle = 'Batch ' . substr(sha1(rand()), 0, 7) . date('Y-m-d');
44 $setDescription = 'Test Batch Creation';
45 $setPaymentInstrument = 'Credit Card';
46 $numberOfTrxn = '10'; // can be 10, 25, 50, 100
48 $exportFormat = 'CSV';
49 $batchId = $this->_testAddBatch(
52 $setPaymentInstrument,
56 $this->_testAssignBatch($numberOfTrxn);
57 $this->_testExportBatch($setTitle, $batchId, $exportFormat);
62 * @param $setDescription
63 * @param $setPaymentInstrument
64 * @param $numberOfTrxn
69 public function _testAddBatch($setTitle, $setDescription, $setPaymentInstrument, $numberOfTrxn, $totalAmt) {
70 // Enter Optional Constraints
71 $this->type('title', $setTitle);
72 $this->type('description', $setDescription);
73 if ($setPaymentInstrument == 'Credit Card') {
74 $this->select("payment_instrument_id", "value=1");
76 elseif ($setPaymentInstrument == 'Debit Card') {
77 $this->select("payment_instrument_id", "value=2");
79 elseif ($setPaymentInstrument == 'Cash') {
80 $this->select("payment_instrument_id", "value=3");
82 elseif ($setPaymentInstrument == 'Check') {
83 $this->select("payment_instrument_id", "value=4");
85 elseif ($setPaymentInstrument == 'EFT') {
86 $this->select("payment_instrument_id", "value=5");
88 $this->type('item_count', $numberOfTrxn);
89 $this->type('total', $totalAmt);
91 $this->click('_qf_FinancialBatch_next-botttom');
92 $this->waitForPageToLoad($this->getTimeoutMsec());
94 // parse URL to grab the batch ID
95 $batchId = $this->urlArg('bid');
100 * @param $numberOfTrxn
102 public function _testAssignBatch($numberOfTrxn) {
103 $this->waitForAjaxContent();
104 $this->select("xpath=//div[@class='dataTables_length']/label/select", "value={$numberOfTrxn}");
105 // Because it tends to cause problems, all uses of sleep() must be justified in comments
106 // Sleep should never be used for wait for anything to load from the server
107 // Justification for this instance: FIXME
108 $this->waitForAjaxContent();
109 $this->click('toggleSelect');
110 $this->select('trans_assign', 'value=Assign');
116 * @param int $batchId
117 * @param $exportFormat
119 public function _testExportBatch($setTitle, $batchId, $exportFormat) {
120 $this->openCiviPage("financial/batch", "reset=1&action=export&id=$batchId");
121 if ($exportFormat == 'CSV') {
122 $this->click("xpath=//form[@id='FinancialBatch']/div[2]/table[@class='form-layout']/tbody/tr/td/input[1]");
123 $this->click('_qf_FinancialBatch_next-botttom');
124 $this->waitForPageToLoad($this->getTimeoutMsec());
127 $this->click("xpath=//form[@id='FinancialBatch']/div[2]/table[@class='form-layout']/tbody/tr/td/input[1]");
128 $this->click('_qf_FinancialBatch_next-botttom');
129 $this->waitForPageToLoad($this->getTimeoutMsec());
131 $this->openCiviPage("dashboard", "reset=1");
132 $this->clickLink("xpath=//div[@id='crm-recently-viewed']/ul/li[1]/a", "_qf_Activity_cancel-bottom");
133 $this->webtestVerifyTabularData(
135 'Current Attachment(s)' => 'Financial_Transactions_',