webtestLogin('admin'); $this->openCiviPage("financial/batch", "reset=1&action=add", '_qf_FinancialBatch_next-botttom'); $setTitle = 'Batch ' . substr(sha1(rand()), 0, 7) . date('Y-m-d'); $setDescription = 'Test Batch Creation'; $setPaymentInstrument = 'Credit Card'; $numberOfTrxn = '10'; // can be 10, 25, 50, 100 $totalAmt = '1000'; $exportFormat = 'CSV'; $batchId = $this->_testAddBatch( $setTitle, $setDescription, $setPaymentInstrument, $numberOfTrxn, $totalAmt ); $this->_testAssignBatch($numberOfTrxn); $this->_testExportBatch($setTitle, $batchId, $exportFormat); } function _testAddBatch($setTitle, $setDescription, $setPaymentInstrument, $numberOfTrxn, $totalAmt) { // Enter Optional Constraints $this->type('title', $setTitle); $this->type('description', $setDescription); if ($setPaymentInstrument == 'Credit Card') { $this->select("payment_instrument_id", "value=1"); } elseif ($setPaymentInstrument == 'Debit Card') { $this->select("payment_instrument_id", "value=2"); } elseif ($setPaymentInstrument == 'Cash') { $this->select("payment_instrument_id", "value=3"); } elseif ($setPaymentInstrument == 'Check') { $this->select("payment_instrument_id", "value=4"); } elseif ($setPaymentInstrument == 'EFT') { $this->select("payment_instrument_id", "value=5"); } $this->type('item_count', $numberOfTrxn); $this->type('total', $totalAmt); $this->click('_qf_FinancialBatch_next-botttom'); $this->waitForPageToLoad($this->getTimeoutMsec()); // parse URL to grab the batch ID $elements = $this->parseURL(); $batchId = $elements['queryString']['bid']; return $batchId; } function _testAssignBatch($numberOfTrxn) { $this->select( "xpath=//div[@id='crm-transaction-selector-assign_length']/label/select[@name='crm-transaction-selector-assign_length']", "value=$numberOfTrxn" ); // Because it tends to cause problems, all uses of sleep() must be justified in comments // Sleep should never be used for wait for anything to load from the server // Justification for this instance: FIXME sleep(5); $this->click('toggleSelect'); $this->select('trans_assign', 'value=Assign'); $this->click('Go'); $this->waitForPageToLoad($this->getTimeoutMsec()); } function _testExportBatch($setTitle, $batchId, $exportFormat) { $this->openCiviPage("financial/batch", "reset=1&action=export&id=$batchId"); if ($exportFormat == 'CSV') { $this->click("xpath=//form[@id='FinancialBatch']/div[2]/table[@class='form-layout']/tbody/tr/td/input[2]"); $this->click('_qf_FinancialBatch_next-botttom'); $this->waitForPageToLoad($this->getTimeoutMsec()); } else { $this->click("xpath=//form[@id='FinancialBatch']/div[2]/table[@class='form-layout']/tbody/tr/td/input[1]"); $this->click('_qf_FinancialBatch_next-botttom'); $this->waitForPageToLoad($this->getTimeoutMsec()); } $this->openCiviPage("dashboard", "reset=1"); $this->waitForPageToLoad($this->getTimeoutMsec()); $this->clickLink("xpath=//div[@id='recently-viewed']/ul/li[1]/a", "_qf_Activity_cancel-bottom"); $this->webtestVerifyTabularData( array( 'Current Attachment(s)' => 'Financial_Transactions_' ) ); } }