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->webtestLogin();
45 // Get sample import data.
46 list($headers, $rows) = $this->_individualCSVData_yyyy_mm_dd();
48 // Import and check Individual contacts in Skip mode and yyyy-mm-dd OR yyyymmdd dateformat.
49 $other = array('dateFormat' => 'yyyy-mm-dd OR yyyymmdd');
51 $this->importContacts($headers, $rows, 'Individual', 'Skip', array(), $other);
55 * Test contact import for mm_dd_yy date format.
57 function testDateFormat_mm_dd_yy() {
58 $this->webtestLogin();
60 // Get sample import data.
61 list($headers, $rows) = $this->_individualCSVData_mm_dd_yy();
63 // Import and check Individual contacts in Skip mode and
64 // mm/dd/yy OR mm-dd-yy date format.
65 $other = array('dateFormat' => 'mm/dd/yy OR mm-dd-yy');
67 $this->importContacts($headers, $rows, 'Individual', 'Skip', array(), $other);
71 * Test contact import for mm_dd_yyyy date format.
73 function testDateFormat_mm_dd_yyyy() {
74 // Logging in. Remember to wait for page to load. In most cases,
75 // you can rely on 30000 as the value that allows your test to pass, however,
76 // sometimes your test might fail because of this. In such cases, it's better to pick one element
77 // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole
78 // page contents loaded
79 $this->webtestLogin();
81 // Get sample import data.
82 list($headers, $rows) = $this->_individualCSVData_mm_dd_yyyy();
84 // Import and check Individual contacts in Skip mode and
85 // mm/dd/yyyy OR mm-dd-yyyy date format.
86 $other = array('dateFormat' => 'mm/dd/yyyy OR mm-dd-yyyy');
88 $this->importContacts($headers, $rows, 'Individual', 'Skip', array(), $other);
92 * Test contact import for Month_dd_yyyy date format.
94 function testDateFormat_Month_dd_yyyy() {
95 // Logging in. Remember to wait for page to load. In most cases,
96 // you can rely on 30000 as the value that allows your test to pass, however,
97 // sometimes your test might fail because of this. In such cases, it's better to pick one element
98 // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole
99 // page contents loaded
100 $this->webtestLogin();
102 // Get sample import data.
103 list($headers, $rows) = $this->_individualCSVData_Month_dd_yyyy();
105 // Import and check Individual contacts in Skip mode and
106 // Month dd, yyyy date format.
107 $other = array('dateFormat' => 'Month dd, yyyy');
109 $this->importContacts($headers, $rows, 'Individual', 'Skip', array(), $other);
113 * Test contact import for dd_mon_yy date format.
115 function testDateFormat_dd_mon_yy() {
116 // Logging in. Remember to wait for page to load. In most cases,
117 // you can rely on 30000 as the value that allows your test to pass, however,
118 // sometimes your test might fail because of this. In such cases, it's better to pick one element
119 // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole
120 // page contents loaded
121 $this->webtestLogin();
123 // Get sample import data.
124 list($headers, $rows) = $this->_individualCSVData_dd_mon_yy();
126 // Import and check Individual contacts in Skip mode and
127 // dd-mon-yy OR dd/mm/yy date format.
128 $other = array('dateFormat' => 'dd-mon-yy OR dd/mm/yy');
130 $this->importContacts($headers, $rows, 'Individual', 'Skip', array(), $other);
134 * Test contact import for dd_mm_yyyy date format.
136 function testDateFormat_dd_mm_yyyy() {
137 // Logging in. Remember to wait for page to load. In most cases,
138 // you can rely on 30000 as the value that allows your test to pass, however,
139 // sometimes your test might fail because of this. In such cases, it's better to pick one element
140 // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole
141 // page contents loaded
142 $this->webtestLogin();
144 // Get sample import data.
145 list($headers, $rows) = $this->_individualCSVData_dd_mm_yyyy();
147 // Import and check Individual contacts in Skip mode and
148 // dd/mm/yyyy date format.
149 $other = array('dateFormat' => 'dd/mm/yyyy');
151 $this->importContacts($headers, $rows, 'Individual', 'Skip', array(), $other);
155 * Helper function to provide data for contact import for Individuals and yyyy-mm-dd OR yyyymmdd dateformat.
157 function _individualCSVData_yyyy_mm_dd() {
159 'first_name' => 'First Name',
160 'middle_name' => 'Middle Name',
161 'last_name' => 'Last Name',
164 'address_1' => 'Additional Address 1',
165 'address_2' => 'Additional Address 2',
168 'country' => 'Country',
169 'birth_date' => 'Birth Date',
173 array('first_name' => substr(sha1(rand()), 0, 7),
174 'middle_name' => substr(sha1(rand()), 0, 7),
175 'last_name' => 'Anderson',
176 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
177 'phone' => '6949912154',
178 'address_1' => 'Add 1',
179 'address_2' => 'Add 2',
182 'country' => 'United States',
183 'birth_date' => '1998-12-25',
185 array('first_name' => substr(sha1(rand()), 0, 7),
186 'middle_name' => substr(sha1(rand()), 0, 7),
187 'last_name' => 'Summerson',
188 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
189 'phone' => '6944412154',
190 'address_1' => 'Add 1',
191 'address_2' => 'Add 2',
194 'country' => 'United States',
195 'birth_date' => '1999-11-26',
199 return array($headers, $rows);
203 * Helper function to provide data for contact import for Individuals and mm/dd/yy OR mm-dd-yy dateformat.
205 function _individualCSVData_mm_dd_yy() {
207 'first_name' => 'First Name',
208 'middle_name' => 'Middle Name',
209 'last_name' => 'Last Name',
212 'address_1' => 'Additional Address 1',
213 'address_2' => 'Additional Address 2',
216 'country' => 'Country',
217 'birth_date' => 'Birth Date',
221 array('first_name' => substr(sha1(rand()), 0, 7),
222 'middle_name' => substr(sha1(rand()), 0, 7),
223 'last_name' => 'Anderson',
224 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
225 'phone' => '6949912154',
226 'address_1' => 'Add 1',
227 'address_2' => 'Add 2',
230 'country' => 'United States',
231 'birth_date' => '12/23/98',
233 array('first_name' => substr(sha1(rand()), 0, 7),
234 'middle_name' => substr(sha1(rand()), 0, 7),
235 'last_name' => 'Summerson',
236 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
237 'phone' => '6944412154',
238 'address_1' => 'Add 1',
239 'address_2' => 'Add 2',
242 'country' => 'United States',
243 'birth_date' => '11/24/88',
247 return array($headers, $rows);
251 * Helper function to provide data for contact import for Individuals and mm/dd/yyyy OR mm-dd-yyyy dateformat.
253 function _individualCSVData_mm_dd_yyyy() {
255 'first_name' => 'First Name',
256 'middle_name' => 'Middle Name',
257 'last_name' => 'Last Name',
260 'address_1' => 'Additional Address 1',
261 'address_2' => 'Additional Address 2',
264 'country' => 'Country',
265 'birth_date' => 'Birth Date',
269 array('first_name' => substr(sha1(rand()), 0, 7),
270 'middle_name' => substr(sha1(rand()), 0, 7),
271 'last_name' => 'Anderson',
272 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
273 'phone' => '6949912154',
274 'address_1' => 'Add 1',
275 'address_2' => 'Add 2',
278 'country' => 'United States',
279 'birth_date' => '11/12/1995',
281 array('first_name' => substr(sha1(rand()), 0, 7),
282 'middle_name' => substr(sha1(rand()), 0, 7),
283 'last_name' => 'Summerson',
284 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
285 'phone' => '6944412154',
286 'address_1' => 'Add 1',
287 'address_2' => 'Add 2',
290 'country' => 'United States',
291 'birth_date' => '12/12/1995',
295 return array($headers, $rows);
299 * Helper function to provide data for contact import for Individuals and Month dd, yyyy dateformat.
301 function _individualCSVData_Month_dd_yyyy() {
303 'first_name' => 'First Name',
304 'middle_name' => 'Middle Name',
305 'last_name' => 'Last Name',
308 'address_1' => 'Additional Address 1',
309 'address_2' => 'Additional Address 2',
312 'country' => 'Country',
313 'birth_date' => 'Birth Date',
317 array('first_name' => substr(sha1(rand()), 0, 7),
318 'middle_name' => substr(sha1(rand()), 0, 7),
319 'last_name' => 'Anderson',
320 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
321 'phone' => '6949912154',
322 'address_1' => 'Add 1',
323 'address_2' => 'Add 2',
326 'country' => 'United States',
327 'birth_date' => 'December 12, 1998',
329 array('first_name' => substr(sha1(rand()), 0, 7),
330 'middle_name' => substr(sha1(rand()), 0, 7),
331 'last_name' => 'Summerson',
332 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
333 'phone' => '6944412154',
334 'address_1' => 'Add 1',
335 'address_2' => 'Add 2',
338 'country' => 'United States',
339 'birth_date' => 'December 13, 1998',
343 return array($headers, $rows);
347 * Helper function to provide data for contact import for Individuals and dd-mon-yy OR dd/mm/yy dateformat.
349 function _individualCSVData_dd_mon_yy() {
351 'first_name' => 'First Name',
352 'middle_name' => 'Middle Name',
353 'last_name' => 'Last Name',
356 'address_1' => 'Additional Address 1',
357 'address_2' => 'Additional Address 2',
360 'country' => 'Country',
361 'birth_date' => 'Birth Date',
365 array('first_name' => substr(sha1(rand()), 0, 7),
366 'middle_name' => substr(sha1(rand()), 0, 7),
367 'last_name' => 'Anderson',
368 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
369 'phone' => '6949912154',
370 'address_1' => 'Add 1',
371 'address_2' => 'Add 2',
374 'country' => 'United States',
375 'birth_date' => '25/12/98',
377 array('first_name' => substr(sha1(rand()), 0, 7),
378 'middle_name' => substr(sha1(rand()), 0, 7),
379 'last_name' => 'Summerson',
380 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
381 'phone' => '6944412154',
382 'address_1' => 'Add 1',
383 'address_2' => 'Add 2',
386 'country' => 'United States',
387 'birth_date' => '26/12/99',
391 return array($headers, $rows);
395 * Helper function to provide data for contact import for Individuals and dd/mm/yyyy dateformat.
397 function _individualCSVData_dd_mm_yyyy() {
399 'first_name' => 'First Name',
400 'middle_name' => 'Middle Name',
401 'last_name' => 'Last Name',
404 'address_1' => 'Additional Address 1',
405 'address_2' => 'Additional Address 2',
408 'country' => 'Country',
409 'birth_date' => 'Birth Date',
413 array('first_name' => substr(sha1(rand()), 0, 7),
414 'middle_name' => substr(sha1(rand()), 0, 7),
415 'last_name' => 'Anderson',
416 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
417 'phone' => '6949912154',
418 'address_1' => 'Add 1',
419 'address_2' => 'Add 2',
422 'country' => 'United States',
423 'birth_date' => '25/12/1998',
425 array('first_name' => substr(sha1(rand()), 0, 7),
426 'middle_name' => substr(sha1(rand()), 0, 7),
427 'last_name' => 'Summerson',
428 'email' => substr(sha1(rand()), 0, 7) . '@example.com',
429 'phone' => '6944412154',
430 'address_1' => 'Add 1',
431 'address_2' => 'Add 2',
434 'country' => 'United States',
435 'birth_date' => '24/11/1996',
439 return array($headers, $rows);