1 date.test public DateUITestCase::testFieldUI()

File

core/modules/date/tests/date.test, line 19
Test date UI.

Class

DateUITestCase

Code

public function testFieldUI() {
  $label = 'Test';
  $current_year = date('Y');

  $field_types = array('date', 'datestamp', 'datetime');
  $widget_types = array('date_select', 'date_text', 'date_popup', 'date_html5');

  // Test widgets with default settings using every widget and field type.
  foreach ($field_types as $field_type) {
    foreach ($widget_types as $widget_type) {
      $this->createDateField(
      array(
        'label' => $label,
        'field_type' => $field_type,
        'widget_type' => $widget_type,
      )
      );
      $this->dateForm($widget_type);
      $this->assertText(format_string('10/07/!year - 10:30', array('!year' => $current_year)), 'Found the correct date for a date field using the ' . $widget_type . ' widget.');
      $this->deleteDateField($label);
    }
  }

  // Test timezone handling validation on the field settings form.
  $this->createDateField(array('label' => $label, 'field_type' => 'date', 'widget_type' => 'date_select', 'granularity' => array('year', 'month', 'day')));
  $edit = array('field[settings][granularity][hour]' => FALSE);
  $this->backdropPost('admin/structure/types/manage/story/fields/field_' . strtolower($label), $edit, t('Save settings'));
  $this->assertText("Dates without hours granularity must not use any timezone handling.", "Dates without hours granularity required to use timezone handling of 'none.'");
  $this->deleteDateField($label);
}