From ec24e302aa1d208cf414c0b52726818ba624df80 Mon Sep 17 00:00:00 2001 From: Deepak Srivastava Date: Mon, 3 Jun 2013 18:05:18 +0530 Subject: [PATCH] CRM-12622, filters and more valid assertions ---------------------------------------- * CRM-12622: Create example data files for CiviHR Report Template http://issues.civicrm.org/jira/browse/CRM-12622 --- .../CRM/Report/Form/Contribute/DetailTest.php | 10 ++++++-- .../Form/Contribute/fixtures/report.csv | 18 +++++++-------- tests/phpunit/CiviTest/CiviReportTestCase.php | 23 ++++--------------- 3 files changed, 21 insertions(+), 30 deletions(-) diff --git a/tests/phpunit/CRM/Report/Form/Contribute/DetailTest.php b/tests/phpunit/CRM/Report/Form/Contribute/DetailTest.php index 250ec42eb1..468f75a8b2 100644 --- a/tests/phpunit/CRM/Report/Form/Contribute/DetailTest.php +++ b/tests/phpunit/CRM/Report/Form/Contribute/DetailTest.php @@ -51,6 +51,10 @@ class CRM_Report_Form_Contribute_DetailTest extends CiviReportTestCase { 'email', 'total_amount', ), + 'filters' => array( + 'total_amount_op' => 'gte', + 'total_amount_value' => 50, + ), // FIXME: add filters ), 'fixtures/dataset.sql', @@ -82,7 +86,9 @@ class CRM_Report_Form_Contribute_DetailTest extends CiviReportTestCase { $expectedOutputCsvArray = $this->getArrayFromCsv(dirname(__FILE__) . "/{$expectedOutputCsvFile}"); $this->assertEquals(count($reportCsvArray[0]), count($expectedOutputCsvArray[0]), 'In line ' . __LINE__); - $this->compareCsvFiles($reportCsvFile, dirname(__FILE__) . "/{$expectedOutputCsvFile}"); - // FIXME: add more asserts + foreach($reportCsvArray as $intKey => $strVal) { + $this->assertNotNull($expectedOutputCsvArray[$intKey], 'In line ' . __LINE__); + $this->assertEquals($expectedOutputCsvArray[$intKey], $strVal); + } } } diff --git a/tests/phpunit/CRM/Report/Form/Contribute/fixtures/report.csv b/tests/phpunit/CRM/Report/Form/Contribute/fixtures/report.csv index e56bf8d242..0ff30c800f 100644 --- a/tests/phpunit/CRM/Report/Form/Contribute/fixtures/report.csv +++ b/tests/phpunit/CRM/Report/Form/Contribute/fixtures/report.csv @@ -1,11 +1,9 @@ "Donor Name","First Name","Donor Email","Amount" -" Empowerment Association", , ,"$ 50.00" -"Bachman, Lincoln","Lincoln", ,"$ 175.00" -"Blackwell, Sanford","Sanford","st.blackwell3@testmail.co.pl","$ 250.00" -"Dimitrov, Iris","Iris","irisdimitrov@infomail.co.pl","$ 25.00" -"Dimitrov, Kenny","Kenny", ,"$ 50.00" -"Grant, Megan","Megan","grantm@fishmail.net","$ 500.00" -"merriechowski95@notmail.info", ,"merrie@testmail.co.nz","$ 125.00" -"Müller, Billy","Billy","mller.billy30@example.org","$ 50.00" -"Reynolds, Brent","Brent", ,"$ 10.00" -"Smith, Errol","Errol","errols@sample.com","$ 500.00" +" Empowerment Association", , ,"USD 50.00" +"Bachman, Lincoln","Lincoln", ,"USD 175.00" +"Blackwell, Sanford","Sanford","st.blackwell3@testmail.co.pl","USD 250.00" +"Dimitrov, Kenny","Kenny", ,"USD 50.00" +"Grant, Megan","Megan","grantm@fishmail.net","USD 500.00" +"merriechowski95@notmail.info", ,"merrie@testmail.co.nz","USD 125.00" +"Müller, Billy","Billy","mller.billy30@example.org","USD 50.00" +"Smith, Errol","Errol","errols@sample.com","USD 500.00" diff --git a/tests/phpunit/CiviTest/CiviReportTestCase.php b/tests/phpunit/CiviTest/CiviReportTestCase.php index 77a8c2ae59..5814721645 100644 --- a/tests/phpunit/CiviTest/CiviReportTestCase.php +++ b/tests/phpunit/CiviTest/CiviReportTestCase.php @@ -43,7 +43,11 @@ class CiviReportTestCase extends CiviUnitTestCase { $_GET['fld'] = $fields; $_GET['ufld'] = 1; } - + if (!empty($inputParams['filters'])) { + foreach ($inputParams['filters'] as $key => $val) { + $_GET[$key] = $val; + } + } $reportObj->storeResultSet(); $reportObj->buildForm(); $rows = $reportObj->getResultSet(); @@ -65,21 +69,4 @@ class CiviReportTestCase extends CiviUnitTestCase { } return $arrFile; } - - function compareCsvFiles($csvFile1, $csvFile2) { - $arrFile1 = $this->getArrayFromCsv($csvFile1); - $arrFile2 = $this->getArrayFromCsv($csvFile2); - - $intRow = 0; - foreach($arrFile1 as $intKey => $strVal) { - if (count($strVal) != count($arrFile2[$intKey])) { - //FIXME : exit("Column count doesn't match\n"); - } - if (!isset($arrFile2[$intKey]) || ($arrFile2[$intKey] != $strVal)) { - //FIXME: exit("Column $intKey, row $intRow of $strFile1 doesn't match\n"); - } - $intRow++; - } - // FIXME: print "All rows match fine.\n"; - } } -- 2.25.1