Skip to content

Commit 1b7f456

Browse files
authored
ext/date: Fix tests (#18891)
1 parent 171501b commit 1b7f456

File tree

3 files changed

+33
-32
lines changed

3 files changed

+33
-32
lines changed

ext/date/tests/bug33536.phpt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ Bug #33456 (strtotime defaults to now even on non time string)
44
<?php
55
date_default_timezone_set("GMT");
66
var_dump(strtotime("monkey"));
7-
print date("Y-m-d", strtotime("monkey")) ."\n";
8-
print date("Y-m-d", false) ."\n";
97
?>
108
--EXPECT--
119
bool(false)
12-
1970-01-01
13-
1970-01-01

ext/date/tests/bug44780.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
Bug #44780 (some time zone offsets not recognized by timezone_name_from_abbr)
33
--FILE--
44
<?php
5-
var_dump( timezone_name_from_abbr("", 5.5*3600, false) );
6-
var_dump( timezone_name_from_abbr("", 28800, false) );
5+
var_dump( timezone_name_from_abbr("", 5.5*3600, 0) );
6+
var_dump( timezone_name_from_abbr("", 28800, 0) );
77
?>
88
--EXPECT--
99
string(12) "Asia/Kolkata"

ext/date/tests/date_sun_info_003.phpt

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,38 +5,43 @@ edgarsandi - <edgar.r.sandi@gmail.com>
55
--FILE--
66
<?php
77
date_default_timezone_set('America/Sao_Paulo');
8-
$sun_info = date_sun_info(strtotime("2015-01-12 00:00:00 UTC"), 89.00, 1.00);
9-
foreach ($sun_info as $key => $elem ) {
10-
echo "$key: " . date("H:i:s", $elem) . "\n";
8+
9+
function print_sun_info(string $date) {
10+
echo $date, "\n";
11+
$sun_info = date_sun_info(strtotime($date), 89.00, 1.00);
12+
foreach ($sun_info as $key => $elem ) {
13+
echo "$key: " . match ($elem) {
14+
true => 'always',
15+
false => 'never',
16+
default => date("H:i:s", $elem),
17+
} . "\n";
18+
}
1119
}
1220

21+
print_sun_info("2015-01-12 00:00:00 UTC");
1322
echo "\n";
23+
print_sun_info("2015-09-12 00:00:00 UTC");
1424

15-
$sun_info = date_sun_info(strtotime("2015-09-12 00:00:00 UTC"), 89.00, 1.00);
16-
foreach ($sun_info as $key => $elem ) {
17-
echo "$key: " . date("H:i:s", $elem) . "\n";
18-
}
19-
20-
echo "Done\n";
2125
?>
2226
--EXPECT--
23-
sunrise: 21:00:00
24-
sunset: 21:00:00
27+
2015-01-12 00:00:00 UTC
28+
sunrise: never
29+
sunset: never
2530
transit: 10:03:48
26-
civil_twilight_begin: 21:00:00
27-
civil_twilight_end: 21:00:00
28-
nautical_twilight_begin: 21:00:00
29-
nautical_twilight_end: 21:00:00
30-
astronomical_twilight_begin: 21:00:00
31-
astronomical_twilight_end: 21:00:00
31+
civil_twilight_begin: never
32+
civil_twilight_end: never
33+
nautical_twilight_begin: never
34+
nautical_twilight_end: never
35+
astronomical_twilight_begin: never
36+
astronomical_twilight_end: never
3237

33-
sunrise: 21:00:01
34-
sunset: 21:00:01
38+
2015-09-12 00:00:00 UTC
39+
sunrise: always
40+
sunset: always
3541
transit: 08:52:44
36-
civil_twilight_begin: 21:00:01
37-
civil_twilight_end: 21:00:01
38-
nautical_twilight_begin: 21:00:01
39-
nautical_twilight_end: 21:00:01
40-
astronomical_twilight_begin: 21:00:01
41-
astronomical_twilight_end: 21:00:01
42-
Done
42+
civil_twilight_begin: always
43+
civil_twilight_end: always
44+
nautical_twilight_begin: always
45+
nautical_twilight_end: always
46+
astronomical_twilight_begin: always
47+
astronomical_twilight_end: always

0 commit comments

Comments
 (0)