3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.4 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
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. |
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. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License along with this program; if not, contact CiviCRM LLC |
21 | at info[AT]civicrm[DOT]org. If you have questions about the |
22 | GNU Affero General Public License or the licensing of CiviCRM, |
23 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
24 +--------------------------------------------------------------------+
27 require_once 'WebTest/Import/ImportCiviSeleniumTestCase.php';
28 class WebTest_Import_ContributionTest
extends ImportCiviSeleniumTestCase
{
30 protected function setUp() {
34 function testContributionImportIndividual() {
36 $this->webtestLogin();
38 // Get sample import data.
39 list($headers, $rows) = $this->_contributionIndividualCSVData();
41 // Create and import csv from provided data and check imported data.
43 'mapper[0][0]' => 'email',
44 'mapper[2][0]' => 'financial_type',
45 'mapper[4][0]' => 'total_amount',
47 $this->importCSVComponent('Contribution', $headers, $rows, 'Individual', 'Insert new contributions', $fieldMapper);
50 function testContributionImportOrganization() {
52 $this->webtestLogin();
54 // Get sample import data.
55 list($headers, $rows) = $this->_contributionOrganizationCSVData();
57 'mapper[0][0]' => 'organization_name',
58 'mapper[2][0]' => 'financial_type',
59 'mapper[4][0]' => 'total_amount',
61 $this->importCSVComponent('Contribution', $headers, $rows, 'Organization', 'Insert new contributions', $fieldMapper);
64 function testContributionImportHousehold() {
66 $this->webtestLogin();
68 // Get sample import data.
69 list($headers, $rows) = $this->_contributionHouseholdCSVData();
71 'mapper[0][0]' => 'household_name',
72 'mapper[2][0]' => 'financial_type',
73 'mapper[4][0]' => 'total_amount',
75 $this->importCSVComponent('Contribution', $headers, $rows, 'Household', 'Insert new contributions', $fieldMapper);
78 function _contributionIndividualCSVData() {
79 $firstName1 = substr(sha1(rand()), 0, 7);
80 $email1 = 'mail_' . substr(sha1(rand()), 0, 7) . '@example.com';
81 $this->webtestAddContact($firstName1, 'Anderson', $email1);
83 $firstName2 = substr(sha1(rand()), 0, 7);
84 $email2 = 'mail_' . substr(sha1(rand()), 0, 7) . '@example.com';
85 $this->webtestAddContact($firstName2, 'Anderson', $email2);
89 'fee_amount' => 'Fee Amount',
90 'financial_type' => 'Financial Type',
91 'contribution_status_id' => 'Contribution Status',
92 'total_amount' => 'Total Amount',
98 'fee_amount' => '200',
99 'financial_type' => 'Donation',
100 'contribution_status_id' => 'Completed',
101 'total_amount' => '200',
105 'fee_amount' => '400',
106 'financial_type' => 'Donation',
107 'contribution_status_id' => 'Completed',
108 'total_amount' => '400',
112 return array($headers, $rows);
115 function _contributionHouseholdCSVData() {
116 $household1 = substr(sha1(rand()), 0, 7) . ' home';
117 $this->webtestAddHousehold($household1, TRUE);
119 $household2 = substr(sha1(rand()), 0, 7) . ' home';
120 $this->webtestAddHousehold($household2, TRUE);
123 'household' => 'Household Name',
124 'fee_amount' => 'Fee Amount',
125 'financial_type' => 'financial Type',
126 'contribution_status_id' => 'Contribution Status',
127 'total_amount' => 'Total Amount',
132 'household' => $household1,
133 'fee_amount' => '200',
134 'financial_type' => 'Donation',
135 'contribution_status_id' => 'Completed',
136 'total_amount' => '200',
139 'household' => $household2,
140 'fee_amount' => '400',
141 'financial_type' => 'Donation',
142 'contribution_status_id' => 'Completed',
143 'total_amount' => '400',
147 return array($headers, $rows);
150 function _contributionOrganizationCSVData() {
151 $organization1 = substr(sha1(rand()), 0, 7) . ' org';
152 $this->webtestAddOrganization($organization1, TRUE);
154 $organization2 = substr(sha1(rand()), 0, 7) . ' org';
155 $this->webtestAddOrganization($organization2, TRUE);
158 'organization' => 'Organization Name',
159 'fee_amount' => 'Fee Amount',
160 'financial_type' => 'Financial Type',
161 'contribution_status_id' => 'Contribution Status',
162 'total_amount' => 'Total Amount',
167 'organization' => $organization1,
168 'fee_amount' => '200',
169 'financial_type' => 'Donation',
170 'contribution_status_id' => 'Completed',
171 'total_amount' => '200',
174 'organization' => $organization2,
175 'fee_amount' => '400',
176 'financial_type' => 'Donation',
177 'contribution_status_id' => 'Completed',
178 'total_amount' => '400',
182 return array($headers, $rows);