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