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_MemberTest
32 class WebTest_Import_MemberTest
extends ImportCiviSeleniumTestCase
{
34 protected function setUp() {
39 * Test participant import for Individuals.
41 public function testMemberImportIndividual() {
43 $this->webtestLogin();
45 // Get membership import data for Individuals.
46 list($headers, $rows, $fieldMapper) = $this->_memberIndividualCSVData();
48 // Import participants and check imported data.
49 $this->importCSVComponent('Membership', $headers, $rows, 'Individual', 'Skip', $fieldMapper);
53 * Test participant import for Households.
55 public function testMemberImportHousehold() {
57 $this->webtestLogin();
59 // Get membership import data for Households.
60 list($headers, $rows, $fieldMapper) = $this->_memberHouseholdCSVData();
62 // Import participants and check imported data.
63 $this->importCSVComponent('Membership', $headers, $rows, 'Household', 'Skip', $fieldMapper);
67 * Test participant import for Organizations.
69 public function testMemberImportOrganization() {
71 $this->webtestLogin();
73 // Get membership import data for Organizations.
74 list($headers, $rows, $fieldMapper) = $this->_memberOrganizationCSVData();
76 // Import participants and check imported data.
77 $this->importCSVComponent('Membership', $headers, $rows, 'Organization', 'Skip', $fieldMapper);
81 * Helper function to provide data for Membeship import for Individuals.
85 public function _memberIndividualCSVData() {
86 $memTypeParams = $this->webtestAddMembershipType();
88 $firstName1 = substr(sha1(rand()), 0, 7);
89 $email1 = 'mail_' . substr(sha1(rand()), 0, 7) . '@example.com';
90 $this->webtestAddContact($firstName1, 'Anderson', $email1);
91 $startDate1 = date('Y-m-d');
93 $firstName2 = substr(sha1(rand()), 0, 7);
94 $email2 = 'mail_' . substr(sha1(rand()), 0, 7) . '@example.com';
95 $this->webtestAddContact($firstName2, 'Anderson', $email2);
96 $year = date('Y') - 1;
97 $startDate2 = date('Y-m-d', mktime(0, 0, 0, 9, 10, $year));
101 'membership_type_id' => 'Membership Type',
102 'membership_start_date' => 'Membership Start Date',
108 'membership_type_id' => $memTypeParams['membership_type'],
109 'membership_start_date' => $startDate1,
113 'membership_type_id' => $memTypeParams['membership_type'],
114 'membership_start_date' => $startDate2,
118 $fieldMapper = array(
119 'mapper[0][0]' => 'email',
120 'mapper[1][0]' => 'membership_type_id',
121 'mapper[2][0]' => 'membership_start_date',
123 return array($headers, $rows, $fieldMapper);
127 * Helper function to provide data for Membeship import for Households.
131 public function _memberHouseholdCSVData() {
132 $memTypeParams = $this->webtestAddMembershipType();
134 $household1 = substr(sha1(rand()), 0, 7) . ' home';
135 $this->webtestAddHousehold($household1, TRUE);
136 $startDate1 = date('Y-m-d');
138 $household2 = substr(sha1(rand()), 0, 7) . ' home';
139 $this->webtestAddHousehold($household2, TRUE);
140 $year = date('Y') - 1;
141 $startDate2 = date('Y-m-d', mktime(0, 0, 0, 12, 31, $year));
144 'household_name' => 'Household Name',
145 'membership_type_id' => 'Membership Type',
146 'membership_start_date' => 'Membership Start Date',
151 'household_name' => $household1,
152 'membership_type_id' => $memTypeParams['membership_type'],
153 'membership_start_date' => $startDate1,
156 'household_name' => $household2,
157 'membership_type_id' => $memTypeParams['membership_type'],
158 'membership_start_date' => $startDate2,
162 $fieldMapper = array(
163 'mapper[0][0]' => 'household_name',
164 'mapper[1][0]' => 'membership_type_id',
165 'mapper[2][0]' => 'membership_start_date',
167 return array($headers, $rows, $fieldMapper);
171 * Helper function to provide data for Membeship import for Organizations.
175 public function _memberOrganizationCSVData() {
176 $memTypeParams = $this->webtestAddMembershipType();
178 $organization1 = substr(sha1(rand()), 0, 7) . ' org';
179 $this->webtestAddOrganization($organization1, TRUE);
180 $startDate1 = date('Y-m-d');
182 $organization2 = substr(sha1(rand()), 0, 7) . ' org';
183 $this->webtestAddOrganization($organization2, TRUE);
184 $year = date('Y') - 1;
185 $startDate2 = date('Y-m-d', mktime(0, 0, 0, 12, 31, $year));
188 'organization_name' => 'Organization Name',
189 'membership_type_id' => 'Membership Type',
190 'membership_start_date' => 'Membership Start Date',
195 'organization_name' => $organization1,
196 'membership_type_id' => $memTypeParams['membership_type'],
197 'membership_start_date' => $startDate1,
200 'organization_name' => $organization2,
201 'membership_type_id' => $memTypeParams['membership_type'],
202 'membership_start_date' => $startDate2,
206 $fieldMapper = array(
207 'mapper[0][0]' => 'organization_name',
208 'mapper[1][0]' => 'membership_type_id',
209 'mapper[2][0]' => 'membership_start_date',
211 return array($headers, $rows, $fieldMapper);