X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=tests%2Fphpunit%2FCiviTest%2FCiviReportTestCase.php;h=5d54fee994796a39ced8e5dfc1ab0392c560fdda;hb=e70a7fc01e4d73954614f33ff4ba352ec41c2334;hp=b51a0e2deb40c513c35ce9a281cb85aa9c2182b4;hpb=d5f6077993b1df66a934933af0bc9327cff13e78;p=civicrm-core.git diff --git a/tests/phpunit/CiviTest/CiviReportTestCase.php b/tests/phpunit/CiviTest/CiviReportTestCase.php index b51a0e2deb..5d54fee994 100644 --- a/tests/phpunit/CiviTest/CiviReportTestCase.php +++ b/tests/phpunit/CiviTest/CiviReportTestCase.php @@ -1,7 +1,7 @@ _sethtmlGlobals(); } - function tearDown() { + public function tearDown() { // TODO Figure out how to automatically drop all temporary tables. // Note that MySQL doesn't provide a way to list them, so we would need // to keep track ourselves (eg CRM_Core_TemporaryTableManager) or reset @@ -43,7 +46,14 @@ class CiviReportTestCase extends CiviUnitTestCase { parent::tearDown(); } - function getReportOutputAsCsv($reportClass, $inputParams) { + /** + * @param $reportClass + * @param array $inputParams + * + * @return string + * @throws Exception + */ + public function getReportOutputAsCsv($reportClass, $inputParams) { $config = CRM_Core_Config::singleton(); $config->keyDisable = TRUE; $controller = new CRM_Core_Controller_Simple($reportClass, ts('some title')); @@ -80,7 +90,8 @@ class CiviReportTestCase extends CiviUnitTestCase { $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) { + } + catch (Exception $e) { // print_r($e->getCause()->getUserInfo()); CRM_Utils_GlobalStack::singleton()->pop(); throw $e; @@ -90,7 +101,12 @@ class CiviReportTestCase extends CiviUnitTestCase { return $tmpFile; } - function getArrayFromCsv($csvFile) { + /** + * @param $csvFile + * + * @return array + */ + public function getArrayFromCsv($csvFile) { $arrFile = array(); if (($handle = fopen($csvFile, "r")) !== FALSE) { while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { @@ -102,8 +118,10 @@ class CiviReportTestCase extends CiviUnitTestCase { } /** - * @param array $expectedCsvArray two-dimensional array representing a CSV table - * @param array $actualCsvArray two-dimensional array representing a CSV table + * @param array $expectedCsvArray + * Two-dimensional array representing a CSV table. + * @param array $actualCsvArray + * Two-dimensional array representing a CSV table. */ public function assertCsvArraysEqual($expectedCsvArray, $actualCsvArray) { // TODO provide better debug output @@ -122,18 +140,23 @@ class CiviReportTestCase extends CiviUnitTestCase { foreach ($actualCsvArray as $intKey => $strVal) { $rowData = var_export(array( 'expected' => $expectedCsvArray[$intKey], - 'actual' => $actualCsvArray[$intKey], + 'actual' => $actualCsvArray[$intKey], ), TRUE); $this->assertNotNull($expectedCsvArray[$intKey], 'In line ' . __LINE__); $this->assertEquals( count($actualCsvArray[$intKey]), count($expectedCsvArray[$intKey]), - 'Arrays have different number of columns at row ' . $intKey . '; in line ' . __LINE__. '; data: ' . $rowData + 'Arrays have different number of columns at row ' . $intKey . '; in line ' . __LINE__ . '; data: ' . $rowData ); $this->assertEquals($expectedCsvArray[$intKey], $strVal); } } + /** + * @param $rows + * + * @return string + */ public function flattenCsvArray($rows) { $result = ''; foreach ($rows as $row) { @@ -141,4 +164,5 @@ class CiviReportTestCase extends CiviUnitTestCase { } return $result; } + }