1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Test Date All Day functionality.
|
6
|
*/
|
7
|
|
8
|
/**
|
9
|
* Test Date All Day functionality.
|
10
|
*/
|
11
|
class DateAllDayUiTestCase extends DateFieldTestBase {
|
12
|
|
13
|
/**
|
14
|
*
|
15
|
*/
|
16
|
public static function getInfo() {
|
17
|
return array(
|
18
|
'name' => t('Date All Day unit'),
|
19
|
'description' => t('Test Date All Day functions.') ,
|
20
|
'group' => t('Date'),
|
21
|
);
|
22
|
}
|
23
|
|
24
|
/**
|
25
|
* {@inheritdoc}
|
26
|
*/
|
27
|
public function setUp(array $modules = array()) {
|
28
|
$modules[] = 'date_all_day';
|
29
|
$modules[] = 'date_all_day_test_feature';
|
30
|
parent::setUp($modules);
|
31
|
|
32
|
// Provide a date format that includes the main values.
|
33
|
variable_set('date_format_long', 'D, m/d/Y - H:i');
|
34
|
|
35
|
// Turn off the option to let users change their timezone, so that all date
|
36
|
// values will have a fixed output.
|
37
|
variable_set('configurable_timezones', FALSE);
|
38
|
}
|
39
|
|
40
|
/**
|
41
|
* Test the node form, confirm the "Date all day" field exists & works.
|
42
|
*/
|
43
|
public function testAllDayField() {
|
44
|
// A first node, with the "all day" option disabled.
|
45
|
$this->drupalGet('node/add/date-all-day-test');
|
46
|
$this->assertResponse(200);
|
47
|
|
48
|
// Confirm the 'date all day' field exists.
|
49
|
$this->assertFieldByName('field_date_all_day[und][0][all_day]');
|
50
|
$this->assertFieldByName('field_date_all_day[und][0][value][month]');
|
51
|
$this->assertFieldByName('field_date_all_day[und][0][value][day]');
|
52
|
$this->assertFieldByName('field_date_all_day[und][0][value][year]');
|
53
|
$this->assertFieldByName('field_date_all_day[und][0][value][hour]');
|
54
|
$this->assertFieldByName('field_date_all_day[und][0][value][minute]');
|
55
|
|
56
|
// Submit the node form.
|
57
|
$edit = array(
|
58
|
'title' => 'Testing the All Day option',
|
59
|
'field_date_all_day[und][0][all_day]' => FALSE,
|
60
|
'field_date_all_day[und][0][value][month]' => 2,
|
61
|
'field_date_all_day[und][0][value][day]' => 11,
|
62
|
'field_date_all_day[und][0][value][year]' => 2021,
|
63
|
'field_date_all_day[und][0][value][hour]' => 18,
|
64
|
'field_date_all_day[und][0][value][minute]' => 15,
|
65
|
);
|
66
|
$this->drupalPost(NULL, $edit, 'Save');
|
67
|
$this->assertResponse(200);
|
68
|
|
69
|
// Confirm the data is displayed correctly.
|
70
|
$this->assertText('Testing the All Day option');
|
71
|
$this->assertText('Date All Day');
|
72
|
$this->assertText('Thu, 02/11/2021 - 18:15');
|
73
|
|
74
|
// A second node, this time with the "all day" option enabled.
|
75
|
$this->drupalGet('node/add/date-all-day-test');
|
76
|
$this->assertResponse(200);
|
77
|
|
78
|
// Submit the node form.
|
79
|
$edit = array(
|
80
|
'title' => 'Testing the All Day option again',
|
81
|
'field_date_all_day[und][0][all_day]' => TRUE,
|
82
|
'field_date_all_day[und][0][value][month]' => 2,
|
83
|
'field_date_all_day[und][0][value][day]' => 11,
|
84
|
'field_date_all_day[und][0][value][year]' => 2021,
|
85
|
'field_date_all_day[und][0][value][hour]' => 18,
|
86
|
'field_date_all_day[und][0][value][minute]' => 15,
|
87
|
);
|
88
|
$this->drupalPost(NULL, $edit, 'Save');
|
89
|
$this->assertResponse(200);
|
90
|
|
91
|
// Confirm the data is displayed correctly.
|
92
|
$this->assertText('Testing the All Day option again');
|
93
|
$this->assertText('Date All Day');
|
94
|
$this->assertText('Thu, 02/11/2021 (All day)');
|
95
|
|
96
|
// Load the node and confirm the data is as expected.
|
97
|
$node = node_load(2);
|
98
|
$this->verbose($node);
|
99
|
$this->assertEqual($node->title, $edit['title']);
|
100
|
$this->assertTrue(isset($node->field_date_all_day[LANGUAGE_NONE][0]['value']));
|
101
|
$this->assertEqual($node->field_date_all_day[LANGUAGE_NONE][0]['value'], '2021-02-11 23:45:59');
|
102
|
}
|
103
|
|
104
|
}
|