* @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');
$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;
*
* @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);
*/
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.
* 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() {
$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);
+ }
+
}