Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
81621fee | 4 | | CiviCRM version 4.7 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
e7112fa7 | 6 | | Copyright CiviCRM LLC (c) 2004-2015 | |
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 | +--------------------------------------------------------------------+ | |
d25dd0ee | 25 | */ |
6a488035 | 26 | |
6a488035 | 27 | require_once 'WebTest/Import/ImportCiviSeleniumTestCase.php'; |
e9479dcf EM |
28 | |
29 | /** | |
30 | * Class WebTest_Import_DateFormatTest | |
31 | */ | |
6a488035 TO |
32 | class WebTest_Import_DateFormatTest extends ImportCiviSeleniumTestCase { |
33 | ||
6a488035 TO |
34 | protected function setUp() { |
35 | parent::setUp(); | |
36 | } | |
37 | ||
8d7a9d07 | 38 | /** |
6a488035 TO |
39 | * Test contact import for yyyy_mm_dd date format. |
40 | */ | |
00be9182 | 41 | public function testDateFormat_yyyy_mm_dd() { |
6a488035 TO |
42 | $this->webtestLogin(); |
43 | ||
44 | // Get sample import data. | |
45 | list($headers, $rows) = $this->_individualCSVData_yyyy_mm_dd(); | |
46 | ||
47 | // Import and check Individual contacts in Skip mode and yyyy-mm-dd OR yyyymmdd dateformat. | |
48 | $other = array('dateFormat' => 'yyyy-mm-dd OR yyyymmdd'); | |
49 | ||
50 | $this->importContacts($headers, $rows, 'Individual', 'Skip', array(), $other); | |
51 | } | |
52 | ||
8d7a9d07 | 53 | /** |
6a488035 TO |
54 | * Test contact import for mm_dd_yy date format. |
55 | */ | |
00be9182 | 56 | public function testDateFormat_mm_dd_yy() { |
6a488035 TO |
57 | $this->webtestLogin(); |
58 | ||
59 | // Get sample import data. | |
60 | list($headers, $rows) = $this->_individualCSVData_mm_dd_yy(); | |
61 | ||
62 | // Import and check Individual contacts in Skip mode and | |
63 | // mm/dd/yy OR mm-dd-yy date format. | |
64 | $other = array('dateFormat' => 'mm/dd/yy OR mm-dd-yy'); | |
65 | ||
66 | $this->importContacts($headers, $rows, 'Individual', 'Skip', array(), $other); | |
67 | } | |
68 | ||
8d7a9d07 | 69 | /** |
6a488035 TO |
70 | * Test contact import for mm_dd_yyyy date format. |
71 | */ | |
00be9182 | 72 | public function testDateFormat_mm_dd_yyyy() { |
6a488035 TO |
73 | // Logging in. Remember to wait for page to load. In most cases, |
74 | // you can rely on 30000 as the value that allows your test to pass, however, | |
75 | // sometimes your test might fail because of this. In such cases, it's better to pick one element | |
76 | // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole | |
77 | // page contents loaded | |
78 | $this->webtestLogin(); | |
79 | ||
80 | // Get sample import data. | |
81 | list($headers, $rows) = $this->_individualCSVData_mm_dd_yyyy(); | |
82 | ||
83 | // Import and check Individual contacts in Skip mode and | |
84 | // mm/dd/yyyy OR mm-dd-yyyy date format. | |
85 | $other = array('dateFormat' => 'mm/dd/yyyy OR mm-dd-yyyy'); | |
86 | ||
87 | $this->importContacts($headers, $rows, 'Individual', 'Skip', array(), $other); | |
88 | } | |
89 | ||
8d7a9d07 | 90 | /** |
6a488035 TO |
91 | * Test contact import for Month_dd_yyyy date format. |
92 | */ | |
00be9182 | 93 | public function testDateFormat_Month_dd_yyyy() { |
6a488035 TO |
94 | // Logging in. Remember to wait for page to load. In most cases, |
95 | // you can rely on 30000 as the value that allows your test to pass, however, | |
96 | // sometimes your test might fail because of this. In such cases, it's better to pick one element | |
97 | // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole | |
98 | // page contents loaded | |
99 | $this->webtestLogin(); | |
100 | ||
101 | // Get sample import data. | |
102 | list($headers, $rows) = $this->_individualCSVData_Month_dd_yyyy(); | |
103 | ||
104 | // Import and check Individual contacts in Skip mode and | |
105 | // Month dd, yyyy date format. | |
106 | $other = array('dateFormat' => 'Month dd, yyyy'); | |
107 | ||
108 | $this->importContacts($headers, $rows, 'Individual', 'Skip', array(), $other); | |
109 | } | |
110 | ||
8d7a9d07 | 111 | /** |
6a488035 TO |
112 | * Test contact import for dd_mon_yy date format. |
113 | */ | |
00be9182 | 114 | public function testDateFormat_dd_mon_yy() { |
6a488035 TO |
115 | // Logging in. Remember to wait for page to load. In most cases, |
116 | // you can rely on 30000 as the value that allows your test to pass, however, | |
117 | // sometimes your test might fail because of this. In such cases, it's better to pick one element | |
118 | // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole | |
119 | // page contents loaded | |
120 | $this->webtestLogin(); | |
121 | ||
122 | // Get sample import data. | |
123 | list($headers, $rows) = $this->_individualCSVData_dd_mon_yy(); | |
124 | ||
125 | // Import and check Individual contacts in Skip mode and | |
126 | // dd-mon-yy OR dd/mm/yy date format. | |
127 | $other = array('dateFormat' => 'dd-mon-yy OR dd/mm/yy'); | |
128 | ||
129 | $this->importContacts($headers, $rows, 'Individual', 'Skip', array(), $other); | |
130 | } | |
131 | ||
8d7a9d07 | 132 | /** |
6a488035 TO |
133 | * Test contact import for dd_mm_yyyy date format. |
134 | */ | |
00be9182 | 135 | public function testDateFormat_dd_mm_yyyy() { |
6a488035 TO |
136 | // Logging in. Remember to wait for page to load. In most cases, |
137 | // you can rely on 30000 as the value that allows your test to pass, however, | |
138 | // sometimes your test might fail because of this. In such cases, it's better to pick one element | |
139 | // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole | |
140 | // page contents loaded | |
141 | $this->webtestLogin(); | |
142 | ||
143 | // Get sample import data. | |
144 | list($headers, $rows) = $this->_individualCSVData_dd_mm_yyyy(); | |
145 | ||
146 | // Import and check Individual contacts in Skip mode and | |
147 | // dd/mm/yyyy date format. | |
148 | $other = array('dateFormat' => 'dd/mm/yyyy'); | |
149 | ||
150 | $this->importContacts($headers, $rows, 'Individual', 'Skip', array(), $other); | |
151 | } | |
152 | ||
8d7a9d07 | 153 | /** |
6a488035 TO |
154 | * Helper function to provide data for contact import for Individuals and yyyy-mm-dd OR yyyymmdd dateformat. |
155 | */ | |
4cbe18b8 EM |
156 | /** |
157 | * @return array | |
158 | */ | |
00be9182 | 159 | public function _individualCSVData_yyyy_mm_dd() { |
6a488035 TO |
160 | $headers = array( |
161 | 'first_name' => 'First Name', | |
162 | 'middle_name' => 'Middle Name', | |
163 | 'last_name' => 'Last Name', | |
164 | 'email' => 'Email', | |
165 | 'phone' => 'Phone', | |
166 | 'address_1' => 'Additional Address 1', | |
167 | 'address_2' => 'Additional Address 2', | |
168 | 'city' => 'City', | |
169 | 'state' => 'State', | |
170 | 'country' => 'Country', | |
171 | 'birth_date' => 'Birth Date', | |
172 | ); | |
173 | ||
174 | $rows = array( | |
6c6e6187 | 175 | array( |
92915c55 | 176 | 'first_name' => substr(sha1(rand()), 0, 7), |
6a488035 TO |
177 | 'middle_name' => substr(sha1(rand()), 0, 7), |
178 | 'last_name' => 'Anderson', | |
179 | 'email' => substr(sha1(rand()), 0, 7) . '@example.com', | |
180 | 'phone' => '6949912154', | |
181 | 'address_1' => 'Add 1', | |
182 | 'address_2' => 'Add 2', | |
183 | 'city' => 'Watson', | |
184 | 'state' => 'NY', | |
86797006 | 185 | 'country' => 'UNITED STATES', |
6a488035 TO |
186 | 'birth_date' => '1998-12-25', |
187 | ), | |
6c6e6187 | 188 | array( |
92915c55 | 189 | 'first_name' => substr(sha1(rand()), 0, 7), |
6a488035 TO |
190 | 'middle_name' => substr(sha1(rand()), 0, 7), |
191 | 'last_name' => 'Summerson', | |
192 | 'email' => substr(sha1(rand()), 0, 7) . '@example.com', | |
193 | 'phone' => '6944412154', | |
194 | 'address_1' => 'Add 1', | |
195 | 'address_2' => 'Add 2', | |
196 | 'city' => 'Watson', | |
197 | 'state' => 'NY', | |
86797006 | 198 | 'country' => 'UNITED STATES', |
6a488035 TO |
199 | 'birth_date' => '1999-11-26', |
200 | ), | |
201 | ); | |
202 | ||
203 | return array($headers, $rows); | |
204 | } | |
205 | ||
8d7a9d07 | 206 | /** |
6a488035 TO |
207 | * Helper function to provide data for contact import for Individuals and mm/dd/yy OR mm-dd-yy dateformat. |
208 | */ | |
4cbe18b8 EM |
209 | /** |
210 | * @return array | |
211 | */ | |
00be9182 | 212 | public function _individualCSVData_mm_dd_yy() { |
6a488035 TO |
213 | $headers = array( |
214 | 'first_name' => 'First Name', | |
215 | 'middle_name' => 'Middle Name', | |
216 | 'last_name' => 'Last Name', | |
217 | 'email' => 'Email', | |
218 | 'phone' => 'Phone', | |
219 | 'address_1' => 'Additional Address 1', | |
220 | 'address_2' => 'Additional Address 2', | |
221 | 'city' => 'City', | |
222 | 'state' => 'State', | |
223 | 'country' => 'Country', | |
224 | 'birth_date' => 'Birth Date', | |
225 | ); | |
226 | ||
227 | $rows = array( | |
6c6e6187 | 228 | array( |
92915c55 | 229 | 'first_name' => substr(sha1(rand()), 0, 7), |
6a488035 TO |
230 | 'middle_name' => substr(sha1(rand()), 0, 7), |
231 | 'last_name' => 'Anderson', | |
232 | 'email' => substr(sha1(rand()), 0, 7) . '@example.com', | |
233 | 'phone' => '6949912154', | |
234 | 'address_1' => 'Add 1', | |
235 | 'address_2' => 'Add 2', | |
236 | 'city' => 'Watson', | |
237 | 'state' => 'NY', | |
86797006 | 238 | 'country' => 'UNITED STATES', |
6a488035 TO |
239 | 'birth_date' => '12/23/98', |
240 | ), | |
6c6e6187 | 241 | array( |
92915c55 | 242 | 'first_name' => substr(sha1(rand()), 0, 7), |
6a488035 TO |
243 | 'middle_name' => substr(sha1(rand()), 0, 7), |
244 | 'last_name' => 'Summerson', | |
245 | 'email' => substr(sha1(rand()), 0, 7) . '@example.com', | |
246 | 'phone' => '6944412154', | |
247 | 'address_1' => 'Add 1', | |
248 | 'address_2' => 'Add 2', | |
249 | 'city' => 'Watson', | |
250 | 'state' => 'NY', | |
86797006 | 251 | 'country' => 'UNITED STATES', |
6a488035 TO |
252 | 'birth_date' => '11/24/88', |
253 | ), | |
254 | ); | |
255 | ||
256 | return array($headers, $rows); | |
257 | } | |
258 | ||
8d7a9d07 | 259 | /** |
6a488035 TO |
260 | * Helper function to provide data for contact import for Individuals and mm/dd/yyyy OR mm-dd-yyyy dateformat. |
261 | */ | |
4cbe18b8 EM |
262 | /** |
263 | * @return array | |
264 | */ | |
00be9182 | 265 | public function _individualCSVData_mm_dd_yyyy() { |
6a488035 TO |
266 | $headers = array( |
267 | 'first_name' => 'First Name', | |
268 | 'middle_name' => 'Middle Name', | |
269 | 'last_name' => 'Last Name', | |
270 | 'email' => 'Email', | |
271 | 'phone' => 'Phone', | |
272 | 'address_1' => 'Additional Address 1', | |
273 | 'address_2' => 'Additional Address 2', | |
274 | 'city' => 'City', | |
275 | 'state' => 'State', | |
276 | 'country' => 'Country', | |
277 | 'birth_date' => 'Birth Date', | |
278 | ); | |
279 | ||
280 | $rows = array( | |
6c6e6187 | 281 | array( |
92915c55 | 282 | 'first_name' => substr(sha1(rand()), 0, 7), |
6a488035 TO |
283 | 'middle_name' => substr(sha1(rand()), 0, 7), |
284 | 'last_name' => 'Anderson', | |
285 | 'email' => substr(sha1(rand()), 0, 7) . '@example.com', | |
286 | 'phone' => '6949912154', | |
287 | 'address_1' => 'Add 1', | |
288 | 'address_2' => 'Add 2', | |
289 | 'city' => 'Watson', | |
290 | 'state' => 'NY', | |
86797006 | 291 | 'country' => 'UNITED STATES', |
6a488035 TO |
292 | 'birth_date' => '11/12/1995', |
293 | ), | |
6c6e6187 | 294 | array( |
92915c55 | 295 | 'first_name' => substr(sha1(rand()), 0, 7), |
6a488035 TO |
296 | 'middle_name' => substr(sha1(rand()), 0, 7), |
297 | 'last_name' => 'Summerson', | |
298 | 'email' => substr(sha1(rand()), 0, 7) . '@example.com', | |
299 | 'phone' => '6944412154', | |
300 | 'address_1' => 'Add 1', | |
301 | 'address_2' => 'Add 2', | |
302 | 'city' => 'Watson', | |
303 | 'state' => 'NY', | |
86797006 | 304 | 'country' => 'UNITED STATES', |
6a488035 TO |
305 | 'birth_date' => '12/12/1995', |
306 | ), | |
307 | ); | |
308 | ||
309 | return array($headers, $rows); | |
310 | } | |
311 | ||
8d7a9d07 | 312 | /** |
6a488035 TO |
313 | * Helper function to provide data for contact import for Individuals and Month dd, yyyy dateformat. |
314 | */ | |
4cbe18b8 EM |
315 | /** |
316 | * @return array | |
317 | */ | |
00be9182 | 318 | public function _individualCSVData_Month_dd_yyyy() { |
6a488035 TO |
319 | $headers = array( |
320 | 'first_name' => 'First Name', | |
321 | 'middle_name' => 'Middle Name', | |
322 | 'last_name' => 'Last Name', | |
323 | 'email' => 'Email', | |
324 | 'phone' => 'Phone', | |
325 | 'address_1' => 'Additional Address 1', | |
326 | 'address_2' => 'Additional Address 2', | |
327 | 'city' => 'City', | |
328 | 'state' => 'State', | |
329 | 'country' => 'Country', | |
330 | 'birth_date' => 'Birth Date', | |
331 | ); | |
332 | ||
333 | $rows = array( | |
6c6e6187 | 334 | array( |
92915c55 | 335 | 'first_name' => substr(sha1(rand()), 0, 7), |
6a488035 TO |
336 | 'middle_name' => substr(sha1(rand()), 0, 7), |
337 | 'last_name' => 'Anderson', | |
338 | 'email' => substr(sha1(rand()), 0, 7) . '@example.com', | |
339 | 'phone' => '6949912154', | |
340 | 'address_1' => 'Add 1', | |
341 | 'address_2' => 'Add 2', | |
342 | 'city' => 'Watson', | |
343 | 'state' => 'NY', | |
86797006 | 344 | 'country' => 'UNITED STATES', |
6a488035 TO |
345 | 'birth_date' => 'December 12, 1998', |
346 | ), | |
6c6e6187 | 347 | array( |
92915c55 | 348 | 'first_name' => substr(sha1(rand()), 0, 7), |
6a488035 TO |
349 | 'middle_name' => substr(sha1(rand()), 0, 7), |
350 | 'last_name' => 'Summerson', | |
351 | 'email' => substr(sha1(rand()), 0, 7) . '@example.com', | |
352 | 'phone' => '6944412154', | |
353 | 'address_1' => 'Add 1', | |
354 | 'address_2' => 'Add 2', | |
355 | 'city' => 'Watson', | |
356 | 'state' => 'NY', | |
86797006 | 357 | 'country' => 'UNITED STATES', |
6a488035 TO |
358 | 'birth_date' => 'December 13, 1998', |
359 | ), | |
360 | ); | |
361 | ||
362 | return array($headers, $rows); | |
363 | } | |
364 | ||
8d7a9d07 | 365 | /** |
6a488035 TO |
366 | * Helper function to provide data for contact import for Individuals and dd-mon-yy OR dd/mm/yy dateformat. |
367 | */ | |
4cbe18b8 EM |
368 | /** |
369 | * @return array | |
370 | */ | |
00be9182 | 371 | public function _individualCSVData_dd_mon_yy() { |
6a488035 TO |
372 | $headers = array( |
373 | 'first_name' => 'First Name', | |
374 | 'middle_name' => 'Middle Name', | |
375 | 'last_name' => 'Last Name', | |
376 | 'email' => 'Email', | |
377 | 'phone' => 'Phone', | |
378 | 'address_1' => 'Additional Address 1', | |
379 | 'address_2' => 'Additional Address 2', | |
380 | 'city' => 'City', | |
381 | 'state' => 'State', | |
382 | 'country' => 'Country', | |
383 | 'birth_date' => 'Birth Date', | |
384 | ); | |
385 | ||
386 | $rows = array( | |
6c6e6187 | 387 | array( |
92915c55 | 388 | 'first_name' => substr(sha1(rand()), 0, 7), |
6a488035 TO |
389 | 'middle_name' => substr(sha1(rand()), 0, 7), |
390 | 'last_name' => 'Anderson', | |
391 | 'email' => substr(sha1(rand()), 0, 7) . '@example.com', | |
392 | 'phone' => '6949912154', | |
393 | 'address_1' => 'Add 1', | |
394 | 'address_2' => 'Add 2', | |
395 | 'city' => 'Watson', | |
396 | 'state' => 'NY', | |
86797006 | 397 | 'country' => 'UNITED STATES', |
6a488035 TO |
398 | 'birth_date' => '25/12/98', |
399 | ), | |
6c6e6187 | 400 | array( |
92915c55 | 401 | 'first_name' => substr(sha1(rand()), 0, 7), |
6a488035 TO |
402 | 'middle_name' => substr(sha1(rand()), 0, 7), |
403 | 'last_name' => 'Summerson', | |
404 | 'email' => substr(sha1(rand()), 0, 7) . '@example.com', | |
405 | 'phone' => '6944412154', | |
406 | 'address_1' => 'Add 1', | |
407 | 'address_2' => 'Add 2', | |
408 | 'city' => 'Watson', | |
409 | 'state' => 'NY', | |
86797006 | 410 | 'country' => 'UNITED STATES', |
6a488035 TO |
411 | 'birth_date' => '26/12/99', |
412 | ), | |
413 | ); | |
414 | ||
415 | return array($headers, $rows); | |
416 | } | |
417 | ||
8d7a9d07 | 418 | /** |
6a488035 TO |
419 | * Helper function to provide data for contact import for Individuals and dd/mm/yyyy dateformat. |
420 | */ | |
4cbe18b8 EM |
421 | /** |
422 | * @return array | |
423 | */ | |
00be9182 | 424 | public function _individualCSVData_dd_mm_yyyy() { |
6a488035 TO |
425 | $headers = array( |
426 | 'first_name' => 'First Name', | |
427 | 'middle_name' => 'Middle Name', | |
428 | 'last_name' => 'Last Name', | |
429 | 'email' => 'Email', | |
430 | 'phone' => 'Phone', | |
431 | 'address_1' => 'Additional Address 1', | |
432 | 'address_2' => 'Additional Address 2', | |
433 | 'city' => 'City', | |
434 | 'state' => 'State', | |
435 | 'country' => 'Country', | |
436 | 'birth_date' => 'Birth Date', | |
437 | ); | |
438 | ||
439 | $rows = array( | |
6c6e6187 | 440 | array( |
92915c55 | 441 | 'first_name' => substr(sha1(rand()), 0, 7), |
6a488035 TO |
442 | 'middle_name' => substr(sha1(rand()), 0, 7), |
443 | 'last_name' => 'Anderson', | |
444 | 'email' => substr(sha1(rand()), 0, 7) . '@example.com', | |
445 | 'phone' => '6949912154', | |
446 | 'address_1' => 'Add 1', | |
447 | 'address_2' => 'Add 2', | |
448 | 'city' => 'Watson', | |
449 | 'state' => 'NY', | |
86797006 | 450 | 'country' => 'UNITED STATES', |
6a488035 TO |
451 | 'birth_date' => '25/12/1998', |
452 | ), | |
6c6e6187 | 453 | array( |
92915c55 | 454 | 'first_name' => substr(sha1(rand()), 0, 7), |
6a488035 TO |
455 | 'middle_name' => substr(sha1(rand()), 0, 7), |
456 | 'last_name' => 'Summerson', | |
457 | 'email' => substr(sha1(rand()), 0, 7) . '@example.com', | |
458 | 'phone' => '6944412154', | |
459 | 'address_1' => 'Add 1', | |
460 | 'address_2' => 'Add 2', | |
461 | 'city' => 'Watson', | |
462 | 'state' => 'NY', | |
86797006 | 463 | 'country' => 'UNITED STATES', |
6a488035 TO |
464 | 'birth_date' => '24/11/1996', |
465 | ), | |
466 | ); | |
467 | ||
468 | return array($headers, $rows); | |
469 | } | |
96025800 | 470 | |
6a488035 | 471 | } |