3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2016 |
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';
30 * Class WebTest_Import_ContributionTest
32 class WebTest_Import_ContributionTest
extends ImportCiviSeleniumTestCase
{
34 protected function setUp() {
38 public function testContributionImportIndividual() {
40 $this->webtestLogin();
42 // Get sample import data.
43 list($headers, $rows) = $this->_contributionIndividualCSVData();
45 // Create and import csv from provided data and check imported data.
47 'mapper[0][0]' => 'email',
48 'mapper[2][0]' => 'financial_type',
49 'mapper[4][0]' => 'total_amount',
51 $this->importCSVComponent('Contribution', $headers, $rows, 'Individual', 'Insert new contributions', $fieldMapper);
54 public function testContributionImportOrganization() {
56 $this->webtestLogin();
58 // Get sample import data.
59 list($headers, $rows) = $this->_contributionOrganizationCSVData();
61 'mapper[0][0]' => 'organization_name',
62 'mapper[2][0]' => 'financial_type',
63 'mapper[4][0]' => 'total_amount',
65 $this->importCSVComponent('Contribution', $headers, $rows, 'Organization', 'Insert new contributions', $fieldMapper);
68 public function testContributionImportHousehold() {
70 $this->webtestLogin();
72 // Get sample import data.
73 list($headers, $rows) = $this->_contributionHouseholdCSVData();
75 'mapper[0][0]' => 'household_name',
76 'mapper[2][0]' => 'financial_type',
77 'mapper[4][0]' => 'total_amount',
79 $this->importCSVComponent('Contribution', $headers, $rows, 'Household', 'Insert new contributions', $fieldMapper);
85 public function _contributionIndividualCSVData() {
86 $firstName1 = substr(sha1(rand()), 0, 7);
87 $email1 = 'mail_' . substr(sha1(rand()), 0, 7) . '@example.com';
88 $this->webtestAddContact($firstName1, 'Anderson', $email1);
90 $firstName2 = substr(sha1(rand()), 0, 7);
91 $email2 = 'mail_' . substr(sha1(rand()), 0, 7) . '@example.com';
92 $this->webtestAddContact($firstName2, 'Anderson', $email2);
96 'fee_amount' => 'Fee Amount',
97 'financial_type' => 'Financial Type',
98 'contribution_status_id' => 'Contribution Status',
99 'total_amount' => 'Total Amount',
105 'fee_amount' => '200',
106 'financial_type' => 'Donation',
107 'contribution_status_id' => 'Completed',
108 'total_amount' => '200',
112 'fee_amount' => '400',
113 'financial_type' => 'Donation',
114 'contribution_status_id' => 'Completed',
115 'total_amount' => '400',
119 return array($headers, $rows);
125 public function _contributionHouseholdCSVData() {
126 $household1 = substr(sha1(rand()), 0, 7) . ' home';
127 $this->webtestAddHousehold($household1, TRUE);
129 $household2 = substr(sha1(rand()), 0, 7) . ' home';
130 $this->webtestAddHousehold($household2, TRUE);
133 'household' => 'Household Name',
134 'fee_amount' => 'Fee Amount',
135 'financial_type' => 'financial Type',
136 'contribution_status_id' => 'Contribution Status',
137 'total_amount' => 'Total Amount',
142 'household' => $household1,
143 'fee_amount' => '200',
144 'financial_type' => 'Donation',
145 'contribution_status_id' => 'Completed',
146 'total_amount' => '200',
149 'household' => $household2,
150 'fee_amount' => '400',
151 'financial_type' => 'Donation',
152 'contribution_status_id' => 'Completed',
153 'total_amount' => '400',
157 return array($headers, $rows);
163 public function _contributionOrganizationCSVData() {
164 $organization1 = substr(sha1(rand()), 0, 7) . ' org';
165 $this->webtestAddOrganization($organization1, TRUE);
167 $organization2 = substr(sha1(rand()), 0, 7) . ' org';
168 $this->webtestAddOrganization($organization2, TRUE);
171 'organization' => 'Organization Name',
172 'fee_amount' => 'Fee Amount',
173 'financial_type' => 'Financial Type',
174 'contribution_status_id' => 'Contribution Status',
175 'total_amount' => 'Total Amount',
180 'organization' => $organization1,
181 'fee_amount' => '200',
182 'financial_type' => 'Donation',
183 'contribution_status_id' => 'Completed',
184 'total_amount' => '200',
187 'organization' => $organization2,
188 'fee_amount' => '400',
189 'financial_type' => 'Donation',
190 'contribution_status_id' => 'Completed',
191 'total_amount' => '400',
195 return array($headers, $rows);