Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add minimal test for testExportFinancialBatch #15136

Merged
merged 1 commit into from
Aug 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions api/v3/Batch.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
* @param array $params
*
* @return array
* @throws \API_Exception
* @throws \Civi\API\Exception\UnauthorizedException
*/
function civicrm_api3_batch_create($params) {
return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'Batch');
Expand All @@ -56,8 +58,10 @@ function _civicrm_api3_batch_create_spec(&$params) {
$params['entity_table']['api.default'] = "civicrm_batch";
$params['entity_table']['type'] = CRM_Utils_Type::T_STRING;
$params['entity_table']['title'] = 'Batch Entity Table - remove?';

$params['modified_date']['api.default'] = "now";
$params['created_id']['api.default'] = 'user_contact_id';
$params['created_date']['api.default'] = 'now';
$params['modified_id']['api.default'] = 'user_contact_id';
$params['modified_date']['api.default'] = 'now';
$params['status_id']['api.required'] = 1;
$params['title']['api.required'] = 1;
$params['status_id']['api.required'] = 1;
Expand All @@ -82,6 +86,8 @@ function civicrm_api3_batch_get($params) {
*
* @return array
* Array of deleted values.
* @throws \API_Exception
* @throws \Civi\API\Exception\UnauthorizedException
*/
function civicrm_api3_batch_delete($params) {
return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params);
Expand Down
23 changes: 23 additions & 0 deletions tests/phpunit/CRM/Batch/BAO/BatchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@
*/
class CRM_Batch_BAO_BatchTest extends CiviUnitTestCase {

/**
* Cleanup after test.
*
* @throws \CRM_Core_Exception
*/
public function tearDown() {
parent::tearDown();
$this->quickCleanup(['civicrm_batch']);
}

/**
* This test checks that a batch search
* by payment method works.
Expand All @@ -42,6 +52,8 @@ class CRM_Batch_BAO_BatchTest extends CiviUnitTestCase {
* card and one with payment method check. After performing a
* search by payment method for checks, it makes sure that the
* results are only contributions made by check.
*
* @throws \CRM_Core_Exception
*/
public function testGetBatchFinancialItems() {

Expand Down Expand Up @@ -104,4 +116,15 @@ public function testGetBatchFinancialItems() {
$this->assertEquals(count($result), 1, 'In line' . __LINE__);
}

/**
* Test testExportFinancialBatch.
*/
public function testExportFinancialBatch() {
$this->createLoggedInUser();
$batchParams = ['title' => 'Test Batch'];
$batchParams['status_id'] = CRM_Core_PseudoConstant::getKey('CRM_Batch_BAO_Batch', 'status_id', 'Exported');
$batch = $this->callAPISuccess('Batch', 'create', $batchParams);
CRM_Batch_BAO_Batch::exportFinancialBatch([$batch['id']], 'CSV', NULL);
}

}