1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* Test Date API functions
|
6 |
|
|
*/
|
7 |
|
|
|
8 |
|
|
class DateAPITestCase extends DrupalWebTestCase {
|
9 |
|
|
/**
|
10 |
|
|
* @todo.
|
11 |
|
|
*/
|
12 |
|
|
public static function getInfo() {
|
13 |
|
|
return array(
|
14 |
|
|
'name' => t('Date API'),
|
15 |
|
|
'description' => t('Test Date API functions.') ,
|
16 |
|
|
'group' => t('Date'),
|
17 |
|
|
);
|
18 |
|
|
}
|
19 |
|
|
|
20 |
|
|
/**
|
21 |
|
|
* @todo.
|
22 |
|
|
*/
|
23 |
|
|
public function setUp() {
|
24 |
|
|
// Load the date_api module.
|
25 |
|
|
parent::setUp('date_api');
|
26 |
|
|
variable_set('date_api_use_iso8601', FALSE);
|
27 |
|
|
variable_set('date_first_day', 1);
|
28 |
|
|
}
|
29 |
|
|
|
30 |
|
|
/**
|
31 |
|
|
* @todo.
|
32 |
|
|
*/
|
33 |
|
|
public function testDateAPI() {
|
34 |
|
|
// Test date_format_date().
|
35 |
|
|
$formatters = array(
|
36 |
|
|
'a',
|
37 |
|
|
'A',
|
38 |
|
|
'B',
|
39 |
|
|
'c',
|
40 |
|
|
'd',
|
41 |
|
|
'D',
|
42 |
|
|
'e',
|
43 |
|
|
'F',
|
44 |
|
|
'g',
|
45 |
|
|
'G',
|
46 |
|
|
'h',
|
47 |
|
|
'H',
|
48 |
|
|
'i',
|
49 |
|
|
'I',
|
50 |
|
|
'j',
|
51 |
|
|
'l',
|
52 |
|
|
'L',
|
53 |
|
|
'm',
|
54 |
|
|
'M',
|
55 |
|
|
'n',
|
56 |
|
|
'N',
|
57 |
|
|
'o',
|
58 |
|
|
'O',
|
59 |
|
|
'P',
|
60 |
|
|
'r',
|
61 |
|
|
'R',
|
62 |
|
|
's',
|
63 |
|
|
'S',
|
64 |
|
|
't',
|
65 |
|
|
'T',
|
66 |
|
|
'u',
|
67 |
|
|
'U',
|
68 |
|
|
'w',
|
69 |
|
|
'W',
|
70 |
|
|
'y',
|
71 |
|
|
'Y',
|
72 |
|
|
'z',
|
73 |
|
|
'Z',
|
74 |
|
|
);
|
75 |
|
|
foreach ($formatters as $formatter) {
|
76 |
|
|
$date_api_format = date_format_date(date_now(), 'custom', $formatter);
|
77 |
|
|
$php_format = date_format(date_now(), $formatter);
|
78 |
|
|
$this->assertEqual($date_api_format, $php_format, 'Test that the "' . $formatter . '" formatter is formatted correctly by date_format_date()');
|
79 |
|
|
}
|
80 |
|
|
|
81 |
|
|
// Test the order of the weeks days for a calendar that starts on Monday and
|
82 |
|
|
// one that starts on Sunday.
|
83 |
|
|
variable_set('date_first_day', 1);
|
84 |
|
|
$expected = array(0 => t('Mon'), 1 => t('Tue'), 2 => t('Wed'), 3 => t('Thu'), 4 => t('Fri'), 5 => t('Sat'), 6 => t('Sun'));
|
85 |
|
|
$days = date_week_days_ordered(date_week_days_abbr(1));
|
86 |
|
|
$this->assertEqual($expected, $days, 'Test that date_week_days_ordered() array starts on Monday when the site first day is on Monday.');
|
87 |
|
|
variable_set('date_first_day', 0);
|
88 |
|
|
$expected = array(0 => t('Sun'), 1 => t('Mon'), 2 => t('Tue'), 3 => t('Wed'), 4 => t('Thu'), 5 => t('Fri'), 6 => t('Sat'));
|
89 |
|
|
$days = date_week_days_ordered(date_week_days_abbr(1));
|
90 |
|
|
$this->assertEqual($expected, $days, 'Test that date_week_days_ordered() array starts on Sunday when the site first day is on Sunday.');
|
91 |
|
|
|
92 |
|
|
// Test days in February for a leap year and a non-leap year.
|
93 |
|
|
$expected = 28;
|
94 |
|
|
$value = date_days_in_month(2005, 2);
|
95 |
|
|
$this->assertEqual($expected, $value, "Test date_days_in_month(2, 2005): should be $expected, found $value.");
|
96 |
|
|
$expected = 29;
|
97 |
|
|
$value = date_days_in_month(2004, 2);
|
98 |
|
|
$this->assertEqual($expected, $value, "Test date_days_in_month(2, 2004): should be $expected, found $value.");
|
99 |
|
|
|
100 |
|
|
// Test days in year for a leap year and a non-leap year.
|
101 |
|
|
$expected = 365;
|
102 |
|
|
$value = date_days_in_year('2005-06-01 00:00:00');
|
103 |
|
|
$this->assertEqual($expected, $value, "Test date_days_in_year(2005-06-01): should be $expected, found $value.");
|
104 |
|
|
$expected = 366;
|
105 |
|
|
$value = date_days_in_year('2004-06-01 00:00:00');
|
106 |
|
|
$this->assertEqual($expected, $value, "Test date_days_in_year(2004-06-01): should be $expected, found $value.");
|
107 |
|
|
|
108 |
|
|
// Test ISO weeks for a leap year and a non-leap year.
|
109 |
|
|
$expected = 52;
|
110 |
|
|
$value = date_iso_weeks_in_year('2008-06-01 00:00:00');
|
111 |
|
|
$this->assertEqual($expected, $value, "Test date_iso_weeks_in_year(2008-06-01): should be $expected, found $value.");
|
112 |
|
|
$expected = 53;
|
113 |
|
|
$value = date_iso_weeks_in_year('2009-06-01 00:00:00');
|
114 |
|
|
$this->assertEqual($expected, $value, "Test date_iso_weeks_in_year(2009-06-01): should be $expected, found $value.");
|
115 |
|
|
|
116 |
|
|
// Test day of week for March 1, the day after leap day.
|
117 |
|
|
$expected = 6;
|
118 |
|
|
$value = date_day_of_week('2008-03-01 00:00:00');
|
119 |
|
|
$this->assertEqual($expected, $value, "Test date_day_of_week(2008-03-01): should be $expected, found $value.");
|
120 |
|
|
$expected = 0;
|
121 |
|
|
$value = date_day_of_week('2009-03-01 00:00:00');
|
122 |
|
|
$this->assertEqual($expected, $value, "Test date_day_of_week(2009-03-01): should be $expected, found $value.");
|
123 |
|
|
|
124 |
|
|
// Test day of week name for March 1, the day after leap day.
|
125 |
|
|
$expected = 'Sat';
|
126 |
|
|
$value = date_day_of_week_name('2008-03-01 00:00:00');
|
127 |
|
|
$this->assertEqual($expected, $value, "Test date_day_of_week_name(2008-03-01): should be $expected, found $value.");
|
128 |
|
|
$expected = 'Sun';
|
129 |
|
|
$value = date_day_of_week_name('2009-03-01 00:00:00');
|
130 |
|
|
$this->assertEqual($expected, $value, "Test date_day_of_week_name(2009-03-01): should be $expected, found $value.");
|
131 |
|
|
|
132 |
|
|
// Test week range with calendar weeks.
|
133 |
|
|
variable_set('date_first_day', 0);
|
134 |
|
|
variable_set('date_api_use_iso8601', FALSE);
|
135 |
|
|
$expected = '2008-01-27 to 2008-02-03';
|
136 |
|
|
$result = date_week_range(5, 2008);
|
137 |
|
|
$value = $result[0]->format(DATE_FORMAT_DATE) . ' to ' . $result[1]->format(DATE_FORMAT_DATE);
|
138 |
|
|
$this->assertEqual($expected, $value, "Test calendar date_week_range(5, 2008): should be $expected, found $value.");
|
139 |
|
|
$expected = '2009-01-25 to 2009-02-01';
|
140 |
|
|
$result = date_week_range(5, 2009);
|
141 |
|
|
$value = $result[0]->format(DATE_FORMAT_DATE) . ' to ' . $result[1]->format(DATE_FORMAT_DATE);
|
142 |
|
|
$this->assertEqual($expected, $value, "Test calendar date_week_range(5, 2009): should be $expected, found $value.");
|
143 |
|
|
|
144 |
|
|
// And now with ISO weeks.
|
145 |
|
|
variable_set('date_first_day', 1);
|
146 |
|
|
variable_set('date_api_use_iso8601', TRUE);
|
147 |
|
|
$expected = '2008-01-28 to 2008-02-04';
|
148 |
|
|
$result = date_week_range(5, 2008);
|
149 |
|
|
$value = $result[0]->format(DATE_FORMAT_DATE) . ' to ' . $result[1]->format(DATE_FORMAT_DATE);
|
150 |
|
|
$this->assertEqual($expected, $value, "Test ISO date_week_range(5, 2008): should be $expected, found $value.");
|
151 |
|
|
$expected = '2009-01-26 to 2009-02-02';
|
152 |
|
|
$result = date_week_range(5, 2009);
|
153 |
|
|
$value = $result[0]->format(DATE_FORMAT_DATE) . ' to ' . $result[1]->format(DATE_FORMAT_DATE);
|
154 |
|
|
$this->assertEqual($expected, $value, "Test ISO date_week_range(5, 2009): should be $expected, found $value.");
|
155 |
|
|
variable_set('date_api_use_iso8601', FALSE);
|
156 |
|
|
|
157 |
|
|
// Find calendar week for a date.
|
158 |
|
|
variable_set('date_first_day', 0);
|
159 |
|
|
$expected = '09';
|
160 |
|
|
$value = date_week('2008-03-01');
|
161 |
|
|
$this->assertEqual($expected, $value, "Test date_week(2008-03-01): should be $expected, found $value.");
|
162 |
|
|
$expected = '10';
|
163 |
|
|
$value = date_week('2009-03-01');
|
164 |
|
|
$this->assertEqual($expected, $value, "Test date_week(2009-03-01): should be $expected, found $value.");
|
165 |
|
|
|
166 |
|
|
// Create date object from datetime string.
|
167 |
|
|
$input = '2009-03-07 10:30';
|
168 |
|
|
$timezone = 'America/Chicago';
|
169 |
|
|
$date = new dateObject($input, $timezone);
|
170 |
|
|
$value = $date->format('c');
|
171 |
|
|
$expected = '2009-03-07T10:30:00-06:00';
|
172 |
|
|
$this->assertEqual($expected, $value, "Test new dateObject($input, $timezone): should be $expected, found $value.");
|
173 |
|
|
|
174 |
|
|
// Same during daylight savings time.
|
175 |
|
|
$input = '2009-06-07 10:30';
|
176 |
|
|
$timezone = 'America/Chicago';
|
177 |
|
|
$date = new dateObject($input, $timezone);
|
178 |
|
|
$value = $date->format('c');
|
179 |
|
|
$expected = '2009-06-07T10:30:00-05:00';
|
180 |
|
|
$this->assertEqual($expected, $value, "Test new dateObject($input, $timezone): should be $expected, found $value.");
|
181 |
|
|
|
182 |
|
|
// Create date object from date string.
|
183 |
|
|
$input = '2009-03-07';
|
184 |
|
|
$timezone = 'America/Chicago';
|
185 |
|
|
$date = new dateObject($input, $timezone);
|
186 |
|
|
$value = $date->format('c');
|
187 |
|
|
$expected = '2009-03-07T00:00:00-06:00';
|
188 |
|
|
$this->assertEqual($expected, $value, "Test new dateObject($input, $timezone): should be $expected, found $value.");
|
189 |
|
|
|
190 |
|
|
// Same during daylight savings time.
|
191 |
|
|
$input = '2009-06-07';
|
192 |
|
|
$timezone = 'America/Chicago';
|
193 |
|
|
$date = new dateObject($input, $timezone);
|
194 |
|
|
$value = $date->format('c');
|
195 |
|
|
$expected = '2009-06-07T00:00:00-05:00';
|
196 |
|
|
$this->assertEqual($expected, $value, "Test new dateObject($input, $timezone): should be $expected, found $value.");
|
197 |
|
|
|
198 |
|
|
// Create date object from date array, date only.
|
199 |
|
|
$input = array('year' => 2010, 'month' => 2, 'day' => 28);
|
200 |
|
|
$timezone = 'America/Chicago';
|
201 |
|
|
$date = new dateObject($input, $timezone);
|
202 |
|
|
$value = $date->format('c');
|
203 |
|
|
$expected = '2010-02-28T00:00:00-06:00';
|
204 |
|
|
$this->assertEqual($expected, $value, "Test new dateObject(array('year' => 2010, 'month' => 2, 'day' => 28), $timezone): should be $expected, found $value.");
|
205 |
|
|
|
206 |
|
|
// Create date object from date array with hour.
|
207 |
|
|
$input = array('year' => 2010, 'month' => 2, 'day' => 28, 'hour' => 10);
|
208 |
|
|
$timezone = 'America/Chicago';
|
209 |
|
|
$date = new dateObject($input, $timezone);
|
210 |
|
|
$value = $date->format('c');
|
211 |
|
|
$expected = '2010-02-28T10:00:00-06:00';
|
212 |
|
|
$this->assertEqual($expected, $value, "Test new dateObject(array('year' => 2010, 'month' => 2, 'day' => 28, 'hour' => 10), $timezone): should be $expected, found $value.");
|
213 |
|
|
|
214 |
|
|
// 0 = January 1, 1970 00:00:00 (UTC);
|
215 |
|
|
// 1000000000 = September 9, 2001 01:46:40 (UTC);
|
216 |
|
|
// Create date object from unix timestamp and convert it to a local date.
|
217 |
|
|
$input = 0;
|
218 |
|
|
$timezone = 'UTC';
|
219 |
|
|
$date = new dateObject($input, $timezone);
|
220 |
|
|
$value = $date->format('c');
|
221 |
|
|
$expected = '1970-01-01T00:00:00+00:00';
|
222 |
|
|
$this->assertEqual($expected, $value, "Test new dateObject($input, $timezone): should be $expected, found $value.");
|
223 |
|
|
|
224 |
|
|
$expected = 'UTC';
|
225 |
|
|
$value = $date->getTimeZone()->getName();
|
226 |
|
|
$this->assertEqual($expected, $value, "The current timezone is $value: should be $expected.");
|
227 |
|
|
$expected = 0;
|
228 |
|
|
$value = $date->getOffset();
|
229 |
|
|
$this->assertEqual($expected, $value, "The current offset is $value: should be $expected.");
|
230 |
|
|
|
231 |
|
|
$timezone = 'America/Los_Angeles';
|
232 |
|
|
$date->setTimezone(new DateTimeZone($timezone));
|
233 |
|
|
$value = $date->format('c');
|
234 |
|
|
$expected = '1969-12-31T16:00:00-08:00';
|
235 |
|
|
$this->assertEqual($expected, $value, "Test \$date->setTimezone(new DateTimeZone($timezone)): should be $expected, found $value.");
|
236 |
|
|
|
237 |
|
|
$expected = 'America/Los_Angeles';
|
238 |
|
|
$value = $date->getTimeZone()->getName();
|
239 |
|
|
$this->assertEqual($expected, $value, "The current timezone should be $expected, found $value.");
|
240 |
|
|
$expected = '-28800';
|
241 |
|
|
$value = $date->getOffset();
|
242 |
|
|
$this->assertEqual($expected, $value, "The current offset should be $expected, found $value.");
|
243 |
|
|
|
244 |
|
|
// Convert the local version of a timestamp to UTC.
|
245 |
|
|
$input = 0;
|
246 |
|
|
$timezone = 'America/Los_Angeles';
|
247 |
|
|
$date = new dateObject($input, $timezone);
|
248 |
|
|
$offset = $date->getOffset();
|
249 |
|
|
$value = $date->format('c');
|
250 |
|
|
$expected = '1969-12-31T16:00:00-08:00';
|
251 |
|
|
$this->assertEqual($expected, $value, "Test new dateObject($input, $timezone): should be $expected, found $value.");
|
252 |
|
|
|
253 |
|
|
$expected = 'America/Los_Angeles';
|
254 |
|
|
$value = $date->getTimeZone()->getName();
|
255 |
|
|
$this->assertEqual($expected, $value, "The current timezone should be $expected, found $value.");
|
256 |
|
|
$expected = '-28800';
|
257 |
|
|
$value = $date->getOffset();
|
258 |
|
|
$this->assertEqual($expected, $value, "The current offset should be $expected, found $value.");
|
259 |
|
|
|
260 |
|
|
$timezone = 'UTC';
|
261 |
|
|
$date->setTimezone(new DateTimeZone($timezone));
|
262 |
|
|
$value = $date->format('c');
|
263 |
|
|
$expected = '1970-01-01T00:00:00+00:00';
|
264 |
|
|
$this->assertEqual($expected, $value, "Test \$date->setTimezone(new DateTimeZone($timezone)): should be $expected, found $value.");
|
265 |
|
|
|
266 |
|
|
$expected = 'UTC';
|
267 |
|
|
$value = $date->getTimeZone()->getName();
|
268 |
|
|
$this->assertEqual($expected, $value, "The current timezone should be $expected, found $value.");
|
269 |
|
|
$expected = '0';
|
270 |
|
|
$value = $date->getOffset();
|
271 |
|
|
$this->assertEqual($expected, $value, "The current offset should be $expected, found $value.");
|
272 |
|
|
|
273 |
|
|
// Create date object from datetime string and convert it to a local date.
|
274 |
|
|
$input = '1970-01-01 00:00:00';
|
275 |
|
|
$timezone = 'UTC';
|
276 |
|
|
$date = new dateObject($input, $timezone);
|
277 |
|
|
$value = $date->format('c');
|
278 |
|
|
$expected = '1970-01-01T00:00:00+00:00';
|
279 |
|
|
$this->assertEqual($expected, $value, "Test new dateObject('$input', '$timezone'): should be $expected, found $value.");
|
280 |
|
|
|
281 |
|
|
$expected = 'UTC';
|
282 |
|
|
$value = $date->getTimeZone()->getName();
|
283 |
|
|
$this->assertEqual($expected, $value, "The current timezone is $value: should be $expected.");
|
284 |
|
|
$expected = 0;
|
285 |
|
|
$value = $date->getOffset();
|
286 |
|
|
$this->assertEqual($expected, $value, "The current offset is $value: should be $expected.");
|
287 |
|
|
|
288 |
|
|
$timezone = 'America/Los_Angeles';
|
289 |
|
|
$date->setTimezone(new DateTimeZone($timezone));
|
290 |
|
|
$value = $date->format('c');
|
291 |
|
|
$expected = '1969-12-31T16:00:00-08:00';
|
292 |
|
|
$this->assertEqual($expected, $value, "Test \$date->setTimezone(new DateTimeZone($timezone)): should be $expected, found $value.");
|
293 |
|
|
|
294 |
|
|
$expected = 'America/Los_Angeles';
|
295 |
|
|
$value = $date->getTimeZone()->getName();
|
296 |
|
|
$this->assertEqual($expected, $value, "The current timezone should be $expected, found $value.");
|
297 |
|
|
$expected = '-28800';
|
298 |
|
|
$value = $date->getOffset();
|
299 |
|
|
$this->assertEqual($expected, $value, "The current offset should be $expected, found $value.");
|
300 |
|
|
|
301 |
|
|
// Convert the local version of a datetime string to UTC.
|
302 |
|
|
$input = '1969-12-31 16:00:00';
|
303 |
|
|
$timezone = 'America/Los_Angeles';
|
304 |
|
|
$date = new dateObject($input, $timezone);
|
305 |
|
|
$offset = $date->getOffset();
|
306 |
|
|
$value = $date->format('c');
|
307 |
|
|
$expected = '1969-12-31T16:00:00-08:00';
|
308 |
|
|
$this->assertEqual($expected, $value, "Test new dateObject('$input', '$timezone'): should be $expected, found $value.");
|
309 |
|
|
|
310 |
|
|
$expected = 'America/Los_Angeles';
|
311 |
|
|
$value = $date->getTimeZone()->getName();
|
312 |
|
|
$this->assertEqual($expected, $value, "The current timezone should be $expected, found $value.");
|
313 |
|
|
$expected = '-28800';
|
314 |
|
|
$value = $date->getOffset();
|
315 |
|
|
$this->assertEqual($expected, $value, "The current offset should be $expected, found $value.");
|
316 |
|
|
|
317 |
|
|
$timezone = 'UTC';
|
318 |
|
|
$date->setTimezone(new DateTimeZone($timezone));
|
319 |
|
|
$value = $date->format('c');
|
320 |
|
|
$expected = '1970-01-01T00:00:00+00:00';
|
321 |
|
|
$this->assertEqual($expected, $value, "Test \$date->setTimezone(new DateTimeZone($timezone)): should be $expected, found $value.");
|
322 |
|
|
|
323 |
|
|
$expected = 'UTC';
|
324 |
|
|
$value = $date->getTimeZone()->getName();
|
325 |
|
|
$this->assertEqual($expected, $value, "The current timezone should be $expected, found $value.");
|
326 |
|
|
$expected = '0';
|
327 |
|
|
$value = $date->getOffset();
|
328 |
|
|
$this->assertEqual($expected, $value, "The current offset should be $expected, found $value.");
|
329 |
|
|
|
330 |
|
|
// Create year-only date.
|
331 |
|
|
$input = '2009';
|
332 |
|
|
$timezone = NULL;
|
333 |
|
|
$format = 'Y';
|
334 |
|
|
$date = new dateObject($input, $timezone, $format);
|
335 |
|
|
$value = $date->format('Y');
|
336 |
|
|
$expected = '2009';
|
337 |
|
|
$this->assertEqual($expected, $value, "Test new dateObject($input, $timezone, $format): should be $expected, found $value.");
|
338 |
|
|
|
339 |
|
|
// Create month and year-only date.
|
340 |
|
|
$input = '2009-10';
|
341 |
|
|
$timezone = NULL;
|
342 |
|
|
$format = 'Y-m';
|
343 |
|
|
$date = new dateObject($input, $timezone, $format);
|
344 |
|
|
$value = $date->format('Y-m');
|
345 |
|
|
$expected = '2009-10';
|
346 |
|
|
$this->assertEqual($expected, $value, "Test new dateObject($input, $timezone, $format): should be $expected, found $value.");
|
347 |
|
|
|
348 |
|
|
// Create time-only date.
|
349 |
|
|
$input = '0000-00-00T10:30:00';
|
350 |
|
|
$timezone = NULL;
|
351 |
|
|
$format = 'Y-m-d\TH:i:s';
|
352 |
|
|
$date = new dateObject($input, $timezone, $format);
|
353 |
|
|
$value = $date->format('H:i:s');
|
354 |
|
|
$expected = '10:30:00';
|
355 |
|
|
$this->assertEqual($expected, $value, "Test new dateObject($input, $timezone, $format): should be $expected, found $value.");
|
356 |
|
|
|
357 |
|
|
// Create time-only date.
|
358 |
|
|
$input = '10:30:00';
|
359 |
|
|
$timezone = NULL;
|
360 |
|
|
$format = 'H:i:s';
|
361 |
|
|
$date = new dateObject($input, $timezone, $format);
|
362 |
|
|
$value = $date->format('H:i:s');
|
363 |
|
|
$expected = '10:30:00';
|
364 |
|
|
$this->assertEqual($expected, $value, "Test new dateObject($input, $timezone, $format): should be $expected, found $value.");
|
365 |
|
|
|
366 |
|
|
// Test date ranges.
|
367 |
|
|
$valid = array(
|
368 |
|
|
'-20:+20',
|
369 |
|
|
'-1:+0',
|
370 |
|
|
'-10:-5',
|
371 |
|
|
'2000:2020',
|
372 |
|
|
'-10:2010',
|
373 |
|
|
'1980:-10',
|
374 |
|
|
'1920:+20',
|
375 |
|
|
);
|
376 |
|
|
$invalid = array(
|
377 |
|
|
'abc',
|
378 |
|
|
'abc:+20',
|
379 |
|
|
'1920:+20a',
|
380 |
|
|
'+-20:+-30',
|
381 |
|
|
'12:12',
|
382 |
|
|
'0:+20',
|
383 |
|
|
'-20:0',
|
384 |
|
|
);
|
385 |
|
|
foreach ($valid as $range) {
|
386 |
|
|
$this->assertTrue(date_range_valid($range), "$range recognized as a valid date range.");
|
387 |
|
|
}
|
388 |
|
|
foreach ($invalid as $range) {
|
389 |
|
|
$this->assertFalse(date_range_valid($range), "$range recognized as an invalid date range.");
|
390 |
|
|
}
|
391 |
|
|
|
392 |
|
|
// Test for invalid month names when we are using a short version of the month
|
393 |
|
|
$input = '23 abc 2012';
|
394 |
|
|
$timezone = NULL;
|
395 |
|
|
$format = 'd M Y';
|
396 |
|
|
$date = new dateObject($input, $timezone, $format);
|
397 |
|
|
$this->assertNotEqual(count($date->errors), 0, '23 abc 2012 should be an invalid date');
|
398 |
|
|
|
399 |
|
|
}
|
400 |
|
|
|
401 |
|
|
/**
|
402 |
|
|
* @todo.
|
403 |
|
|
*/
|
404 |
|
|
public function tearDown() {
|
405 |
|
|
variable_del('date_first_day');
|
406 |
|
|
variable_del('date_api_use_iso8601');
|
407 |
|
|
parent::tearDown();
|
408 |
|
|
}
|
409 |
|
|
} |