You are here

public function DateValidationTestCase::wrongGranularity in Date 7.3

Same name and namespace in other branches
  1. 7.2 tests/DateValidationTestCase.test \DateValidationTestCase::wrongGranularity()

Create a node with incorrect granularity, missing time.

1 call to DateValidationTestCase::wrongGranularity()
DateValidationTestCase::checkDateField in tests/DateValidationTestCase.test
Run some tests against a specific field type/widget combination.

File

tests/DateValidationTestCase.test, line 142
Validate date field values.

Class

DateValidationTestCase
Validate date field values.

Code

public function wrongGranularity($field_name, $field_type, $widget_type) {
  $edit = array();
  $edit['title'] = self::randomName(8);
  $edit['body[und][0][value]'] = self::randomName(16);
  if ($widget_type === 'date_select') {
    $edit[$field_name . '[und][0][value][year]'] = '2011';
    $edit[$field_name . '[und][0][value][month]'] = '12';
    $edit[$field_name . '[und][0][value][day]'] = '10';
    $edit[$field_name . '[und][0][value][hour]'] = '';
    $edit[$field_name . '[und][0][value][minute]'] = '';
  }
  elseif ($widget_type === 'date_text') {
    $edit[$field_name . '[und][0][value][date]'] = '12/10/2011';
  }
  elseif ($widget_type === 'date_popup') {
    $edit[$field_name . '[und][0][value][date]'] = '12/10/2011';
    $edit[$field_name . '[und][0][value][time]'] = '';
  }
  $this
    ->drupalPost('node/add/story', $edit, t('Save'));
  $should_not_be = $edit['title'] . " has been created";
  $this
    ->assertNoText($should_not_be, "Correctly blocked creation of node with missing time for a {$field_type} field using the {$widget_type} widget.");
  $this
    ->assertText('invalid', "Marked form with missing time as invalid for a {$field_type} field using the {$widget_type} widget.");
}