quickCleanUpFinancialEntities(); $this->quickCleanUp([ 'civicrm_entity_batch', 'civicrm_batch', ]); parent::tearDown(); } /** * Test the ajax function to get financial transactions. * * Test focus is on ensuring changes to how labels are retrieved does not cause regression. */ public function testGetFinancialTransactionsList(): void { $individualID = $this->individualCreate(); $this->contributionCreate(['contact_id' => $individualID, 'trxn_id' => 12345]); $batch = $this->callAPISuccess('Batch', 'create', ['title' => 'test', 'status_id' => 'Open']); CRM_Core_DAO::executeQuery(" INSERT INTO civicrm_entity_batch (entity_table, entity_id, batch_id) values('civicrm_financial_trxn', 1, 1) "); $_REQUEST['sEcho'] = 1; $_REQUEST['entityID'] = $batch['id']; $_REQUEST['return'] = TRUE; $json = CRM_Financial_Page_AJAX::getFinancialTransactionsList(); $json = str_replace(rtrim(CIVICRM_UF_BASEURL, '/'), 'http://FIX ME', $json); $this->assertEquals('{"sEcho": 1, "iTotalRecords": 1, "iTotalDisplayRecords": 1, "aaData": [ ["","","Anderson, Anthony","$100.00","12345","' . CRM_Utils_Date::customFormat(date('Ymd')) . ' 12:00 AM","' . CRM_Utils_Date::customFormat(date('Ymd')) . ' 12:00 AM",' . '"Credit Card","Completed","Donation","View"]] }', $json); } /** * Test getting open batch. */ public function testGetFinancialTransactionsListOpenBatch(): void { $individualID = $this->individualCreate(); $this->contributionCreate(['contact_id' => $individualID, 'trxn_id' => 12345]); $batch = $this->callAPISuccess('Batch', 'create', ['title' => 'test', 'status_id' => 'Open']); CRM_Core_DAO::executeQuery(" INSERT INTO civicrm_entity_batch (entity_table, entity_id, batch_id) values('civicrm_financial_trxn', 1, 1) "); $_REQUEST['sEcho'] = 1; $_REQUEST['entityID'] = $batch['id']; $_REQUEST['statusID'] = 1; $_REQUEST['notPresent'] = 1; $_REQUEST['return'] = TRUE; $json = CRM_Financial_Page_AJAX::getFinancialTransactionsList(); $json = str_replace(rtrim(CIVICRM_UF_BASEURL, '/'), 'http://FIX ME', $json); $this->assertEquals('{"sEcho": 1, "iTotalRecords": 1, "iTotalDisplayRecords": 1, "aaData": [ ["","","Anderson, Anthony","$5.00","12345","' . CRM_Utils_Date::customFormat(date('Ymd')) . ' 12:00 AM","' . CRM_Utils_Date::customFormat(date('Ymd')) . ' 12:00 AM",' . '"Credit Card","Completed","Donation","ViewAssign"]] }', $json); } }