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 +--------------------------------------------------------------------+
27 require_once 'WebTest/Import/ImportCiviSeleniumTestCase.php';
28 class WebTest_Import_DateFormatTest
extends ImportCiviSeleniumTestCase
{
30 protected $captureScreenshotOnFailure = TRUE;
31 protected $screenshotPath = '/var/www/api.dev.civicrm.org/public/sc';
32 protected $screenshotUrl = 'http://api.dev.civicrm.org/sc/';
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.
156 function _individualCSVData_yyyy_mm_dd() {
158 'first_name' => 'First Name',
159 'middle_name' => 'Middle Name',
160 'last_name' => 'Last Name',
163 'address_1' => 'Additional Address 1',
164 'address_2' => 'Additional Address 2',
167 'country' => 'Country',
168 'birth_date' => 'Birth Date',
172 array('first_name' => substr(sha1(rand()), 0, 7),
173 'middle_name' => substr(sha1(rand()), 0, 7),
174 'last_name' => 'Anderson',
175 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
176 'phone' => '6949912154',
177 'address_1' => 'Add 1',
178 'address_2' => 'Add 2',
181 'country' => 'United States',
182 'birth_date' => '1998-12-25',
184 array('first_name' => substr(sha1(rand()), 0, 7),
185 'middle_name' => substr(sha1(rand()), 0, 7),
186 'last_name' => 'Summerson',
187 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
188 'phone' => '6944412154',
189 'address_1' => 'Add 1',
190 'address_2' => 'Add 2',
193 'country' => 'United States',
194 'birth_date' => '1999-11-26',
198 return array($headers, $rows);
202 * Helper function to provide data for contact import for Individuals and mm/dd/yy OR mm-dd-yy dateformat.
204 function _individualCSVData_mm_dd_yy() {
206 'first_name' => 'First Name',
207 'middle_name' => 'Middle Name',
208 'last_name' => 'Last Name',
211 'address_1' => 'Additional Address 1',
212 'address_2' => 'Additional Address 2',
215 'country' => 'Country',
216 'birth_date' => 'Birth Date',
220 array('first_name' => substr(sha1(rand()), 0, 7),
221 'middle_name' => substr(sha1(rand()), 0, 7),
222 'last_name' => 'Anderson',
223 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
224 'phone' => '6949912154',
225 'address_1' => 'Add 1',
226 'address_2' => 'Add 2',
229 'country' => 'United States',
230 'birth_date' => '12/23/98',
232 array('first_name' => substr(sha1(rand()), 0, 7),
233 'middle_name' => substr(sha1(rand()), 0, 7),
234 'last_name' => 'Summerson',
235 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
236 'phone' => '6944412154',
237 'address_1' => 'Add 1',
238 'address_2' => 'Add 2',
241 'country' => 'United States',
242 'birth_date' => '11/24/88',
246 return array($headers, $rows);
250 * Helper function to provide data for contact import for Individuals and mm/dd/yyyy OR mm-dd-yyyy dateformat.
252 function _individualCSVData_mm_dd_yyyy() {
254 'first_name' => 'First Name',
255 'middle_name' => 'Middle Name',
256 'last_name' => 'Last Name',
259 'address_1' => 'Additional Address 1',
260 'address_2' => 'Additional Address 2',
263 'country' => 'Country',
264 'birth_date' => 'Birth Date',
268 array('first_name' => substr(sha1(rand()), 0, 7),
269 'middle_name' => substr(sha1(rand()), 0, 7),
270 'last_name' => 'Anderson',
271 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
272 'phone' => '6949912154',
273 'address_1' => 'Add 1',
274 'address_2' => 'Add 2',
277 'country' => 'United States',
278 'birth_date' => '11/12/1995',
280 array('first_name' => substr(sha1(rand()), 0, 7),
281 'middle_name' => substr(sha1(rand()), 0, 7),
282 'last_name' => 'Summerson',
283 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
284 'phone' => '6944412154',
285 'address_1' => 'Add 1',
286 'address_2' => 'Add 2',
289 'country' => 'United States',
290 'birth_date' => '12/12/1995',
294 return array($headers, $rows);
298 * Helper function to provide data for contact import for Individuals and Month dd, yyyy dateformat.
300 function _individualCSVData_Month_dd_yyyy() {
302 'first_name' => 'First Name',
303 'middle_name' => 'Middle Name',
304 'last_name' => 'Last Name',
307 'address_1' => 'Additional Address 1',
308 'address_2' => 'Additional Address 2',
311 'country' => 'Country',
312 'birth_date' => 'Birth Date',
316 array('first_name' => substr(sha1(rand()), 0, 7),
317 'middle_name' => substr(sha1(rand()), 0, 7),
318 'last_name' => 'Anderson',
319 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
320 'phone' => '6949912154',
321 'address_1' => 'Add 1',
322 'address_2' => 'Add 2',
325 'country' => 'United States',
326 'birth_date' => 'December 12, 1998',
328 array('first_name' => substr(sha1(rand()), 0, 7),
329 'middle_name' => substr(sha1(rand()), 0, 7),
330 'last_name' => 'Summerson',
331 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
332 'phone' => '6944412154',
333 'address_1' => 'Add 1',
334 'address_2' => 'Add 2',
337 'country' => 'United States',
338 'birth_date' => 'December 13, 1998',
342 return array($headers, $rows);
346 * Helper function to provide data for contact import for Individuals and dd-mon-yy OR dd/mm/yy dateformat.
348 function _individualCSVData_dd_mon_yy() {
350 'first_name' => 'First Name',
351 'middle_name' => 'Middle Name',
352 'last_name' => 'Last Name',
355 'address_1' => 'Additional Address 1',
356 'address_2' => 'Additional Address 2',
359 'country' => 'Country',
360 'birth_date' => 'Birth Date',
364 array('first_name' => substr(sha1(rand()), 0, 7),
365 'middle_name' => substr(sha1(rand()), 0, 7),
366 'last_name' => 'Anderson',
367 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
368 'phone' => '6949912154',
369 'address_1' => 'Add 1',
370 'address_2' => 'Add 2',
373 'country' => 'United States',
374 'birth_date' => '25/12/98',
376 array('first_name' => substr(sha1(rand()), 0, 7),
377 'middle_name' => substr(sha1(rand()), 0, 7),
378 'last_name' => 'Summerson',
379 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
380 'phone' => '6944412154',
381 'address_1' => 'Add 1',
382 'address_2' => 'Add 2',
385 'country' => 'United States',
386 'birth_date' => '26/12/99',
390 return array($headers, $rows);
394 * Helper function to provide data for contact import for Individuals and dd/mm/yyyy dateformat.
396 function _individualCSVData_dd_mm_yyyy() {
398 'first_name' => 'First Name',
399 'middle_name' => 'Middle Name',
400 'last_name' => 'Last Name',
403 'address_1' => 'Additional Address 1',
404 'address_2' => 'Additional Address 2',
407 'country' => 'Country',
408 'birth_date' => 'Birth Date',
412 array('first_name' => substr(sha1(rand()), 0, 7),
413 'middle_name' => substr(sha1(rand()), 0, 7),
414 'last_name' => 'Anderson',
415 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
416 'phone' => '6949912154',
417 'address_1' => 'Add 1',
418 'address_2' => 'Add 2',
421 'country' => 'United States',
422 'birth_date' => '25/12/1998',
424 array('first_name' => substr(sha1(rand()), 0, 7),
425 'middle_name' => substr(sha1(rand()), 0, 7),
426 'last_name' => 'Summerson',
427 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
428 'phone' => '6944412154',
429 'address_1' => 'Add 1',
430 'address_2' => 'Add 2',
433 'country' => 'United States',
434 'birth_date' => '24/11/1996',
438 return array($headers, $rows);