Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
39de6fd5 | 4 | | CiviCRM version 4.6 | |
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 | 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 | ||
38 | /* | |
39 | * Test contact import for yyyy_mm_dd date format. | |
40 | */ | |
41 | 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 | ||
53 | /* | |
54 | * Test contact import for mm_dd_yy date format. | |
55 | */ | |
56 | 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 | ||
69 | /* | |
70 | * Test contact import for mm_dd_yyyy date format. | |
71 | */ | |
72 | 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 | ||
90 | /* | |
91 | * Test contact import for Month_dd_yyyy date format. | |
92 | */ | |
93 | 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 | ||
111 | /* | |
112 | * Test contact import for dd_mon_yy date format. | |
113 | */ | |
114 | 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 | ||
132 | /* | |
133 | * Test contact import for dd_mm_yyyy date format. | |
134 | */ | |
135 | 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 | ||
153 | /* | |
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 | */ | |
6a488035 TO |
159 | function _individualCSVData_yyyy_mm_dd() { |
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( | |
175 | array('first_name' => substr(sha1(rand()), 0, 7), | |
176 | 'middle_name' => substr(sha1(rand()), 0, 7), | |
177 | 'last_name' => 'Anderson', | |
178 | 'email' => substr(sha1(rand()), 0, 7) . '@example.com', | |
179 | 'phone' => '6949912154', | |
180 | 'address_1' => 'Add 1', | |
181 | 'address_2' => 'Add 2', | |
182 | 'city' => 'Watson', | |
183 | 'state' => 'NY', | |
184 | 'country' => 'United States', | |
185 | 'birth_date' => '1998-12-25', | |
186 | ), | |
187 | array('first_name' => substr(sha1(rand()), 0, 7), | |
188 | 'middle_name' => substr(sha1(rand()), 0, 7), | |
189 | 'last_name' => 'Summerson', | |
190 | 'email' => substr(sha1(rand()), 0, 7) . '@example.com', | |
191 | 'phone' => '6944412154', | |
192 | 'address_1' => 'Add 1', | |
193 | 'address_2' => 'Add 2', | |
194 | 'city' => 'Watson', | |
195 | 'state' => 'NY', | |
196 | 'country' => 'United States', | |
197 | 'birth_date' => '1999-11-26', | |
198 | ), | |
199 | ); | |
200 | ||
201 | return array($headers, $rows); | |
202 | } | |
203 | ||
204 | /* | |
205 | * Helper function to provide data for contact import for Individuals and mm/dd/yy OR mm-dd-yy dateformat. | |
206 | */ | |
4cbe18b8 EM |
207 | /** |
208 | * @return array | |
209 | */ | |
6a488035 TO |
210 | function _individualCSVData_mm_dd_yy() { |
211 | $headers = array( | |
212 | 'first_name' => 'First Name', | |
213 | 'middle_name' => 'Middle Name', | |
214 | 'last_name' => 'Last Name', | |
215 | 'email' => 'Email', | |
216 | 'phone' => 'Phone', | |
217 | 'address_1' => 'Additional Address 1', | |
218 | 'address_2' => 'Additional Address 2', | |
219 | 'city' => 'City', | |
220 | 'state' => 'State', | |
221 | 'country' => 'Country', | |
222 | 'birth_date' => 'Birth Date', | |
223 | ); | |
224 | ||
225 | $rows = array( | |
226 | array('first_name' => substr(sha1(rand()), 0, 7), | |
227 | 'middle_name' => substr(sha1(rand()), 0, 7), | |
228 | 'last_name' => 'Anderson', | |
229 | 'email' => substr(sha1(rand()), 0, 7) . '@example.com', | |
230 | 'phone' => '6949912154', | |
231 | 'address_1' => 'Add 1', | |
232 | 'address_2' => 'Add 2', | |
233 | 'city' => 'Watson', | |
234 | 'state' => 'NY', | |
235 | 'country' => 'United States', | |
236 | 'birth_date' => '12/23/98', | |
237 | ), | |
238 | array('first_name' => substr(sha1(rand()), 0, 7), | |
239 | 'middle_name' => substr(sha1(rand()), 0, 7), | |
240 | 'last_name' => 'Summerson', | |
241 | 'email' => substr(sha1(rand()), 0, 7) . '@example.com', | |
242 | 'phone' => '6944412154', | |
243 | 'address_1' => 'Add 1', | |
244 | 'address_2' => 'Add 2', | |
245 | 'city' => 'Watson', | |
246 | 'state' => 'NY', | |
247 | 'country' => 'United States', | |
248 | 'birth_date' => '11/24/88', | |
249 | ), | |
250 | ); | |
251 | ||
252 | return array($headers, $rows); | |
253 | } | |
254 | ||
255 | /* | |
256 | * Helper function to provide data for contact import for Individuals and mm/dd/yyyy OR mm-dd-yyyy dateformat. | |
257 | */ | |
4cbe18b8 EM |
258 | /** |
259 | * @return array | |
260 | */ | |
6a488035 TO |
261 | function _individualCSVData_mm_dd_yyyy() { |
262 | $headers = array( | |
263 | 'first_name' => 'First Name', | |
264 | 'middle_name' => 'Middle Name', | |
265 | 'last_name' => 'Last Name', | |
266 | 'email' => 'Email', | |
267 | 'phone' => 'Phone', | |
268 | 'address_1' => 'Additional Address 1', | |
269 | 'address_2' => 'Additional Address 2', | |
270 | 'city' => 'City', | |
271 | 'state' => 'State', | |
272 | 'country' => 'Country', | |
273 | 'birth_date' => 'Birth Date', | |
274 | ); | |
275 | ||
276 | $rows = array( | |
277 | array('first_name' => substr(sha1(rand()), 0, 7), | |
278 | 'middle_name' => substr(sha1(rand()), 0, 7), | |
279 | 'last_name' => 'Anderson', | |
280 | 'email' => substr(sha1(rand()), 0, 7) . '@example.com', | |
281 | 'phone' => '6949912154', | |
282 | 'address_1' => 'Add 1', | |
283 | 'address_2' => 'Add 2', | |
284 | 'city' => 'Watson', | |
285 | 'state' => 'NY', | |
286 | 'country' => 'United States', | |
287 | 'birth_date' => '11/12/1995', | |
288 | ), | |
289 | array('first_name' => substr(sha1(rand()), 0, 7), | |
290 | 'middle_name' => substr(sha1(rand()), 0, 7), | |
291 | 'last_name' => 'Summerson', | |
292 | 'email' => substr(sha1(rand()), 0, 7) . '@example.com', | |
293 | 'phone' => '6944412154', | |
294 | 'address_1' => 'Add 1', | |
295 | 'address_2' => 'Add 2', | |
296 | 'city' => 'Watson', | |
297 | 'state' => 'NY', | |
298 | 'country' => 'United States', | |
299 | 'birth_date' => '12/12/1995', | |
300 | ), | |
301 | ); | |
302 | ||
303 | return array($headers, $rows); | |
304 | } | |
305 | ||
306 | /* | |
307 | * Helper function to provide data for contact import for Individuals and Month dd, yyyy dateformat. | |
308 | */ | |
4cbe18b8 EM |
309 | /** |
310 | * @return array | |
311 | */ | |
6a488035 TO |
312 | function _individualCSVData_Month_dd_yyyy() { |
313 | $headers = array( | |
314 | 'first_name' => 'First Name', | |
315 | 'middle_name' => 'Middle Name', | |
316 | 'last_name' => 'Last Name', | |
317 | 'email' => 'Email', | |
318 | 'phone' => 'Phone', | |
319 | 'address_1' => 'Additional Address 1', | |
320 | 'address_2' => 'Additional Address 2', | |
321 | 'city' => 'City', | |
322 | 'state' => 'State', | |
323 | 'country' => 'Country', | |
324 | 'birth_date' => 'Birth Date', | |
325 | ); | |
326 | ||
327 | $rows = array( | |
328 | array('first_name' => substr(sha1(rand()), 0, 7), | |
329 | 'middle_name' => substr(sha1(rand()), 0, 7), | |
330 | 'last_name' => 'Anderson', | |
331 | 'email' => substr(sha1(rand()), 0, 7) . '@example.com', | |
332 | 'phone' => '6949912154', | |
333 | 'address_1' => 'Add 1', | |
334 | 'address_2' => 'Add 2', | |
335 | 'city' => 'Watson', | |
336 | 'state' => 'NY', | |
337 | 'country' => 'United States', | |
338 | 'birth_date' => 'December 12, 1998', | |
339 | ), | |
340 | array('first_name' => substr(sha1(rand()), 0, 7), | |
341 | 'middle_name' => substr(sha1(rand()), 0, 7), | |
342 | 'last_name' => 'Summerson', | |
343 | 'email' => substr(sha1(rand()), 0, 7) . '@example.com', | |
344 | 'phone' => '6944412154', | |
345 | 'address_1' => 'Add 1', | |
346 | 'address_2' => 'Add 2', | |
347 | 'city' => 'Watson', | |
348 | 'state' => 'NY', | |
349 | 'country' => 'United States', | |
350 | 'birth_date' => 'December 13, 1998', | |
351 | ), | |
352 | ); | |
353 | ||
354 | return array($headers, $rows); | |
355 | } | |
356 | ||
357 | /* | |
358 | * Helper function to provide data for contact import for Individuals and dd-mon-yy OR dd/mm/yy dateformat. | |
359 | */ | |
4cbe18b8 EM |
360 | /** |
361 | * @return array | |
362 | */ | |
6a488035 TO |
363 | function _individualCSVData_dd_mon_yy() { |
364 | $headers = array( | |
365 | 'first_name' => 'First Name', | |
366 | 'middle_name' => 'Middle Name', | |
367 | 'last_name' => 'Last Name', | |
368 | 'email' => 'Email', | |
369 | 'phone' => 'Phone', | |
370 | 'address_1' => 'Additional Address 1', | |
371 | 'address_2' => 'Additional Address 2', | |
372 | 'city' => 'City', | |
373 | 'state' => 'State', | |
374 | 'country' => 'Country', | |
375 | 'birth_date' => 'Birth Date', | |
376 | ); | |
377 | ||
378 | $rows = array( | |
379 | array('first_name' => substr(sha1(rand()), 0, 7), | |
380 | 'middle_name' => substr(sha1(rand()), 0, 7), | |
381 | 'last_name' => 'Anderson', | |
382 | 'email' => substr(sha1(rand()), 0, 7) . '@example.com', | |
383 | 'phone' => '6949912154', | |
384 | 'address_1' => 'Add 1', | |
385 | 'address_2' => 'Add 2', | |
386 | 'city' => 'Watson', | |
387 | 'state' => 'NY', | |
388 | 'country' => 'United States', | |
389 | 'birth_date' => '25/12/98', | |
390 | ), | |
391 | array('first_name' => substr(sha1(rand()), 0, 7), | |
392 | 'middle_name' => substr(sha1(rand()), 0, 7), | |
393 | 'last_name' => 'Summerson', | |
394 | 'email' => substr(sha1(rand()), 0, 7) . '@example.com', | |
395 | 'phone' => '6944412154', | |
396 | 'address_1' => 'Add 1', | |
397 | 'address_2' => 'Add 2', | |
398 | 'city' => 'Watson', | |
399 | 'state' => 'NY', | |
400 | 'country' => 'United States', | |
401 | 'birth_date' => '26/12/99', | |
402 | ), | |
403 | ); | |
404 | ||
405 | return array($headers, $rows); | |
406 | } | |
407 | ||
408 | /* | |
409 | * Helper function to provide data for contact import for Individuals and dd/mm/yyyy dateformat. | |
410 | */ | |
4cbe18b8 EM |
411 | /** |
412 | * @return array | |
413 | */ | |
6a488035 TO |
414 | function _individualCSVData_dd_mm_yyyy() { |
415 | $headers = array( | |
416 | 'first_name' => 'First Name', | |
417 | 'middle_name' => 'Middle Name', | |
418 | 'last_name' => 'Last Name', | |
419 | 'email' => 'Email', | |
420 | 'phone' => 'Phone', | |
421 | 'address_1' => 'Additional Address 1', | |
422 | 'address_2' => 'Additional Address 2', | |
423 | 'city' => 'City', | |
424 | 'state' => 'State', | |
425 | 'country' => 'Country', | |
426 | 'birth_date' => 'Birth Date', | |
427 | ); | |
428 | ||
429 | $rows = array( | |
430 | array('first_name' => substr(sha1(rand()), 0, 7), | |
431 | 'middle_name' => substr(sha1(rand()), 0, 7), | |
432 | 'last_name' => 'Anderson', | |
433 | 'email' => substr(sha1(rand()), 0, 7) . '@example.com', | |
434 | 'phone' => '6949912154', | |
435 | 'address_1' => 'Add 1', | |
436 | 'address_2' => 'Add 2', | |
437 | 'city' => 'Watson', | |
438 | 'state' => 'NY', | |
439 | 'country' => 'United States', | |
440 | 'birth_date' => '25/12/1998', | |
441 | ), | |
442 | array('first_name' => substr(sha1(rand()), 0, 7), | |
443 | 'middle_name' => substr(sha1(rand()), 0, 7), | |
444 | 'last_name' => 'Summerson', | |
445 | 'email' => substr(sha1(rand()), 0, 7) . '@example.com', | |
446 | 'phone' => '6944412154', | |
447 | 'address_1' => 'Add 1', | |
448 | 'address_2' => 'Add 2', | |
449 | 'city' => 'Watson', | |
450 | 'state' => 'NY', | |
451 | 'country' => 'United States', | |
452 | 'birth_date' => '24/11/1996', | |
453 | ), | |
454 | ); | |
455 | ||
456 | return array($headers, $rows); | |
457 | } | |
458 | } | |
459 |