1 date_timezone.test public DateTimezoneTestCase::testTimezone()

Creates one of each type of date field and check timezone handling in each.

File

core/modules/date/tests/date_timezone.test, line 14
Timezone tests.

Class

DateTimezoneTestCase

Code

public function testTimezone() {
  // Create date fields with combinations of various timezone handling and
  // granularity.
  foreach (array('date', 'datestamp', 'datetime') as $field_type) {
    foreach (array('site', 'none', 'date', 'user', 'utc') as $tz_handling) {
      foreach (array('year', 'month', 'day', 'hour', 'minute', 'second') as $max_granularity) {
        // Skip invalid combinations.
        if (in_array($max_granularity, array('year', 'month', 'day')) && $tz_handling != 'none') {
          continue;
        }
        $field_name = "field_test";
        $label = 'Test';
        $granularity = date_granularity_array_from_precision($max_granularity);
        $options = array(
          'label' => $label,
          'widget_type' => 'date_text',
          'field_name' => $field_name,
          'field_type' => $field_type,
          'input_format' => 'custom',
          'input_format_custom' => 'm/d/Y - H:i:s',
          'tz_handling' => $tz_handling,
          'granularity' => $granularity,
        );
        $this->createDateField($options);
        $this->dateForm($field_name, $field_type, $max_granularity, $tz_handling);
        $this->deleteDateField($label);
      }
    }
  }
}