public function DateTimezoneTestCase::buildDateForm in Date 7.2
Same name and namespace in other branches
- 7.3 tests/DateTimezoneTestCase.test \DateTimezoneTestCase::buildDateForm()
Replacement for dateForm().
1 call to DateTimezoneTestCase::buildDateForm()
- DateTimezoneTestCase::testTimezone in tests/
DateTimezoneTestCase.test - Create a date fields, combining various timezones and granularity.
File
- tests/
DateTimezoneTestCase.test, line 202 - Test timezone handling.
Class
- DateTimezoneTestCase
- Test timezone handling.
Code
public function buildDateForm($field_name, $field_type, $max_granularity, $tz_handling) {
variable_set('date_format_long', 'D, m/d/Y - H:i:s');
$edit = array();
$edit['title'] = self::randomName(8);
$edit[$field_name . '[und][0][show_todate]'] = '1';
switch ($max_granularity) {
case 'year':
$edit[$field_name . '[und][0][value][date]'] = '2010';
$edit[$field_name . '[und][0][value2][date]'] = '2011';
$should_be = '2010 to 2011';
break;
case 'month':
$edit[$field_name . '[und][0][value][date]'] = '07/2010';
$edit[$field_name . '[und][0][value2][date]'] = '08/2010';
$should_be = '07/2010 to 08/2010';
break;
case 'day':
$edit[$field_name . '[und][0][value][date]'] = '10/07/2010';
$edit[$field_name . '[und][0][value2][date]'] = '10/08/2010';
$should_be = 'Thu, 10/07/2010 to Fri, 10/08/2010';
break;
case 'hour':
$edit[$field_name . '[und][0][value][date]'] = '10/07/2010 - 10';
$edit[$field_name . '[und][0][value2][date]'] = '10/07/2010 - 11';
if ($tz_handling === 'utc') {
$should_be = 'Thu, 10/07/2010 - 21 to Thu, 10/07/2010 - 22';
}
else {
$should_be = 'Thu, 10/07/2010 - 10 to Thu, 10/07/2010 - 11';
}
break;
case 'minute':
$edit[$field_name . '[und][0][value][date]'] = '10/07/2010 - 10:30';
$edit[$field_name . '[und][0][value2][date]'] = '10/07/2010 - 11:30';
if ($tz_handling === 'utc') {
$should_be = 'Thu, 10/07/2010 - 21:30 to 22:30';
}
else {
$should_be = 'Thu, 10/07/2010 - 10:30 to 11:30';
}
break;
case 'second':
$edit[$field_name . '[und][0][value][date]'] = '10/07/2010 - 10:30:30';
$edit[$field_name . '[und][0][value2][date]'] = '10/07/2010 - 11:30:30';
if ($tz_handling === 'utc') {
$should_be = 'Thu, 10/07/2010 - 21:30:30 to 22:30:30';
}
else {
$should_be = 'Thu, 10/07/2010 - 10:30:30 to 11:30:30';
}
break;
}
$this
->drupalPost('node/add/story', $edit, t('Save'));
$this
->assertText($edit['title'], "Node has been created");
$this
->assertText($should_be, "Found the correct date for a {$field_type} field using {$max_granularity} granularity with {$tz_handling} timezone handling.");
}