1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Test date UI.
|
6
|
*/
|
7
|
|
8
|
class DateUITestCase extends DateFieldBasic {
|
9
|
|
10
|
/**
|
11
|
* @todo.
|
12
|
*/
|
13
|
public static function getInfo() {
|
14
|
return array(
|
15
|
'name' => 'Field UI',
|
16
|
'description' => 'Test creation of various date fields and widgets using Field UI.',
|
17
|
'group' => 'Date',
|
18
|
);
|
19
|
}
|
20
|
|
21
|
/**
|
22
|
* @todo.
|
23
|
*/
|
24
|
public function setUp() {
|
25
|
parent::setUp();
|
26
|
|
27
|
variable_set('date_format_long', 'D, m/d/Y - H:i');
|
28
|
}
|
29
|
|
30
|
/**
|
31
|
* @todo.
|
32
|
*/
|
33
|
public function testFieldUI() {
|
34
|
$label = 'Test';
|
35
|
$current_year = date('Y');
|
36
|
|
37
|
$field_types = array('date', 'datestamp', 'datetime');
|
38
|
$widget_types = array('date_select', 'date_text', 'date_popup');
|
39
|
|
40
|
// Test widgets with default settings using every widget and field type.
|
41
|
foreach ($field_types as $field_type) {
|
42
|
foreach ($widget_types as $widget_type) {
|
43
|
$this->createDateField(
|
44
|
array(
|
45
|
'label' => $label,
|
46
|
'field_type' => $field_type,
|
47
|
'widget_type' => $widget_type,
|
48
|
)
|
49
|
);
|
50
|
$this->dateForm($widget_type);
|
51
|
$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.');
|
52
|
$this->deleteDateField($label);
|
53
|
}
|
54
|
}
|
55
|
|
56
|
// Test timezone handling validation on the field settings form.
|
57
|
$this->createDateField(array('label' => $label, 'field_type' => 'date', 'widget_type' => 'date_select', 'granularity' => array('year', 'month', 'day')));
|
58
|
$edit = array('field[settings][granularity][hour]' => FALSE);
|
59
|
$this->drupalPost('admin/structure/types/manage/story/fields/field_' . strtolower($label), $edit, t('Save settings'));
|
60
|
$this->assertText("Dates without hours granularity must not use any timezone handling.", "Dates without hours granularity required to use timezone handling of 'none.'");
|
61
|
$this->deleteDateField($label);
|
62
|
}
|
63
|
|
64
|
/**
|
65
|
* @todo.
|
66
|
*/
|
67
|
function dateForm($options) {
|
68
|
// Tests that date field functions properly.
|
69
|
$edit = array();
|
70
|
$edit['title'] = $this->randomName(8);
|
71
|
$edit['body[und][0][value]'] = $this->randomName(16);
|
72
|
$current_year = date('Y');
|
73
|
|
74
|
if ($options == 'date_select') {
|
75
|
$edit['field_test[und][0][value][year]'] = $current_year;
|
76
|
$edit['field_test[und][0][value][month]'] = '10';
|
77
|
$edit['field_test[und][0][value][day]'] = '7';
|
78
|
$edit['field_test[und][0][value][hour]'] = '10';
|
79
|
$edit['field_test[und][0][value][minute]'] = '30';
|
80
|
}
|
81
|
elseif ($options == 'date_text') {
|
82
|
$edit['field_test[und][0][value][date]'] = format_string('10/07/!year - 10:30', array('!year' => $current_year));
|
83
|
}
|
84
|
elseif ($options == 'date_popup') {
|
85
|
$edit['field_test[und][0][value][date]'] = format_string('10/07/!year', array('!year' => $current_year));
|
86
|
$edit['field_test[und][0][value][time]'] = '10:30';
|
87
|
}
|
88
|
$this->drupalPost('node/add/story', $edit, t('Save'));
|
89
|
$this->assertText($edit['body[und][0][value]'], 'Test node has been created');
|
90
|
}
|
91
|
}
|