3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
27 require_once 'WebTest/Import/ImportCiviSeleniumTestCase.php';
30 * Class WebTest_Import_DateFormatTest
32 class WebTest_Import_DateFormatTest
extends ImportCiviSeleniumTestCase
{
34 protected function setUp() {
39 * Test contact import for yyyy_mm_dd date format.
41 function testDateFormat_yyyy_mm_dd() {
42 $this->webtestLogin();
44 // Get sample import data.
45 list($headers, $rows) = $this->_individualCSVData_yyyy_mm_dd();
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');
50 $this->importContacts($headers, $rows, 'Individual', 'Skip', array(), $other);
54 * Test contact import for mm_dd_yy date format.
56 function testDateFormat_mm_dd_yy() {
57 $this->webtestLogin();
59 // Get sample import data.
60 list($headers, $rows) = $this->_individualCSVData_mm_dd_yy();
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');
66 $this->importContacts($headers, $rows, 'Individual', 'Skip', array(), $other);
70 * Test contact import for mm_dd_yyyy date format.
72 function testDateFormat_mm_dd_yyyy() {
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();
80 // Get sample import data.
81 list($headers, $rows) = $this->_individualCSVData_mm_dd_yyyy();
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');
87 $this->importContacts($headers, $rows, 'Individual', 'Skip', array(), $other);
91 * Test contact import for Month_dd_yyyy date format.
93 function testDateFormat_Month_dd_yyyy() {
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();
101 // Get sample import data.
102 list($headers, $rows) = $this->_individualCSVData_Month_dd_yyyy();
104 // Import and check Individual contacts in Skip mode and
105 // Month dd, yyyy date format.
106 $other = array('dateFormat' => 'Month dd, yyyy');
108 $this->importContacts($headers, $rows, 'Individual', 'Skip', array(), $other);
112 * Test contact import for dd_mon_yy date format.
114 function testDateFormat_dd_mon_yy() {
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();
122 // Get sample import data.
123 list($headers, $rows) = $this->_individualCSVData_dd_mon_yy();
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');
129 $this->importContacts($headers, $rows, 'Individual', 'Skip', array(), $other);
133 * Test contact import for dd_mm_yyyy date format.
135 function testDateFormat_dd_mm_yyyy() {
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();
143 // Get sample import data.
144 list($headers, $rows) = $this->_individualCSVData_dd_mm_yyyy();
146 // Import and check Individual contacts in Skip mode and
147 // dd/mm/yyyy date format.
148 $other = array('dateFormat' => 'dd/mm/yyyy');
150 $this->importContacts($headers, $rows, 'Individual', 'Skip', array(), $other);
154 * Helper function to provide data for contact import for Individuals and yyyy-mm-dd OR yyyymmdd dateformat.
159 function _individualCSVData_yyyy_mm_dd() {
161 'first_name' => 'First Name',
162 'middle_name' => 'Middle Name',
163 'last_name' => 'Last Name',
166 'address_1' => 'Additional Address 1',
167 'address_2' => 'Additional Address 2',
170 'country' => 'Country',
171 'birth_date' => 'Birth Date',
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',
184 'country' => 'United States',
185 'birth_date' => '1998-12-25',
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',
196 'country' => 'United States',
197 'birth_date' => '1999-11-26',
201 return array($headers, $rows);
205 * Helper function to provide data for contact import for Individuals and mm/dd/yy OR mm-dd-yy dateformat.
210 function _individualCSVData_mm_dd_yy() {
212 'first_name' => 'First Name',
213 'middle_name' => 'Middle Name',
214 'last_name' => 'Last Name',
217 'address_1' => 'Additional Address 1',
218 'address_2' => 'Additional Address 2',
221 'country' => 'Country',
222 'birth_date' => 'Birth Date',
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',
235 'country' => 'United States',
236 'birth_date' => '12/23/98',
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',
247 'country' => 'United States',
248 'birth_date' => '11/24/88',
252 return array($headers, $rows);
256 * Helper function to provide data for contact import for Individuals and mm/dd/yyyy OR mm-dd-yyyy dateformat.
261 function _individualCSVData_mm_dd_yyyy() {
263 'first_name' => 'First Name',
264 'middle_name' => 'Middle Name',
265 'last_name' => 'Last Name',
268 'address_1' => 'Additional Address 1',
269 'address_2' => 'Additional Address 2',
272 'country' => 'Country',
273 'birth_date' => 'Birth Date',
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',
286 'country' => 'United States',
287 'birth_date' => '11/12/1995',
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',
298 'country' => 'United States',
299 'birth_date' => '12/12/1995',
303 return array($headers, $rows);
307 * Helper function to provide data for contact import for Individuals and Month dd, yyyy dateformat.
312 function _individualCSVData_Month_dd_yyyy() {
314 'first_name' => 'First Name',
315 'middle_name' => 'Middle Name',
316 'last_name' => 'Last Name',
319 'address_1' => 'Additional Address 1',
320 'address_2' => 'Additional Address 2',
323 'country' => 'Country',
324 'birth_date' => 'Birth Date',
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',
337 'country' => 'United States',
338 'birth_date' => 'December 12, 1998',
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',
349 'country' => 'United States',
350 'birth_date' => 'December 13, 1998',
354 return array($headers, $rows);
358 * Helper function to provide data for contact import for Individuals and dd-mon-yy OR dd/mm/yy dateformat.
363 function _individualCSVData_dd_mon_yy() {
365 'first_name' => 'First Name',
366 'middle_name' => 'Middle Name',
367 'last_name' => 'Last Name',
370 'address_1' => 'Additional Address 1',
371 'address_2' => 'Additional Address 2',
374 'country' => 'Country',
375 'birth_date' => 'Birth Date',
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',
388 'country' => 'United States',
389 'birth_date' => '25/12/98',
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',
400 'country' => 'United States',
401 'birth_date' => '26/12/99',
405 return array($headers, $rows);
409 * Helper function to provide data for contact import for Individuals and dd/mm/yyyy dateformat.
414 function _individualCSVData_dd_mm_yyyy() {
416 'first_name' => 'First Name',
417 'middle_name' => 'Middle Name',
418 'last_name' => 'Last Name',
421 'address_1' => 'Additional Address 1',
422 'address_2' => 'Additional Address 2',
425 'country' => 'Country',
426 'birth_date' => 'Birth Date',
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',
439 'country' => 'United States',
440 'birth_date' => '25/12/1998',
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',
451 'country' => 'United States',
452 'birth_date' => '24/11/1996',
456 return array($headers, $rows);