From 8c09980729fae41bd8b53c1c6107257f02fcc069 Mon Sep 17 00:00:00 2001 From: Pradeep Nayak Date: Thu, 10 Nov 2016 00:31:34 +0530 Subject: [PATCH] CRM-19623, added test ---------------------------------------- * CRM-19623: is not of the type Int when report is filtered with postal code https://issues.civicrm.org/jira/browse/CRM-19623 --- .../CRM/Report/Form/Contribute/DetailTest.php | 45 +++++++++++++++++++ .../fixtures/DetailPostalCodeTest-ascii.csv | 5 +++ .../Contribute/fixtures/dataset-ascii.sql | 14 +++--- 3 files changed, 57 insertions(+), 7 deletions(-) create mode 100644 tests/phpunit/CRM/Report/Form/Contribute/fixtures/DetailPostalCodeTest-ascii.csv diff --git a/tests/phpunit/CRM/Report/Form/Contribute/DetailTest.php b/tests/phpunit/CRM/Report/Form/Contribute/DetailTest.php index 4574e4067a..e1f9aa4e46 100644 --- a/tests/phpunit/CRM/Report/Form/Contribute/DetailTest.php +++ b/tests/phpunit/CRM/Report/Form/Contribute/DetailTest.php @@ -96,4 +96,49 @@ class CRM_Report_Form_Contribute_DetailTest extends CiviReportTestCase { $this->assertCsvArraysEqual($expectedOutputCsvArray, $reportCsvArray); } + /** + * @return array + */ + public function postalCodeDataProvider() { + return array( + array( + 'CRM_Report_Form_Contribute_Detail', + array( + 'fields' => array( + 'sort_name', + 'first_name', + 'email', + 'total_amount', + 'postal_code', + ), + 'filters' => array( + 'postal_code_value' => 'B10 G56', + 'postal_code_op' => 'has', + ), + ), + 'fixtures/dataset-ascii.sql', + 'fixtures/DetailPostalCodeTest-ascii.csv', + ), + ); + } + + /** + * @dataProvider postalCodeDataProvider + * @param $reportClass + * @param $inputParams + * @param $dataSet + * @param $expectedOutputCsvFile + * @throws \Exception + */ + public function testPostalCodeSearchReportOutput($reportClass, $inputParams, $dataSet, $expectedOutputCsvFile) { + $config = CRM_Core_Config::singleton(); + CRM_Utils_File::sourceSQLFile($config->dsn, dirname(__FILE__) . "/{$dataSet}"); + + $reportCsvFile = $this->getReportOutputAsCsv($reportClass, $inputParams); + $reportCsvArray = $this->getArrayFromCsv($reportCsvFile); + + $expectedOutputCsvArray = $this->getArrayFromCsv(dirname(__FILE__) . "/{$expectedOutputCsvFile}"); + $this->assertCsvArraysEqual($expectedOutputCsvArray, $reportCsvArray); + } + } diff --git a/tests/phpunit/CRM/Report/Form/Contribute/fixtures/DetailPostalCodeTest-ascii.csv b/tests/phpunit/CRM/Report/Form/Contribute/fixtures/DetailPostalCodeTest-ascii.csv new file mode 100644 index 0000000000..0a5a5150d7 --- /dev/null +++ b/tests/phpunit/CRM/Report/Form/Contribute/fixtures/DetailPostalCodeTest-ascii.csv @@ -0,0 +1,5 @@ +"Donor Name","First Name","Donor Email","Amount","Postal Code" +" Empowerment Association",,,"$ 50.00","B10 G56" +"Bachman, Lincoln","Lincoln",,"$ 175.00","B10 G56" +"Grant, Megan","Megan","grantm@fishmail.net","$ 500.00","B10 G56" +"Reynolds, Brent","Brent",,"$ 10.00","B10 G56" diff --git a/tests/phpunit/CRM/Report/Form/Contribute/fixtures/dataset-ascii.sql b/tests/phpunit/CRM/Report/Form/Contribute/fixtures/dataset-ascii.sql index 821eb5155f..1dd4d8970c 100644 --- a/tests/phpunit/CRM/Report/Form/Contribute/fixtures/dataset-ascii.sql +++ b/tests/phpunit/CRM/Report/Form/Contribute/fixtures/dataset-ascii.sql @@ -24,18 +24,18 @@ SET FOREIGN_KEY_CHECKS=0; -- INSERT INTO `civicrm_address` (`id`, `contact_id`, `location_type_id`, `is_primary`, `is_billing`, `street_address`, `street_number`, `street_number_suffix`, `street_number_predirectional`, `street_name`, `street_type`, `street_number_postdirectional`, `street_unit`, `supplemental_address_1`, `supplemental_address_2`, `supplemental_address_3`, `city`, `county_id`, `state_province_id`, `postal_code_suffix`, `postal_code`, `usps_adc`, `country_id`, `geo_code_1`, `geo_code_2`, `manual_geo_code`, `timezone`, `name`, `master_id`) VALUES -(5, 71, 1, 1, 0, '877P Caulder Way S', 877, 'P', NULL, 'Caulder', 'Way', 'S', NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL), +(5, 71, 1, 1, 0, '877P Caulder Way S', 877, 'P', NULL, 'Caulder', 'Way', 'S', NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, 'B10 G56', NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL), (13, 4, 1, 1, 0, '990G Martin Luther King Dr W', 990, 'G', NULL, 'Martin Luther King', 'Dr', 'W', NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL), -(26, 92, 1, 1, 0, '271X Pine Ave N', 271, 'X', NULL, 'Pine', 'Ave', 'N', NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL), +(26, 92, 1, 1, 0, '271X Pine Ave N', 271, 'X', NULL, 'Pine', 'Ave', 'N', NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, 'B10 G56', NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL), (42, 34, 1, 1, 0, '691V Main Ln W', 691, 'V', NULL, 'Main', 'Ln', 'W', NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL), (83, 6, 2, 1, 0, '249S Martin Luther King Way N', 249, 'S', NULL, 'Martin Luther King', 'Way', 'N', NULL, 'Subscriptions Dept', NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL), -(93, 82, 3, 1, 0, '838D Van Ness Blvd E', 838, 'D', NULL, 'Van Ness', 'Blvd', 'E', NULL, 'Urgent', NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL), -(97, 19, 1, 1, 0, '780L Van Ness St S', 780, 'L', NULL, 'Van Ness', 'St', 'S', NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL), -(128, 8, 1, 1, 0, '527K Main Pl S', 527, 'K', NULL, 'Main', 'Pl', 'S', NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL), +(93, 82, 3, 1, 0, '838D Van Ness Blvd E', 838, 'D', NULL, 'Van Ness', 'Blvd', 'E', NULL, 'Urgent', NULL, NULL, NULL, 1, NULL, NULL, 'B10 G56', NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL), +(97, 19, 1, 1, 0, '780L Van Ness St S', 780, 'L', NULL, 'Van Ness', 'St', 'S', NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, 'B10 G56', NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL), +(128, 8, 1, 1, 0, '527K Main Pl S', 527, 'K', NULL, 'Main', 'Pl', 'S', NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, '444567', NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL), (151, 6, 1, 0, 0, '996S States Ln W', 996, 'S', NULL, 'States', 'Ln', 'W', NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL), -(171, 16, 1, 1, 0, '409K El Camino Path NE', 409, 'K', NULL, 'El Camino', 'Path', 'NE', NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL), +(171, 16, 1, 1, 0, '409K El Camino Path NE', 409, 'K', NULL, 'El Camino', 'Path', 'NE', NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, '54286', NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL), (175, NULL, 1, 1, 1, '14S El Camino Way E', 14, 'S', NULL, 'El Camino', 'Way', NULL, NULL, NULL, NULL, NULL, 'Collinsville', NULL, 1006, NULL, '6022', NULL, 1228, 41.8328, -72.9253, 0, NULL, NULL, NULL), -(176, NULL, 1, 1, 1, '11B Woodbridge Path SW', 11, 'B', NULL, 'Woodbridge', 'Path', NULL, NULL, NULL, NULL, NULL, 'Dayton', NULL, 1034, NULL, '45417', NULL, 1228, 39.7531, -84.2471, 0, NULL, NULL, NULL), +(176, NULL, 1, 1, 1, '11B Woodbridge Path SW', 11, 'B', NULL, 'Woodbridge', 'Path', NULL, NULL, NULL, NULL, NULL, 'Dayton', NULL, 1034, NULL, 'B10 G56', NULL, 1228, 39.7531, -84.2471, 0, NULL, NULL, NULL), (177, NULL, 1, 1, 1, '581O Lincoln Dr SW', 581, 'O', NULL, 'Lincoln', 'Dr', NULL, NULL, NULL, NULL, NULL, 'Santa Fe', NULL, 1030, NULL, '87594', NULL, 1228, 35.5212, -105.982, 0, NULL, NULL, NULL); -- -- 2.25.1