3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
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 public 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 public 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 public 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 public 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 public 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 public 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 public 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',
176 'first_name' => substr(sha1(rand()), 0, 7),
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',
185 'country' => 'UNITED STATES',
186 'birth_date' => '1998-12-25',
189 'first_name' => substr(sha1(rand()), 0, 7),
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',
198 'country' => 'UNITED STATES',
199 'birth_date' => '1999-11-26',
203 return array($headers, $rows);
207 * Helper function to provide data for contact import for Individuals and mm/dd/yy OR mm-dd-yy dateformat.
212 public function _individualCSVData_mm_dd_yy() {
214 'first_name' => 'First Name',
215 'middle_name' => 'Middle Name',
216 'last_name' => 'Last Name',
219 'address_1' => 'Additional Address 1',
220 'address_2' => 'Additional Address 2',
223 'country' => 'Country',
224 'birth_date' => 'Birth Date',
229 'first_name' => substr(sha1(rand()), 0, 7),
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',
238 'country' => 'UNITED STATES',
239 'birth_date' => '12/23/98',
242 'first_name' => substr(sha1(rand()), 0, 7),
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',
251 'country' => 'UNITED STATES',
252 'birth_date' => '11/24/88',
256 return array($headers, $rows);
260 * Helper function to provide data for contact import for Individuals and mm/dd/yyyy OR mm-dd-yyyy dateformat.
265 public function _individualCSVData_mm_dd_yyyy() {
267 'first_name' => 'First Name',
268 'middle_name' => 'Middle Name',
269 'last_name' => 'Last Name',
272 'address_1' => 'Additional Address 1',
273 'address_2' => 'Additional Address 2',
276 'country' => 'Country',
277 'birth_date' => 'Birth Date',
282 'first_name' => substr(sha1(rand()), 0, 7),
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',
291 'country' => 'UNITED STATES',
292 'birth_date' => '11/12/1995',
295 'first_name' => substr(sha1(rand()), 0, 7),
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',
304 'country' => 'UNITED STATES',
305 'birth_date' => '12/12/1995',
309 return array($headers, $rows);
313 * Helper function to provide data for contact import for Individuals and Month dd, yyyy dateformat.
318 public function _individualCSVData_Month_dd_yyyy() {
320 'first_name' => 'First Name',
321 'middle_name' => 'Middle Name',
322 'last_name' => 'Last Name',
325 'address_1' => 'Additional Address 1',
326 'address_2' => 'Additional Address 2',
329 'country' => 'Country',
330 'birth_date' => 'Birth Date',
335 'first_name' => substr(sha1(rand()), 0, 7),
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',
344 'country' => 'UNITED STATES',
345 'birth_date' => 'December 12, 1998',
348 'first_name' => substr(sha1(rand()), 0, 7),
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',
357 'country' => 'UNITED STATES',
358 'birth_date' => 'December 13, 1998',
362 return array($headers, $rows);
366 * Helper function to provide data for contact import for Individuals and dd-mon-yy OR dd/mm/yy dateformat.
371 public function _individualCSVData_dd_mon_yy() {
373 'first_name' => 'First Name',
374 'middle_name' => 'Middle Name',
375 'last_name' => 'Last Name',
378 'address_1' => 'Additional Address 1',
379 'address_2' => 'Additional Address 2',
382 'country' => 'Country',
383 'birth_date' => 'Birth Date',
388 'first_name' => substr(sha1(rand()), 0, 7),
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',
397 'country' => 'UNITED STATES',
398 'birth_date' => '25/12/98',
401 'first_name' => substr(sha1(rand()), 0, 7),
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',
410 'country' => 'UNITED STATES',
411 'birth_date' => '26/12/99',
415 return array($headers, $rows);
419 * Helper function to provide data for contact import for Individuals and dd/mm/yyyy dateformat.
424 public function _individualCSVData_dd_mm_yyyy() {
426 'first_name' => 'First Name',
427 'middle_name' => 'Middle Name',
428 'last_name' => 'Last Name',
431 'address_1' => 'Additional Address 1',
432 'address_2' => 'Additional Address 2',
435 'country' => 'Country',
436 'birth_date' => 'Birth Date',
441 'first_name' => substr(sha1(rand()), 0, 7),
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',
450 'country' => 'UNITED STATES',
451 'birth_date' => '25/12/1998',
454 'first_name' => substr(sha1(rand()), 0, 7),
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',
463 'country' => 'UNITED STATES',
464 'birth_date' => '24/11/1996',
468 return array($headers, $rows);