3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.3 |
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_MemberTest
extends ImportCiviSeleniumTestCase
{
30 protected function setUp() {
35 * Test participant import for Individuals.
37 function testMemberImportIndividual() {
39 $this->webtestLogin();
41 // Get membership import data for Individuals.
42 list($headers, $rows, $fieldMapper) = $this->_memberIndividualCSVData();
44 // Import participants and check imported data.
45 $this->importCSVComponent('Membership', $headers, $rows, 'Individual', 'Skip', $fieldMapper);
49 * Test participant import for Households.
51 function testMemberImportHousehold() {
53 $this->webtestLogin();
55 // Get membership import data for Households.
56 list($headers, $rows, $fieldMapper) = $this->_memberHouseholdCSVData();
58 // Import participants and check imported data.
59 $this->importCSVComponent('Membership', $headers, $rows, 'Household', 'Skip', $fieldMapper);
63 * Test participant import for Organizations.
65 function testMemberImportOrganization() {
67 $this->webtestLogin();
69 // Get membership import data for Organizations.
70 list($headers, $rows, $fieldMapper) = $this->_memberOrganizationCSVData();
72 // Import participants and check imported data.
73 $this->importCSVComponent('Membership', $headers, $rows, 'Organization', 'Skip', $fieldMapper);
77 * Helper function to provide data for Membeship import for Individuals.
79 function _memberIndividualCSVData() {
80 $memTypeParams = $this->webtestAddMembershipType();
82 $firstName1 = substr(sha1(rand()), 0, 7);
83 $email1 = 'mail_' . substr(sha1(rand()), 0, 7) . '@example.com';
84 $this->webtestAddContact($firstName1, 'Anderson', $email1);
85 $startDate1 = date('Y-m-d');
87 $firstName2 = substr(sha1(rand()), 0, 7);
88 $email2 = 'mail_' . substr(sha1(rand()), 0, 7) . '@example.com';
89 $this->webtestAddContact($firstName2, 'Anderson', $email2);
90 $year = date('Y') - 1;
91 $startDate2 = date('Y-m-d', mktime(0, 0, 0, 9, 10, $year));
95 'membership_type_id' => 'Membership Type',
96 'membership_start_date' => 'Membership Start Date',
102 'membership_type_id' => $memTypeParams['membership_type'],
103 'membership_start_date' => $startDate1,
107 'membership_type_id' => $memTypeParams['membership_type'],
108 'membership_start_date' => $startDate2,
112 $fieldMapper = array(
113 'mapper[0][0]' => 'email',
114 'mapper[1][0]' => 'membership_type_id',
115 'mapper[2][0]' => 'membership_start_date',
117 return array($headers, $rows, $fieldMapper);
121 * Helper function to provide data for Membeship import for Households.
123 function _memberHouseholdCSVData() {
124 $memTypeParams = $this->webtestAddMembershipType();
126 $household1 = substr(sha1(rand()), 0, 7) . ' home';
127 $this->webtestAddHousehold($household1, TRUE);
128 $startDate1 = date('Y-m-d');
130 $household2 = substr(sha1(rand()), 0, 7) . ' home';
131 $this->webtestAddHousehold($household2, TRUE);
132 $year = date('Y') - 1;
133 $startDate2 = date('Y-m-d', mktime(0, 0, 0, 12, 31, $year));
136 'household_name' => 'Household Name',
137 'membership_type_id' => 'Membership Type',
138 'membership_start_date' => 'Membership Start Date',
143 'household_name' => $household1,
144 'membership_type_id' => $memTypeParams['membership_type'],
145 'membership_start_date' => $startDate1,
148 'household_name' => $household2,
149 'membership_type_id' => $memTypeParams['membership_type'],
150 'membership_start_date' => $startDate2,
154 $fieldMapper = array(
155 'mapper[0][0]' => 'household_name',
156 'mapper[1][0]' => 'membership_type_id',
157 'mapper[2][0]' => 'membership_start_date',
159 return array($headers, $rows, $fieldMapper);
163 * Helper function to provide data for Membeship import for Organizations.
165 function _memberOrganizationCSVData() {
166 $memTypeParams = $this->webtestAddMembershipType();
168 $organization1 = substr(sha1(rand()), 0, 7) . ' org';
169 $this->webtestAddOrganization($organization1, TRUE);
170 $startDate1 = date('Y-m-d');
172 $organization2 = substr(sha1(rand()), 0, 7) . ' org';
173 $this->webtestAddOrganization($organization2, TRUE);
174 $year = date('Y') - 1;
175 $startDate2 = date('Y-m-d', mktime(0, 0, 0, 12, 31, $year));
178 'organization_name' => 'Organization Name',
179 'membership_type_id' => 'Membership Type',
180 'membership_start_date' => 'Membership Start Date',
185 'organization_name' => $organization1,
186 'membership_type_id' => $memTypeParams['membership_type'],
187 'membership_start_date' => $startDate1,
190 'organization_name' => $organization2,
191 'membership_type_id' => $memTypeParams['membership_type'],
192 'membership_start_date' => $startDate2,
196 $fieldMapper = array(
197 'mapper[0][0]' => 'organization_name',
198 'mapper[1][0]' => 'membership_type_id',
199 'mapper[2][0]' => 'membership_start_date',
201 return array($headers, $rows, $fieldMapper);