From f5cae495b135dd2653d94730f12d8de74700dd9b Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Thu, 30 Jan 2020 08:46:04 +1100 Subject: [PATCH] Add in unit test of to verify the change --- tests/phpunit/api/v3/ReportTemplateTest.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/phpunit/api/v3/ReportTemplateTest.php b/tests/phpunit/api/v3/ReportTemplateTest.php index 21653e943f..b87981643c 100644 --- a/tests/phpunit/api/v3/ReportTemplateTest.php +++ b/tests/phpunit/api/v3/ReportTemplateTest.php @@ -325,11 +325,28 @@ class api_v3_ReportTemplateTest extends CiviUnitTestCase { $this->markTestIncomplete($reportID . " has non enotices when calling statistics fn"); } $description = "Get Statistics from a report (note there isn't much data to get in the test DB)."; + if ($reportID === 'contribute/summary') { + $this->hookClass->setHook('civicrm_alterReportVar', [$this, 'alterReportVarHook']); + } $result = $this->callAPIAndDocument('report_template', 'getstatistics', [ 'report_id' => $reportID, ], __FUNCTION__, __FILE__, $description, 'Getstatistics', 'getstatistics'); } + /** + * Implements hook_civicrm_alterReportVar(). + */ + public function alterReportVarHook($varType, &$var, &$object) { + if ($varType === 'sql' && $object instanceof CRM_Report_Form_Contribute_Summary) { + $from = $var->getVar('_from'); + $from .= " LEFT JOIN civicrm_financial_type as temp ON temp.id = contribution_civireport.financial_type_id"; + $var->setVar('_from', $from); + $where = $var->getVar('_where'); + $where .= " AND ( temp.id IS NOT NULL )"; + $var->setVar('_where', $where); + } + } + /** * Data provider function for getting all templates. * -- 2.25.1