2021-03-22 11:00:10 +01:00

86 lines
2.5 KiB
Plaintext

<?php
/**
* @file
* Test date UI.
*/
/**
*
*/
class DateUiTestCase extends DateFieldTestBase {
/**
* @todo.
*/
public static function getInfo() {
return array(
'name' => 'Field UI',
'description' => 'Test creation of various date fields and widgets using Field UI.',
'group' => 'Date',
);
}
/**
* @todo.
*/
public function setUp(array $modules = array()) {
parent::setUp($modules);
variable_set('date_format_long', 'D, m/d/Y - H:i');
}
/**
* @todo.
*/
public function testFieldUI() {
$label = 'Test';
$current_year = date('Y');
// Test widgets with default settings using every widget and field type.
foreach (array('date', 'datestamp', 'datetime') as $field_type) {
// @todo Add back 'date_popup'.
foreach (array('date_select', 'date_text') as $widget_type) {
$this->createDateField(
array(
'label' => $label,
'field_type' => $field_type,
'widget_type' => $widget_type,
)
);
$this->dateForm('blah', 'blah', $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);
}
}
}
/**
* {@inheritdoc}
*/
function dateForm($field_name, $field_type, $widget_type, $todate = TRUE) {
// Tests that date field functions properly.
$edit = array();
$edit['title'] = $this->randomName(8);
$edit['body[und][0][value]'] = $this->randomName(16);
$current_year = date('Y');
if ($widget_type == 'date_select') {
$edit['field_test[und][0][value][year]'] = $current_year;
$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';
}
elseif ($widget_type == 'date_text') {
$edit['field_test[und][0][value][date]'] = format_string('10/07/!year - 10:30', array('!year' => $current_year));
}
elseif ($widget_type == 'date_popup') {
$edit['field_test[und][0][value][date]'] = format_string('10/07/!year', array('!year' => $current_year));
$edit['field_test[und][0][value][time]'] = '10:30';
}
$this->drupalPost('node/add/story', $edit, t('Save'));
$this->assertText($edit['body[und][0][value]'], 'Test node has been created');
}
}