X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=tests%2Fphpunit%2FWebTest%2FFinancial%2FFinancialBatchExport.php;h=457288430ecdbd73a319d9e15c49ab7a77730616;hb=b6708aebbc04438be1e5a8a97213d0fc9a89d483;hp=565f4197c47543dee58718b24c0c02c4f8b57f1e;hpb=727983225106f0901a3f8639a068a1aa71fb18e4;p=civicrm-core.git diff --git a/tests/phpunit/WebTest/Financial/FinancialBatchExport.php b/tests/phpunit/WebTest/Financial/FinancialBatchExport.php index 565f4197c4..457288430e 100644 --- a/tests/phpunit/WebTest/Financial/FinancialBatchExport.php +++ b/tests/phpunit/WebTest/Financial/FinancialBatchExport.php @@ -1,120 +1,120 @@ -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 - $batchId = $this->urlArg('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" ); +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 + $batchId = $this->urlArg('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_' - ) - ); - } -} + 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_' + ) + ); + } +}