1 date_validation.test public DateValidationTestCase::testValidation()

Test validation on each type of date widget.

File

core/modules/date/tests/date_validation.test, line 14
Date validation tests.

Class

DateValidationTestCase

Code

public function testValidation() {
  // Attempts to create text date field stored as a date with default settings
  // (from input which is not valid).
  foreach (array('date', 'datestamp', 'datetime') as $field_type) {
    foreach (array('date_select', 'date_popup', 'date_text') as $widget_type) {
      $field_name = 'field_test';
      $label = 'Test';
      $options = array(
        'label' => $label,
        'field_name' => $field_name,
        'field_type' => $field_type,
        'widget_type' => $widget_type,
        'input_format' => 'm/d/Y - H:i',
      );
      $this->createDateField($options);

      // Malformed date test won't work on date_select, which won't allow
      // invalid input.
      if ($widget_type != 'date_select') {
        $this->malFormedDate($field_name, $field_type, $widget_type);
      }

      $this->checkGranularity($field_name, $field_type, $widget_type);
      $this->deleteDateField($label);
    }
  }
}