Mass switch to openCiviPage method
[civicrm-core.git] / tests / phpunit / WebTest / Financial / FinancialBatchExport.php
CommitLineData
6a488035
TO
1<?php\r
2/*\r
3 +--------------------------------------------------------------------+\r
4 | CiviCRM version 4.3 |\r
5 +--------------------------------------------------------------------+\r
6 | Copyright CiviCRM LLC (c) 2004-2013 |\r
7 +--------------------------------------------------------------------+\r
8 | This file is a part of CiviCRM. |\r
9 | |\r
10 | CiviCRM is free software; you can copy, modify, and distribute it |\r
11 | under the terms of the GNU Affero General Public License |\r
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |\r
13 | |\r
14 | CiviCRM is distributed in the hope that it will be useful, but |\r
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |\r
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |\r
17 | See the GNU Affero General Public License for more details. |\r
18 | |\r
19 | You should have received a copy of the GNU Affero General Public |\r
20 | License along with this program; if not, contact CiviCRM LLC |\r
21 | at info[AT]civicrm[DOT]org. If you have questions about the |\r
22 | GNU Affero General Public License or the licensing of CiviCRM, |\r
23 | see the CiviCRM license FAQ at http://civicrm.org/licensing |\r
24 +--------------------------------------------------------------------+\r
25*/\r
26\r
27\r
28require_once 'CiviTest/CiviSeleniumTestCase.php';\r
29class WebTest_Financial_FinancialBatchExport extends CiviSeleniumTestCase {\r
30\r
31 protected function setUp() {\r
32 parent::setUp();\r
33 }\r
34\r
35 function testAddFinancialBatch() {\r
6a488035 36 // Log in using webtestLogin() method\r
42daf119
CW
37 $this->webtestLogin('admin');\r
38 $this->openCiviPage("financial/batch", "reset=1&action=add", '_qf_FinancialBatch_next-botttom');\r
6a488035
TO
39 $setTitle = 'Batch ' . substr(sha1(rand()), 0, 7) . date('Y-m-d');\r
40 $setDescription = 'Test Batch Creation';\r
41 $setPaymentInstrument = 'Credit Card';\r
42 $numberOfTrxn = '10'; // can be 10, 25, 50, 100\r
43 $totalAmt = '1000';\r
44 $exportFormat = 'CSV';\r
45 $batchId = $this->_testAddBatch(\r
46 $setTitle,\r
47 $setDescription,\r
48 $setPaymentInstrument,\r
49 $numberOfTrxn,\r
50 $totalAmt\r
51 );\r
52 $this->_testAssignBatch($numberOfTrxn);\r
53 $this->_testExportBatch($setTitle, $batchId, $exportFormat);\r
54 }\r
55\r
56 function _testAddBatch($setTitle, $setDescription, $setPaymentInstrument, $numberOfTrxn, $totalAmt) {\r
57 // Enter Optional Constraints\r
58 $this->type('title', $setTitle);\r
59 $this->type('description', $setDescription);\r
60 if ($setPaymentInstrument == 'Credit Card') {\r
61 $this->select("payment_instrument_id", "value=1");\r
62 }\r
63 elseif ($setPaymentInstrument == 'Debit Card') {\r
64 $this->select("payment_instrument_id", "value=2");\r
65 }\r
66 elseif ($setPaymentInstrument == 'Cash') {\r
67 $this->select("payment_instrument_id", "value=3");\r
68 }\r
69 elseif ($setPaymentInstrument == 'Check') {\r
70 $this->select("payment_instrument_id", "value=4");\r
71 }\r
72 elseif ($setPaymentInstrument == 'EFT') {\r
73 $this->select("payment_instrument_id", "value=5");\r
74 }\r
75 $this->type('item_count', $numberOfTrxn);\r
76 $this->type('total', $totalAmt);\r
77\r
78 $this->click('_qf_FinancialBatch_next-botttom');\r
79 $this->waitForPageToLoad($this->getTimeoutMsec());\r
80\r
81 // parse URL to grab the batch ID\r
82 $elements = $this->parseURL();\r
83 $batchId = $elements['queryString']['bid'];\r
84 return $batchId;\r
85 }\r
86\r
87 function _testAssignBatch($numberOfTrxn) {\r
88 $this->select( "xpath=//div[@id='crm-transaction-selector-assign_length']/label/select[@name='crm-transaction-selector-assign_length']", "value=$numberOfTrxn" );\r
89 sleep(5);\r
90 $this->click('toggleSelect');\r
91 $this->select('trans_assign', 'value=Assign');\r
92 $this->click('Go');\r
93 sleep(5);\r
94 }\r
95\r
96 function _testExportBatch($setTitle, $batchId, $exportFormat) {\r
071a6d2e 97 $this->openCiviPage("financial/batch", "reset=1&action=export&id=$batchId");\r
6a488035
TO
98 if ($exportFormat == 'CSV') {\r
99 $this->click("xpath=//form[@id='FinancialBatch']/div[2]/table[@class='form-layout']/tbody/tr/td/input[2]");\r
100 $this->click('_qf_FinancialBatch_next-botttom');\r
101 sleep(5);\r
102 }\r
103 else {\r
104 $this->click("xpath=//form[@id='FinancialBatch']/div[2]/table[@class='form-layout']/tbody/tr/td/input[1]");\r
105 $this->click('_qf_FinancialBatch_next-botttom');\r
106 sleep(5);\r
107 }\r
071a6d2e 108 $this->openCiviPage("dashboard", "reset=1");\r
6a488035
TO
109 $this->waitForPageToLoad($this->getTimeoutMsec());\r
110\r
111 $this->click("xpath=//div[@id='recently-viewed']/ul/li[1]/a");\r
112 $this->waitForPageToLoad($this->getTimeoutMsec());\r
113 $this->waitForElementPresent("_qf_Activity_cancel-bottom");\r
114 $this->webtestVerifyTabularData(\r
115 array(\r
116 'Current Attachment(s)' => 'Financial_Transactions_'\r
117 )\r
118 );\r
119 }\r
120}\r