Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
8d7a9d07 | 3 | +--------------------------------------------------------------------+ |
81621fee | 4 | | CiviCRM version 4.7 | |
8d7a9d07 | 5 | +--------------------------------------------------------------------+ |
fa938177 | 6 | | Copyright CiviCRM LLC (c) 2004-2016 | |
8d7a9d07 CB |
7 | +--------------------------------------------------------------------+ |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
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. | | |
13 | | | | |
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. | | |
18 | | | | |
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 | +--------------------------------------------------------------------+ | |
e70a7fc0 | 25 | */ |
6a488035 | 26 | |
6a488035 | 27 | require_once 'WebTest/Import/ImportCiviSeleniumTestCase.php'; |
e9479dcf EM |
28 | |
29 | /** | |
30 | * Class WebTest_Import_MultipleRelationshipTest | |
31 | */ | |
6a488035 TO |
32 | class WebTest_Import_MultipleRelationshipTest extends ImportCiviSeleniumTestCase { |
33 | ||
6a488035 TO |
34 | protected function setUp() { |
35 | parent::setUp(); | |
36 | } | |
37 | ||
d424ffde CW |
38 | /** |
39 | * Test Multiple Relationship import for Individuals. | |
40 | */ | |
00be9182 | 41 | public function testMultipleRelationshipImport() { |
6a488035 TO |
42 | $this->webtestLogin(); |
43 | ||
44 | // Get sample import data. | |
45 | list($headers, $rows, $fieldMapper) = $this->_individualRelationshipCSVData(); | |
46 | ||
47 | // Import Individuals with multiple relationships | |
48 | $this->importContacts($headers, $rows, 'Individual', 'Skip', $fieldMapper); | |
49 | } | |
50 | ||
d424ffde | 51 | /** |
eceb18cc | 52 | * Helper function to provide data for multiple relationship import. |
76e86fd8 | 53 | * for Individuals. |
d424ffde | 54 | * |
4cbe18b8 | 55 | * @return array |
6a488035 | 56 | */ |
00be9182 | 57 | public function _individualRelationshipCSVData() { |
6a488035 TO |
58 | |
59 | $headers = array( | |
60 | 'first_name' => 'First Name', | |
61 | 'middle_name' => 'Middle Name', | |
62 | 'last_name' => 'Last Name', | |
63 | 'email' => 'Email', | |
64 | 'phone' => 'Phone', | |
65 | 'address_1' => 'Additional Address 1', | |
66 | 'address_2' => 'Additional Address 2', | |
67 | 'city' => 'City', | |
68 | 'state' => 'State', | |
69 | 'country' => 'Country', | |
70 | 'contact_relationships' => | |
8d7a9d07 CB |
71 | array( |
72 | '4_a_b' => array( | |
73 | 'organization_name' => 'Organization Name', | |
74 | 'organization_email' => 'Organization Email', | |
75 | 'organization_add' => 'Organization Street Address', | |
76 | 'organization_city' => 'Organization City', | |
77 | 'organization_state' => 'Organization State', | |
78 | 'organization_country' => 'Organization Country', | |
79 | ), | |
80 | '7_a_b' => array( | |
81 | 'household_name' => 'Household Name', | |
82 | 'household_email' => 'Household Name', | |
83 | 'household_add' => 'Household Street Address', | |
84 | 'household_city' => 'Household City', | |
85 | 'household_state' => 'Household State', | |
86 | 'household_country' => 'Household Country', | |
87 | ), | |
88 | '2_a_b' => array( | |
89 | 'spouse_f_name' => 'Spouse First Name', | |
90 | 'spouse_l_name' => 'Spouse Last Name', | |
91 | 'spouse_email' => 'Spouse Email', | |
92 | 'spouse_add' => 'Spouse Street Address', | |
93 | 'spouse_city' => 'Spouse City', | |
94 | 'spouse_state' => 'Spouse State', | |
95 | 'spouse_country' => 'Spouse Country', | |
6a488035 | 96 | ), |
8d7a9d07 | 97 | ), |
6a488035 TO |
98 | ); |
99 | ||
100 | $rows = array( | |
6c6e6187 | 101 | array( |
92915c55 | 102 | 'first_name' => substr(sha1(rand()), 0, 7), |
6a488035 TO |
103 | 'middle_name' => substr(sha1(rand()), 0, 7), |
104 | 'last_name' => 'Anderson', | |
105 | 'email' => substr(sha1(rand()), 0, 7) . '@example.com', | |
106 | 'phone' => '6949912154', | |
107 | 'address_1' => 'Add 1', | |
108 | 'address_2' => 'Add 2', | |
109 | 'city' => 'Watson', | |
110 | 'state' => 'NY', | |
86797006 | 111 | 'country' => 'UNITED STATES', |
6a488035 | 112 | 'contact_relationships' => |
8d7a9d07 CB |
113 | array( |
114 | '4_a_b' => array( | |
115 | 'organization_name' => 'Org ' . substr(sha1(rand()), 0, 7), | |
116 | 'organization_email' => substr(sha1(rand()), 0, 7) . 'org@example.org', | |
117 | 'organization_add' => 'Org Street Address', | |
118 | 'organization_city' => 'Org City', | |
119 | 'organization_state' => 'NY', | |
86797006 | 120 | 'organization_country' => 'UNITED STATES', |
6a488035 | 121 | ), |
8d7a9d07 CB |
122 | '7_a_b' => array( |
123 | 'household_name' => 'House ' . substr(sha1(rand()), 0, 7), | |
124 | 'household_email' => substr(sha1(rand()), 0, 7) . 'house@example.org', | |
125 | 'household_add' => 'House Street Address', | |
126 | 'household_city' => 'House City', | |
127 | 'household_state' => 'NY', | |
86797006 | 128 | 'household_country' => 'UNITED STATES', |
8d7a9d07 CB |
129 | ), |
130 | '2_a_b' => array( | |
131 | 'spouse_f_name' => substr(sha1(rand()), 0, 7), | |
132 | 'spouse_l_name' => substr(sha1(rand()), 0, 7), | |
133 | 'spouse_email' => substr(sha1(rand()), 0, 7) . 'spouse@example.org', | |
134 | 'spouse_add' => 'Spouse Street Address', | |
135 | 'spouse_city' => 'Spouse City', | |
136 | 'spouse_state' => 'NY', | |
86797006 | 137 | 'spouse_country' => 'UNITED STATES', |
8d7a9d07 CB |
138 | ), |
139 | ), | |
6a488035 | 140 | ), |
6c6e6187 | 141 | array( |
92915c55 | 142 | 'first_name' => substr(sha1(rand()), 0, 7), |
6a488035 TO |
143 | 'middle_name' => substr(sha1(rand()), 0, 7), |
144 | 'last_name' => 'Summerson', | |
145 | 'email' => substr(sha1(rand()), 0, 7) . '@example.com', | |
146 | 'phone' => '6944412154', | |
147 | 'address_1' => 'Add 1', | |
148 | 'address_2' => 'Add 2', | |
149 | 'city' => 'Watson', | |
150 | 'state' => 'NY', | |
86797006 | 151 | 'country' => 'UNITED STATES', |
6a488035 | 152 | 'contact_relationships' => |
8d7a9d07 CB |
153 | array( |
154 | '4_a_b' => array( | |
155 | 'organization_name' => 'Org ' . substr(sha1(rand()), 0, 7), | |
156 | 'organization_email' => substr(sha1(rand()), 0, 7) . 'org@example.org', | |
157 | 'organization_add' => 'Org Street Address', | |
158 | 'organization_city' => 'Org City', | |
159 | 'organization_state' => 'NY', | |
86797006 | 160 | 'organization_country' => 'UNITED STATES', |
6a488035 | 161 | ), |
8d7a9d07 CB |
162 | '7_a_b' => array( |
163 | 'household_name' => 'House ' . substr(sha1(rand()), 0, 7), | |
164 | 'household_email' => substr(sha1(rand()), 0, 7) . 'house@example.org', | |
165 | 'household_add' => 'House Street Address', | |
166 | 'household_city' => 'House City', | |
167 | 'household_state' => 'NY', | |
86797006 | 168 | 'household_country' => 'UNITED STATES', |
8d7a9d07 CB |
169 | ), |
170 | '2_a_b' => array( | |
171 | 'spouse_f_name' => substr(sha1(rand()), 0, 7), | |
172 | 'spouse_l_name' => substr(sha1(rand()), 0, 7), | |
173 | 'spouse_email' => substr(sha1(rand()), 0, 7) . 'spouse@example.org', | |
174 | 'spouse_add' => 'Spouse Street Address', | |
175 | 'spouse_city' => 'Spouse City', | |
176 | 'spouse_state' => 'NY', | |
86797006 | 177 | 'spouse_country' => 'UNITED STATES', |
8d7a9d07 CB |
178 | ), |
179 | ), | |
6a488035 TO |
180 | ), |
181 | ); | |
6c6e6187 | 182 | // for Employee of relationship |
6a488035 TO |
183 | $fieldMapper = array( |
184 | 'mapper[10][0]' => '5_a_b', | |
185 | 'mapper[10][1]' => 'organization_name', | |
186 | 'mapper[11][0]' => '5_a_b', | |
187 | 'mapper[11][1]' => 'email', | |
188 | 'mapper[12][0]' => '5_a_b', | |
189 | 'mapper[12][1]' => 'street_address', | |
190 | 'mapper[13][0]' => '5_a_b', | |
191 | 'mapper[13][1]' => 'city', | |
192 | 'mapper[14][0]' => '5_a_b', | |
193 | 'mapper[14][1]' => 'state_province', | |
194 | 'mapper[15][0]' => '5_a_b', | |
195 | 'mapper[15][1]' => 'country', | |
196 | // for Household Member of relationship | |
197 | 'mapper[16][0]' => '8_a_b', | |
198 | 'mapper[16][1]' => 'household_name', | |
199 | 'mapper[17][0]' => '8_a_b', | |
200 | 'mapper[17][1]' => 'email', | |
201 | 'mapper[18][0]' => '8_a_b', | |
202 | 'mapper[18][1]' => 'street_address', | |
203 | 'mapper[19][0]' => '8_a_b', | |
204 | 'mapper[19][1]' => 'city', | |
205 | 'mapper[20][0]' => '8_a_b', | |
206 | 'mapper[20][1]' => 'state_province', | |
207 | 'mapper[21][0]' => '8_a_b', | |
208 | 'mapper[21][1]' => 'country', | |
209 | // for Spouse of relationship | |
210 | 'mapper[22][0]' => '2_a_b', | |
211 | 'mapper[22][1]' => 'first_name', | |
212 | 'mapper[23][0]' => '2_a_b', | |
213 | 'mapper[23][1]' => 'last_name', | |
214 | 'mapper[24][0]' => '2_a_b', | |
215 | 'mapper[24][1]' => 'email', | |
216 | 'mapper[25][0]' => '2_a_b', | |
217 | 'mapper[25][1]' => 'street_address', | |
218 | 'mapper[26][0]' => '2_a_b', | |
219 | 'mapper[26][1]' => 'city', | |
220 | 'mapper[27][0]' => '2_a_b', | |
221 | 'mapper[27][1]' => 'state_province', | |
222 | 'mapper[28][0]' => '2_a_b', | |
223 | 'mapper[28][1]' => 'country', | |
224 | ); | |
225 | ||
226 | return array($headers, $rows, $fieldMapper); | |
227 | } | |
96025800 | 228 | |
6a488035 | 229 | } |