Commit | Line | Data |
---|---|---|
ae555e90 DS |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
81621fee | 4 | | CiviCRM version 4.7 | |
ae555e90 | 5 | +--------------------------------------------------------------------+ |
15a4309a | 6 | | Copyright CiviCRM LLC (c) 2004-2017 | |
ae555e90 DS |
7 | +--------------------------------------------------------------------+ |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
10 | | CiviCRM is free software; you can copy, modify, and distribute it | | |
11 | | under the terms of the GNU Affero General Public License | | |
12 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | |
13 | | | | |
14 | | CiviCRM is distributed in the hope that it will be useful, but | | |
15 | | WITHOUT ANY WARRANTY; without even the implied warranty of | | |
16 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | |
17 | | See the GNU Affero General Public License for more details. | | |
18 | | | | |
19 | | You should have received a copy of the GNU Affero General Public | | |
20 | | License and the CiviCRM Licensing Exception along | | |
21 | | with this program; if not, contact CiviCRM LLC | | |
22 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
23 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
24 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
25 | +--------------------------------------------------------------------+ | |
d25dd0ee | 26 | */ |
ae555e90 | 27 | |
ae555e90 DS |
28 | /** |
29 | * Test report outcome | |
30 | * | |
4be6c8f8 | 31 | * @package CiviCRM |
ae555e90 DS |
32 | */ |
33 | class CRM_Report_Form_Contribute_DetailTest extends CiviReportTestCase { | |
745bc660 | 34 | protected $_tablesToTruncate = array( |
ae555e90 DS |
35 | 'civicrm_contact', |
36 | 'civicrm_email', | |
37 | 'civicrm_phone', | |
38 | 'civicrm_address', | |
39 | 'civicrm_contribution', | |
40 | ); | |
41 | ||
4cbe18b8 EM |
42 | /** |
43 | * @return array | |
44 | */ | |
ae555e90 DS |
45 | public function dataProvider() { |
46 | return array( | |
47 | array( | |
48 | 'CRM_Report_Form_Contribute_Detail', | |
2efcf0c2 | 49 | array( |
ae555e90 | 50 | 'fields' => array( |
3fbae312 | 51 | 'sort_name', |
ae555e90 DS |
52 | 'first_name', |
53 | 'email', | |
54 | 'total_amount', | |
55 | ), | |
ec24e302 | 56 | 'filters' => array( |
4be6c8f8 | 57 | 'total_amount_op' => 'gte', |
ec24e302 DS |
58 | 'total_amount_value' => 50, |
59 | ), | |
ae555e90 DS |
60 | // FIXME: add filters |
61 | ), | |
2d71e99f TO |
62 | 'fixtures/dataset-ascii.sql', |
63 | 'fixtures/report-ascii.csv', | |
21dfd5f5 | 64 | ), |
ae555e90 DS |
65 | ); |
66 | } | |
67 | ||
00be9182 | 68 | public function setUp() { |
ae555e90 | 69 | parent::setUp(); |
745bc660 | 70 | $this->quickCleanup($this->_tablesToTruncate); |
ae555e90 DS |
71 | } |
72 | ||
00be9182 | 73 | public function tearDown() { |
2d71e99f TO |
74 | parent::tearDown(); |
75 | CRM_Core_DAO::executeQuery('DROP TEMPORARY TABLE IF EXISTS civireport_contribution_detail_temp1'); | |
76 | CRM_Core_DAO::executeQuery('DROP TEMPORARY TABLE IF EXISTS civireport_contribution_detail_temp2'); | |
77 | CRM_Core_DAO::executeQuery('DROP TEMPORARY TABLE IF EXISTS civireport_contribution_detail_temp3'); | |
4be6c8f8 | 78 | } |
ae555e90 DS |
79 | |
80 | /** | |
4be6c8f8 | 81 | * @dataProvider dataProvider |
1e1fdcf6 EM |
82 | * @param $reportClass |
83 | * @param $inputParams | |
84 | * @param $dataSet | |
85 | * @param $expectedOutputCsvFile | |
86 | * @throws \Exception | |
ae555e90 DS |
87 | */ |
88 | public function testReportOutput($reportClass, $inputParams, $dataSet, $expectedOutputCsvFile) { | |
ae555e90 DS |
89 | $config = CRM_Core_Config::singleton(); |
90 | CRM_Utils_File::sourceSQLFile($config->dsn, dirname(__FILE__) . "/{$dataSet}"); | |
91 | ||
4be6c8f8 | 92 | $reportCsvFile = $this->getReportOutputAsCsv($reportClass, $inputParams); |
ae555e90 DS |
93 | $reportCsvArray = $this->getArrayFromCsv($reportCsvFile); |
94 | ||
95 | $expectedOutputCsvArray = $this->getArrayFromCsv(dirname(__FILE__) . "/{$expectedOutputCsvFile}"); | |
3b608e05 | 96 | $this->assertCsvArraysEqual($expectedOutputCsvArray, $reportCsvArray); |
ae555e90 | 97 | } |
96025800 | 98 | |
8c099807 PN |
99 | /** |
100 | * @return array | |
101 | */ | |
102 | public function postalCodeDataProvider() { | |
103 | return array( | |
104 | array( | |
105 | 'CRM_Report_Form_Contribute_Detail', | |
106 | array( | |
107 | 'fields' => array( | |
108 | 'sort_name', | |
109 | 'first_name', | |
110 | 'email', | |
111 | 'total_amount', | |
112 | 'postal_code', | |
113 | ), | |
114 | 'filters' => array( | |
115 | 'postal_code_value' => 'B10 G56', | |
116 | 'postal_code_op' => 'has', | |
117 | ), | |
118 | ), | |
119 | 'fixtures/dataset-ascii.sql', | |
120 | 'fixtures/DetailPostalCodeTest-ascii.csv', | |
121 | ), | |
122 | ); | |
123 | } | |
124 | ||
125 | /** | |
126 | * @dataProvider postalCodeDataProvider | |
127 | * @param $reportClass | |
128 | * @param $inputParams | |
129 | * @param $dataSet | |
130 | * @param $expectedOutputCsvFile | |
131 | * @throws \Exception | |
132 | */ | |
133 | public function testPostalCodeSearchReportOutput($reportClass, $inputParams, $dataSet, $expectedOutputCsvFile) { | |
134 | $config = CRM_Core_Config::singleton(); | |
135 | CRM_Utils_File::sourceSQLFile($config->dsn, dirname(__FILE__) . "/{$dataSet}"); | |
136 | ||
137 | $reportCsvFile = $this->getReportOutputAsCsv($reportClass, $inputParams); | |
138 | $reportCsvArray = $this->getArrayFromCsv($reportCsvFile); | |
139 | ||
140 | $expectedOutputCsvArray = $this->getArrayFromCsv(dirname(__FILE__) . "/{$expectedOutputCsvFile}"); | |
141 | $this->assertCsvArraysEqual($expectedOutputCsvArray, $reportCsvArray); | |
142 | } | |
143 | ||
ae555e90 | 144 | } |