3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
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);
81 function _contributionIndividualCSVData() {
82 $firstName1 = substr(sha1(rand()), 0, 7);
83 $email1 = 'mail_' . substr(sha1(rand()), 0, 7) . '@example.com';
84 $this->webtestAddContact($firstName1, 'Anderson', $email1);
86 $firstName2 = substr(sha1(rand()), 0, 7);
87 $email2 = 'mail_' . substr(sha1(rand()), 0, 7) . '@example.com';
88 $this->webtestAddContact($firstName2, 'Anderson', $email2);
92 'fee_amount' => 'Fee Amount',
93 'financial_type' => 'Financial Type',
94 'contribution_status_id' => 'Contribution Status',
95 'total_amount' => 'Total Amount',
101 'fee_amount' => '200',
102 'financial_type' => 'Donation',
103 'contribution_status_id' => 'Completed',
104 'total_amount' => '200',
108 'fee_amount' => '400',
109 'financial_type' => 'Donation',
110 'contribution_status_id' => 'Completed',
111 'total_amount' => '400',
115 return array($headers, $rows);
121 function _contributionHouseholdCSVData() {
122 $household1 = substr(sha1(rand()), 0, 7) . ' home';
123 $this->webtestAddHousehold($household1, TRUE);
125 $household2 = substr(sha1(rand()), 0, 7) . ' home';
126 $this->webtestAddHousehold($household2, TRUE);
129 'household' => 'Household Name',
130 'fee_amount' => 'Fee Amount',
131 'financial_type' => 'financial Type',
132 'contribution_status_id' => 'Contribution Status',
133 'total_amount' => 'Total Amount',
138 'household' => $household1,
139 'fee_amount' => '200',
140 'financial_type' => 'Donation',
141 'contribution_status_id' => 'Completed',
142 'total_amount' => '200',
145 'household' => $household2,
146 'fee_amount' => '400',
147 'financial_type' => 'Donation',
148 'contribution_status_id' => 'Completed',
149 'total_amount' => '400',
153 return array($headers, $rows);
159 function _contributionOrganizationCSVData() {
160 $organization1 = substr(sha1(rand()), 0, 7) . ' org';
161 $this->webtestAddOrganization($organization1, TRUE);
163 $organization2 = substr(sha1(rand()), 0, 7) . ' org';
164 $this->webtestAddOrganization($organization2, TRUE);
167 'organization' => 'Organization Name',
168 'fee_amount' => 'Fee Amount',
169 'financial_type' => 'Financial Type',
170 'contribution_status_id' => 'Contribution Status',
171 'total_amount' => 'Total Amount',
176 'organization' => $organization1,
177 'fee_amount' => '200',
178 'financial_type' => 'Donation',
179 'contribution_status_id' => 'Completed',
180 'total_amount' => '200',
183 'organization' => $organization2,
184 'fee_amount' => '400',
185 'financial_type' => 'Donation',
186 'contribution_status_id' => 'Completed',
187 'total_amount' => '400',
191 return array($headers, $rows);