copyright and version fixes
[civicrm-core.git] / tests / phpunit / CRM / Report / Form / Contribute / DetailTest.php
CommitLineData
ae555e90
DS
1<?php
2/*
3 +--------------------------------------------------------------------+
232624b1 4 | CiviCRM version 4.4 |
ae555e90
DS
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
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 +--------------------------------------------------------------------+
26*/
27
28require_once 'CiviTest/CiviReportTestCase.php';
29
30/**
31 * Test report outcome
32 *
4be6c8f8 33 * @package CiviCRM
ae555e90
DS
34 */
35class CRM_Report_Form_Contribute_DetailTest extends CiviReportTestCase {
36 static $_tablesToTruncate = array(
37 'civicrm_contact',
38 'civicrm_email',
39 'civicrm_phone',
40 'civicrm_address',
41 'civicrm_contribution',
42 );
43
44 public function dataProvider() {
45 return array(
46 array(
47 'CRM_Report_Form_Contribute_Detail',
2efcf0c2 48 array(
ae555e90 49 'fields' => array(
3fbae312 50 'sort_name',
ae555e90
DS
51 'first_name',
52 'email',
53 'total_amount',
54 ),
ec24e302 55 'filters' => array(
4be6c8f8 56 'total_amount_op' => 'gte',
ec24e302
DS
57 'total_amount_value' => 50,
58 ),
ae555e90
DS
59 // FIXME: add filters
60 ),
2d71e99f
TO
61 'fixtures/dataset-ascii.sql',
62 'fixtures/report-ascii.csv',
63 )
ae555e90
DS
64 );
65 }
66
67 function setUp() {
68 parent::setUp();
2d71e99f
TO
69 $this->foreignKeyChecksOff();
70 $this->quickCleanup(self::$_tablesToTruncate);
ae555e90
DS
71 }
72
4be6c8f8 73 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
ae555e90
DS
82 */
83 public function testReportOutput($reportClass, $inputParams, $dataSet, $expectedOutputCsvFile) {
ae555e90
DS
84 $config = CRM_Core_Config::singleton();
85 CRM_Utils_File::sourceSQLFile($config->dsn, dirname(__FILE__) . "/{$dataSet}");
86
4be6c8f8 87 $reportCsvFile = $this->getReportOutputAsCsv($reportClass, $inputParams);
ae555e90
DS
88 $reportCsvArray = $this->getArrayFromCsv($reportCsvFile);
89
90 $expectedOutputCsvArray = $this->getArrayFromCsv(dirname(__FILE__) . "/{$expectedOutputCsvFile}");
3b608e05 91 $this->assertCsvArraysEqual($expectedOutputCsvArray, $reportCsvArray);
ae555e90
DS
92 }
93}