You are here

function DateFieldTestCase::dateForm in Date 7

1 call to DateFieldTestCase::dateForm()
DateFieldTestCase::testField in tests/date_field.test

File

tests/date_field.test, line 50

Class

DateFieldTestCase

Code

function dateForm($options, $todate = TRUE) {

  // Tests that date field functions properly.
  $edit = array();
  $edit['title'] = $this
    ->randomName(8);
  if ($options == 'select') {
    $edit['field_test[und][0][value][year]'] = '2010';
    $edit['field_test[und][0][value][month]'] = '10';
    $edit['field_test[und][0][value][day]'] = '7';
    $edit['field_test[und][0][value][hour]'] = '10';
    $edit['field_test[und][0][value][minute]'] = '30';
    if ($todate) {
      $edit['field_test[und][0][value2][year]'] = '';
      $edit['field_test[und][0][value2][month]'] = '';
      $edit['field_test[und][0][value2][day]'] = '';
      $edit['field_test[und][0][value2][hour]'] = '11';
      $edit['field_test[und][0][value2][minute]'] = '';
    }
  }
  elseif ($options == 'text') {
    $edit['field_test[und][0][value][date]'] = '10/07/2010 - 10:30';
    if ($todate) {
      $edit['field_test[und][0][value2][date]'] = '10/07/2010 - 11:30';
    }
  }
  elseif ($options == 'popup') {
    $edit['field_test[und][0][value][date]'] = '10/07/2010';
    $edit['field_test[und][0][value][time]'] = '10:30';
    if ($todate) {
      $edit['field_test[und][0][value2][date]'] = '';
      $edit['field_test[und][0][value2][time]'] = '11:30';
    }
  }
  $this
    ->drupalPost('node/add/story', $edit, t('Save'));
  $this
    ->assertText($edit['title'], 'Test node has been created');
  $shouldbe = $todate ? 'Thu, 10/07/2010 - 10:30 - 11:30' : 'Thu, 10/07/2010 - 10:30';
  $this
    ->assertText($shouldbe, "Found the correct date for a datetime field using the {$options} widget.");
}