From 977548267cbe07def39c37c5fa2a789c7bddff94 Mon Sep 17 00:00:00 2001 From: demeritcowboy Date: Sun, 12 Jul 2020 07:35:38 -0400 Subject: [PATCH] unnecessary try block --- CRM/Report/Form.php | 8 +++++++- tests/phpunit/CiviTest/CiviReportTestCase.php | 13 ++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/CRM/Report/Form.php b/CRM/Report/Form.php index 2aa9b17f9a..31866f648a 100644 --- a/CRM/Report/Form.php +++ b/CRM/Report/Form.php @@ -3399,6 +3399,11 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND */ public function endPostProcess(&$rows = NULL) { $this->assign('report_class', get_class($this)); + + // This is used by unit tests, where _outputMode is intentionally blank. + // Is there a reason it couldn't just always do this? It effectively does + // the same thing anyway by assigning it to the template (in + // doTemplateAssignment()). if ($this->_storeResultSet) { $this->_resultSet = $rows; } @@ -3500,7 +3505,8 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND /** * Set store result set indicator to TRUE. * - * @todo explain what this does + * This is used by unit tests, along with getResultSet(), to get just + * the output rows unformatted. */ public function storeResultSet() { $this->_storeResultSet = TRUE; diff --git a/tests/phpunit/CiviTest/CiviReportTestCase.php b/tests/phpunit/CiviTest/CiviReportTestCase.php index 855ff29aef..7e71a4d98b 100644 --- a/tests/phpunit/CiviTest/CiviReportTestCase.php +++ b/tests/phpunit/CiviTest/CiviReportTestCase.php @@ -39,15 +39,10 @@ class CiviReportTestCase extends CiviUnitTestCase { public function getReportOutputAsCsv($reportClass, $inputParams) { $reportObj = $this->getReportObject($reportClass, $inputParams); - try { - $rows = $reportObj->getResultSet(); - $tmpFile = $this->createTempDir() . CRM_Utils_File::makeFileName('CiviReport.csv'); - $csvContent = CRM_Report_Utils_Report::makeCsv($reportObj, $rows); - file_put_contents($tmpFile, $csvContent); - } - catch (Exception $e) { - throw $e; - } + $rows = $reportObj->getResultSet(); + $tmpFile = $this->createTempDir() . CRM_Utils_File::makeFileName('CiviReport.csv'); + $csvContent = CRM_Report_Utils_Report::makeCsv($reportObj, $rows); + file_put_contents($tmpFile, $csvContent); return $tmpFile; } -- 2.25.1