Add in unit test of to verify the change
authorSeamus Lee <seamuslee001@gmail.com>
Wed, 29 Jan 2020 21:46:04 +0000 (08:46 +1100)
committerSeamus Lee <seamuslee001@gmail.com>
Wed, 29 Jan 2020 21:48:52 +0000 (08:48 +1100)
tests/phpunit/api/v3/ReportTemplateTest.php

index 21653e943fc87e6729957a5d3ed106d09ad02aaa..b87981643c007e21dffe080772f82809dcadcf24 100644 (file)
@@ -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.
    *