CRM-12622, filters and more valid assertions
authorDeepak Srivastava <deepak.srivastava@webaccess.co.in>
Mon, 3 Jun 2013 12:35:18 +0000 (18:05 +0530)
committerDeepak Srivastava <deepak.srivastava@webaccess.co.in>
Mon, 3 Jun 2013 12:35:18 +0000 (18:05 +0530)
----------------------------------------
* CRM-12622: Create example data files for CiviHR Report Template
  http://issues.civicrm.org/jira/browse/CRM-12622

tests/phpunit/CRM/Report/Form/Contribute/DetailTest.php
tests/phpunit/CRM/Report/Form/Contribute/fixtures/report.csv
tests/phpunit/CiviTest/CiviReportTestCase.php

index 250ec42eb1348b40209f20545075a86d1de5499b..468f75a8b222b84ce60c1ae8ff459978b851ad1d 100644 (file)
@@ -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);
+    }
   }
 }
index e56bf8d24264721f79c8cb07d91ed0958bc89bdc..0ff30c800fd2844b2fded61bc68e880b802ba2f4 100644 (file)
@@ -1,11 +1,9 @@
 "Donor Name","First Name","Donor Email","Amount"\r
-" Empowerment Association", , ,"$ 50.00"\r
-"Bachman, Lincoln","Lincoln", ,"$ 175.00"\r
-"Blackwell, Sanford","Sanford","st.blackwell3@testmail.co.pl","$ 250.00"\r
-"Dimitrov, Iris","Iris","irisdimitrov@infomail.co.pl","$ 25.00"\r
-"Dimitrov, Kenny","Kenny", ,"$ 50.00"\r
-"Grant, Megan","Megan","grantm@fishmail.net","$ 500.00"\r
-"merriechowski95@notmail.info", ,"merrie@testmail.co.nz","$ 125.00"\r
-"Müller, Billy","Billy","mller.billy30@example.org","$ 50.00"\r
-"Reynolds, Brent","Brent", ,"$ 10.00"\r
-"Smith, Errol","Errol","errols@sample.com","$ 500.00"\r
+" Empowerment Association", , ,"USD 50.00"\r
+"Bachman, Lincoln","Lincoln", ,"USD 175.00"\r
+"Blackwell, Sanford","Sanford","st.blackwell3@testmail.co.pl","USD 250.00"\r
+"Dimitrov, Kenny","Kenny", ,"USD 50.00"\r
+"Grant, Megan","Megan","grantm@fishmail.net","USD 500.00"\r
+"merriechowski95@notmail.info", ,"merrie@testmail.co.nz","USD 125.00"\r
+"Müller, Billy","Billy","mller.billy30@example.org","USD 50.00"\r
+"Smith, Errol","Errol","errols@sample.com","USD 500.00"\r
index 77a8c2ae59e2da857f5ac30e8d3eccba92923a75..5814721645565a7e2ea0dd90510c3d3ea9e9d1b0 100644 (file)
@@ -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";
-  }
 }