From 243a28d6fdcc8c66208d67ea2e973d65ffc506d2 Mon Sep 17 00:00:00 2001 From: demeritcowboy Date: Tue, 22 Jun 2021 12:12:02 -0400 Subject: [PATCH] dev/core#2647 - deprecated call to non-static --- CRM/Financial/Page/AJAX.php | 5 ++- CRM/Financial/Page/BatchTransaction.php | 8 ++++ tests/phpunit/CRM/Financial/Page/AjaxTest.php | 37 ++++++++++++++++++- 3 files changed, 46 insertions(+), 4 deletions(-) diff --git a/CRM/Financial/Page/AJAX.php b/CRM/Financial/Page/AJAX.php index 484d7a41d1..b14792abce 100644 --- a/CRM/Financial/Page/AJAX.php +++ b/CRM/Financial/Page/AJAX.php @@ -371,7 +371,7 @@ class CRM_Financial_Page_AJAX { $js = "enableActions('x')"; $row[$financialItem->id]['check'] = ""; $row[$financialItem->id]['action'] = CRM_Core_Action::formLink( - CRM_Financial_Form_BatchTransaction::links(), + (new CRM_Financial_Form_BatchTransaction())->links(), NULL, [ 'id' => $financialItem->id, @@ -389,7 +389,7 @@ class CRM_Financial_Page_AJAX { $js = "enableActions('y')"; $row[$financialItem->id]['check'] = ""; $row[$financialItem->id]['action'] = CRM_Core_Action::formLink( - CRM_Financial_Page_BatchTransaction::links(), + (new CRM_Financial_Page_BatchTransaction())->links(), NULL, [ 'id' => $financialItem->id, @@ -427,6 +427,7 @@ class CRM_Financial_Page_AJAX { if ($financialItem->contact_id) { $row[$financialItem->id]['contact_type'] = CRM_Contact_BAO_Contact_Utils::getImage(!empty($row[$financialItem->id]['contact_sub_type']) ? $row[$financialItem->id]['contact_sub_type'] : CRM_Utils_Array::value('contact_type', $row[$financialItem->id]), FALSE, $financialItem->contact_id); } + // @todo: Is this right? Shouldn't it be adding to the array as we loop? $financialitems = $row; } diff --git a/CRM/Financial/Page/BatchTransaction.php b/CRM/Financial/Page/BatchTransaction.php index cd32c0de9e..9f2221fb02 100644 --- a/CRM/Financial/Page/BatchTransaction.php +++ b/CRM/Financial/Page/BatchTransaction.php @@ -44,6 +44,14 @@ class CRM_Financial_Page_BatchTransaction extends CRM_Core_Page_Basic { /** * Get action Links. * + * @todo: + * While this function only references static self::$_links, we can't make + * the function static because we need to match CRM_Core_Page_Basic. Possibly + * the intent was caching, but there's nothing very time-consuming in here + * that needs it so do we even need $_links? The variable is public - a quick + * look doesn't seem like it's used on its own, but it's hard to fully check + * that. + * * @return array * (reference) of action links */ diff --git a/tests/phpunit/CRM/Financial/Page/AjaxTest.php b/tests/phpunit/CRM/Financial/Page/AjaxTest.php index edef40e678..ed157fc677 100644 --- a/tests/phpunit/CRM/Financial/Page/AjaxTest.php +++ b/tests/phpunit/CRM/Financial/Page/AjaxTest.php @@ -15,6 +15,15 @@ */ class CRM_Financial_Page_AjaxTest extends CiviUnitTestCase { + public function tearDown(): void { + $this->quickCleanUpFinancialEntities(); + $this->quickCleanUp([ + 'civicrm_entity_batch', + 'civicrm_batch', + ]); + parent::tearDown(); + } + /** * Test the ajax function to get financial transactions. * @@ -33,10 +42,34 @@ class CRM_Financial_Page_AjaxTest extends CiviUnitTestCase { $_REQUEST['return'] = TRUE; $json = CRM_Financial_Page_AJAX::getFinancialTransactionsList(); $json = str_replace(rtrim(CIVICRM_UF_BASEURL, '/'), 'http://FIX ME', $json); - $this->assertEquals($json, '{"sEcho": 1, "iTotalRecords": 1, "iTotalDisplayRecords": 1, "aaData": [ ["","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"]] }'); + . 'selectedChild=contribute\" class=\"action-item crm-hover-button\" title=\'View Contribution\' >View"]] }', $json); + } + + /** + * Test getting open batch. + */ + public function testGetFinancialTransactionsListOpenBatch() { + $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); } } -- 2.25.1