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