3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.3 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
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 +--------------------------------------------------------------------+
28 require_once 'WebTest/Import/ImportCiviSeleniumTestCase.php';
29 class WebTest_Import_DateFormatTest
extends ImportCiviSeleniumTestCase
{
31 protected $captureScreenshotOnFailure = TRUE;
32 protected $screenshotPath = '/var/www/api.dev.civicrm.org/public/sc';
33 protected $screenshotUrl = 'http://api.dev.civicrm.org/sc/';
35 protected function setUp() {
40 * Test contact import for yyyy_mm_dd date format.
42 function testDateFormat_yyyy_mm_dd() {
43 // This is the path where our testing install resides.
44 // The rest of URL is defined in CiviSeleniumTestCase base class, in
46 $this->open($this->sboxPath
);
48 // Logging in. Remember to wait for page to load. In most cases,
49 // you can rely on 30000 as the value that allows your test to pass, however,
50 // sometimes your test might fail because of this. In such cases, it's better to pick one element
51 // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole
52 // page contents loaded and you can continue your test execution.
53 $this->webtestLogin();
55 // Get sample import data.
56 list($headers, $rows) = $this->_individualCSVData_yyyy_mm_dd();
58 // Import and check Individual contacts in Skip mode and yyyy-mm-dd OR yyyymmdd dateformat.
59 $other = array('dateFormat' => 'yyyy-mm-dd OR yyyymmdd');
61 $this->importContacts($headers, $rows, 'Individual', 'Skip', array(), $other);
65 * Test contact import for mm_dd_yy date format.
67 function testDateFormat_mm_dd_yy() {
68 // This is the path where our testing install resides.
69 // The rest of URL is defined in CiviSeleniumTestCase base class, in
71 $this->open($this->sboxPath
);
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 and you can continue your test execution.
78 $this->webtestLogin();
80 // Get sample import data.
81 list($headers, $rows) = $this->_individualCSVData_mm_dd_yy();
83 // Import and check Individual contacts in Skip mode and
84 // mm/dd/yy OR mm-dd-yy date format.
85 $other = array('dateFormat' => 'mm/dd/yy OR mm-dd-yy');
87 $this->importContacts($headers, $rows, 'Individual', 'Skip', array(), $other);
91 * Test contact import for mm_dd_yyyy date format.
93 function testDateFormat_mm_dd_yyyy() {
94 // This is the path where our testing install resides.
95 // The rest of URL is defined in CiviSeleniumTestCase base class, in
97 $this->open($this->sboxPath
);
99 // Logging in. Remember to wait for page to load. In most cases,
100 // you can rely on 30000 as the value that allows your test to pass, however,
101 // sometimes your test might fail because of this. In such cases, it's better to pick one element
102 // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole
103 // page contents loaded
104 $this->webtestLogin();
106 // Get sample import data.
107 list($headers, $rows) = $this->_individualCSVData_mm_dd_yyyy();
109 // Import and check Individual contacts in Skip mode and
110 // mm/dd/yyyy OR mm-dd-yyyy date format.
111 $other = array('dateFormat' => 'mm/dd/yyyy OR mm-dd-yyyy');
113 $this->importContacts($headers, $rows, 'Individual', 'Skip', array(), $other);
117 * Test contact import for Month_dd_yyyy date format.
119 function testDateFormat_Month_dd_yyyy() {
120 // This is the path where our testing install resides.
121 // The rest of URL is defined in CiviSeleniumTestCase base class, in
123 $this->open($this->sboxPath
);
125 // Logging in. Remember to wait for page to load. In most cases,
126 // you can rely on 30000 as the value that allows your test to pass, however,
127 // sometimes your test might fail because of this. In such cases, it's better to pick one element
128 // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole
129 // page contents loaded
130 $this->webtestLogin();
132 // Get sample import data.
133 list($headers, $rows) = $this->_individualCSVData_Month_dd_yyyy();
135 // Import and check Individual contacts in Skip mode and
136 // Month dd, yyyy date format.
137 $other = array('dateFormat' => 'Month dd, yyyy');
139 $this->importContacts($headers, $rows, 'Individual', 'Skip', array(), $other);
143 * Test contact import for dd_mon_yy date format.
145 function testDateFormat_dd_mon_yy() {
146 // This is the path where our testing install resides.
147 // The rest of URL is defined in CiviSeleniumTestCase base class, in
149 $this->open($this->sboxPath
);
151 // Logging in. Remember to wait for page to load. In most cases,
152 // you can rely on 30000 as the value that allows your test to pass, however,
153 // sometimes your test might fail because of this. In such cases, it's better to pick one element
154 // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole
155 // page contents loaded
156 $this->webtestLogin();
158 // Get sample import data.
159 list($headers, $rows) = $this->_individualCSVData_dd_mon_yy();
161 // Import and check Individual contacts in Skip mode and
162 // dd-mon-yy OR dd/mm/yy date format.
163 $other = array('dateFormat' => 'dd-mon-yy OR dd/mm/yy');
165 $this->importContacts($headers, $rows, 'Individual', 'Skip', array(), $other);
169 * Test contact import for dd_mm_yyyy date format.
171 function testDateFormat_dd_mm_yyyy() {
172 // This is the path where our testing install resides.
173 // The rest of URL is defined in CiviSeleniumTestCase base class, in
175 $this->open($this->sboxPath
);
177 // Logging in. Remember to wait for page to load. In most cases,
178 // you can rely on 30000 as the value that allows your test to pass, however,
179 // sometimes your test might fail because of this. In such cases, it's better to pick one element
180 // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole
181 // page contents loaded
182 $this->webtestLogin();
184 // Get sample import data.
185 list($headers, $rows) = $this->_individualCSVData_dd_mm_yyyy();
187 // Import and check Individual contacts in Skip mode and
188 // dd/mm/yyyy date format.
189 $other = array('dateFormat' => 'dd/mm/yyyy');
191 $this->importContacts($headers, $rows, 'Individual', 'Skip', array(), $other);
195 * Helper function to provide data for contact import for Individuals and yyyy-mm-dd OR yyyymmdd dateformat.
197 function _individualCSVData_yyyy_mm_dd() {
199 'first_name' => 'First Name',
200 'middle_name' => 'Middle Name',
201 'last_name' => 'Last Name',
204 'address_1' => 'Additional Address 1',
205 'address_2' => 'Additional Address 2',
208 'country' => 'Country',
209 'birth_date' => 'Birth Date',
213 array('first_name' => substr(sha1(rand()), 0, 7),
214 'middle_name' => substr(sha1(rand()), 0, 7),
215 'last_name' => 'Anderson',
216 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
217 'phone' => '6949912154',
218 'address_1' => 'Add 1',
219 'address_2' => 'Add 2',
222 'country' => 'United States',
223 'birth_date' => '1998-12-25',
225 array('first_name' => substr(sha1(rand()), 0, 7),
226 'middle_name' => substr(sha1(rand()), 0, 7),
227 'last_name' => 'Summerson',
228 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
229 'phone' => '6944412154',
230 'address_1' => 'Add 1',
231 'address_2' => 'Add 2',
234 'country' => 'United States',
235 'birth_date' => '1999-11-26',
239 return array($headers, $rows);
243 * Helper function to provide data for contact import for Individuals and mm/dd/yy OR mm-dd-yy dateformat.
245 function _individualCSVData_mm_dd_yy() {
247 'first_name' => 'First Name',
248 'middle_name' => 'Middle Name',
249 'last_name' => 'Last Name',
252 'address_1' => 'Additional Address 1',
253 'address_2' => 'Additional Address 2',
256 'country' => 'Country',
257 'birth_date' => 'Birth Date',
261 array('first_name' => substr(sha1(rand()), 0, 7),
262 'middle_name' => substr(sha1(rand()), 0, 7),
263 'last_name' => 'Anderson',
264 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
265 'phone' => '6949912154',
266 'address_1' => 'Add 1',
267 'address_2' => 'Add 2',
270 'country' => 'United States',
271 'birth_date' => '12/23/98',
273 array('first_name' => substr(sha1(rand()), 0, 7),
274 'middle_name' => substr(sha1(rand()), 0, 7),
275 'last_name' => 'Summerson',
276 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
277 'phone' => '6944412154',
278 'address_1' => 'Add 1',
279 'address_2' => 'Add 2',
282 'country' => 'United States',
283 'birth_date' => '11/24/88',
287 return array($headers, $rows);
291 * Helper function to provide data for contact import for Individuals and mm/dd/yyyy OR mm-dd-yyyy dateformat.
293 function _individualCSVData_mm_dd_yyyy() {
295 'first_name' => 'First Name',
296 'middle_name' => 'Middle Name',
297 'last_name' => 'Last Name',
300 'address_1' => 'Additional Address 1',
301 'address_2' => 'Additional Address 2',
304 'country' => 'Country',
305 'birth_date' => 'Birth Date',
309 array('first_name' => substr(sha1(rand()), 0, 7),
310 'middle_name' => substr(sha1(rand()), 0, 7),
311 'last_name' => 'Anderson',
312 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
313 'phone' => '6949912154',
314 'address_1' => 'Add 1',
315 'address_2' => 'Add 2',
318 'country' => 'United States',
319 'birth_date' => '11/12/1995',
321 array('first_name' => substr(sha1(rand()), 0, 7),
322 'middle_name' => substr(sha1(rand()), 0, 7),
323 'last_name' => 'Summerson',
324 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
325 'phone' => '6944412154',
326 'address_1' => 'Add 1',
327 'address_2' => 'Add 2',
330 'country' => 'United States',
331 'birth_date' => '12/12/1995',
335 return array($headers, $rows);
339 * Helper function to provide data for contact import for Individuals and Month dd, yyyy dateformat.
341 function _individualCSVData_Month_dd_yyyy() {
343 'first_name' => 'First Name',
344 'middle_name' => 'Middle Name',
345 'last_name' => 'Last Name',
348 'address_1' => 'Additional Address 1',
349 'address_2' => 'Additional Address 2',
352 'country' => 'Country',
353 'birth_date' => 'Birth Date',
357 array('first_name' => substr(sha1(rand()), 0, 7),
358 'middle_name' => substr(sha1(rand()), 0, 7),
359 'last_name' => 'Anderson',
360 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
361 'phone' => '6949912154',
362 'address_1' => 'Add 1',
363 'address_2' => 'Add 2',
366 'country' => 'United States',
367 'birth_date' => 'December 12, 1998',
369 array('first_name' => substr(sha1(rand()), 0, 7),
370 'middle_name' => substr(sha1(rand()), 0, 7),
371 'last_name' => 'Summerson',
372 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
373 'phone' => '6944412154',
374 'address_1' => 'Add 1',
375 'address_2' => 'Add 2',
378 'country' => 'United States',
379 'birth_date' => 'December 13, 1998',
383 return array($headers, $rows);
387 * Helper function to provide data for contact import for Individuals and dd-mon-yy OR dd/mm/yy dateformat.
389 function _individualCSVData_dd_mon_yy() {
391 'first_name' => 'First Name',
392 'middle_name' => 'Middle Name',
393 'last_name' => 'Last Name',
396 'address_1' => 'Additional Address 1',
397 'address_2' => 'Additional Address 2',
400 'country' => 'Country',
401 'birth_date' => 'Birth Date',
405 array('first_name' => substr(sha1(rand()), 0, 7),
406 'middle_name' => substr(sha1(rand()), 0, 7),
407 'last_name' => 'Anderson',
408 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
409 'phone' => '6949912154',
410 'address_1' => 'Add 1',
411 'address_2' => 'Add 2',
414 'country' => 'United States',
415 'birth_date' => '25/12/98',
417 array('first_name' => substr(sha1(rand()), 0, 7),
418 'middle_name' => substr(sha1(rand()), 0, 7),
419 'last_name' => 'Summerson',
420 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
421 'phone' => '6944412154',
422 'address_1' => 'Add 1',
423 'address_2' => 'Add 2',
426 'country' => 'United States',
427 'birth_date' => '26/12/99',
431 return array($headers, $rows);
435 * Helper function to provide data for contact import for Individuals and dd/mm/yyyy dateformat.
437 function _individualCSVData_dd_mm_yyyy() {
439 'first_name' => 'First Name',
440 'middle_name' => 'Middle Name',
441 'last_name' => 'Last Name',
444 'address_1' => 'Additional Address 1',
445 'address_2' => 'Additional Address 2',
448 'country' => 'Country',
449 'birth_date' => 'Birth Date',
453 array('first_name' => substr(sha1(rand()), 0, 7),
454 'middle_name' => substr(sha1(rand()), 0, 7),
455 'last_name' => 'Anderson',
456 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
457 'phone' => '6949912154',
458 'address_1' => 'Add 1',
459 'address_2' => 'Add 2',
462 'country' => 'United States',
463 'birth_date' => '25/12/1998',
465 array('first_name' => substr(sha1(rand()), 0, 7),
466 'middle_name' => substr(sha1(rand()), 0, 7),
467 'last_name' => 'Summerson',
468 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
469 'phone' => '6944412154',
470 'address_1' => 'Add 1',
471 'address_2' => 'Add 2',
474 'country' => 'United States',
475 'birth_date' => '24/11/1996',
479 return array($headers, $rows);