Skip to content

Commit a9a6628

Browse files
committed
Fix 32bit tests
1 parent 0bc6fd8 commit a9a6628

9 files changed

+173
-37
lines changed

ext/date/tests/bug41523.phpt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ var_dump( $dt = new DateTime('0000-00-00 00:00:00') );
1212
echo $dt->format( DateTime::ISO8601 ), "\n";
1313

1414
?>
15-
--EXPECT--
15+
--EXPECTF--
1616
array(12) {
1717
["year"]=>
1818
int(0)
@@ -43,6 +43,8 @@ array(12) {
4343
["is_localtime"]=>
4444
bool(false)
4545
}
46+
47+
Warning: strtotime(): Epoch doesn't fit in a PHP integer in %s on line %d
4648
bool(false)
4749
object(DateTime)#1 (3) {
4850
["date"]=>

ext/date/tests/bug52062.phpt

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ date.timezone=UTC
1010
<?php
1111
$d = new DateTime('@100000000000');
1212
var_dump($d->format('Y-m-d H:i:s U'));
13-
var_dump($d->getTimestamp());
13+
try {
14+
var_dump($d->getTimestamp());
15+
} catch (\ValueError $e) {
16+
echo $e->getMessage() . \PHP_EOL;
17+
}
1418
var_dump($d->format('U'));
1519

1620
try {
@@ -19,16 +23,20 @@ try {
1923
echo $e->getMessage(), "\n";
2024
}
2125
var_dump($d->format('Y-m-d H:i:s U'));
22-
var_dump($d->getTimestamp());
26+
try {
27+
var_dump($d->getTimestamp());
28+
} catch (\ValueError $e) {
29+
echo $e->getMessage() . \PHP_EOL;
30+
}
2331

2432
$i = new DateInterval('PT100000000000S');
2533
var_dump($i->format('%s'));
2634
?>
2735
--EXPECT--
2836
string(32) "5138-11-16 09:46:40 100000000000"
29-
bool(false)
37+
Epoch doesn't fit in a PHP integer
3038
string(12) "100000000000"
3139
DateTime::setTimestamp(): Argument #1 ($timestamp) must be of type int, float given
3240
string(32) "5138-11-16 09:46:40 100000000000"
33-
bool(false)
41+
Epoch doesn't fit in a PHP integer
3442
string(10) "1215752192"

ext/date/tests/gmdate_variation12.phpt

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
--TEST--
2-
Test gmdate() function : usage variation - Valid and invalid range of timestamp.
2+
Test gmdate() function : usage variation - Valid and invalid range of timestamp 32 bits.
3+
--SKIPIF--
4+
<?php
5+
if (PHP_INT_SIZE != 4) die('skip 32 bit only');
6+
?>
37
--FILE--
48
<?php
59
echo "*** Testing gmdate() : usage variation ***\n";
@@ -24,17 +28,19 @@ $timestamp = mktime(03, 14, 10, 1, 19, 2038);
2428
var_dump( gmdate(DATE_ISO8601, $timestamp) );
2529

2630
?>
27-
--EXPECTREGEX--
28-
\*\*\* Testing gmdate\(\) : usage variation \*\*\*
31+
--EXPECTF--
32+
*** Testing gmdate() : usage variation ***
2933

30-
-- Testing gmdate\(\) function with minimum range of timestamp --
31-
string\(24\) "1901-12-13T20:45:54\+0000"
34+
-- Testing gmdate() function with minimum range of timestamp --
35+
string(24) "1901-12-13T20:45:54+0000"
3236

33-
-- Testing gmdate\(\) function with less than the range of timestamp --
34-
string\(24\) "(1970-01-01T00:00:00\+0000|1901-12-13T20:45:50\+0000)"
37+
Warning: mktime(): Epoch doesn't fit in a PHP integer in %s on line %d
38+
-- Testing gmdate() function with less than the range of timestamp --
39+
string(24) "1970-01-01T00:00:00+0000"
3540

36-
-- Testing gmdate\(\) function with maximum range of timestamp --
37-
string\(24\) "2038-01-19T03:14:07\+0000"
41+
-- Testing gmdate() function with maximum range of timestamp --
42+
string(24) "2038-01-19T03:14:07+0000"
3843

39-
-- Testing gmdate\(\) function with greater than the range of timestamp --
40-
string\(24\) "(1970-01-01T00:00:00\+0000|2038-01-19T03:14:10\+0000)"
44+
Warning: mktime(): Epoch doesn't fit in a PHP integer in %s on line %d
45+
-- Testing gmdate() function with greater than the range of timestamp --
46+
string(24) "1970-01-01T00:00:00+0000"
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
--TEST--
2+
Test gmdate() function : usage variation - Valid and invalid range of timestamp 32 bits.
3+
--SKIPIF--
4+
<?php
5+
if (PHP_INT_SIZE == 4) die('skip 64 bit only');
6+
?>
7+
--FILE--
8+
<?php
9+
echo "*** Testing gmdate() : usage variation ***\n";
10+
11+
// Initialise all required variables
12+
date_default_timezone_set('UTC');
13+
14+
$timestamp = mktime(20, 45, 54, 12, 13, 1901);
15+
echo "\n-- Testing gmdate() function with minimum range of timestamp --\n";
16+
var_dump( gmdate(DATE_ISO8601, $timestamp) );
17+
18+
$timestamp = mktime(20, 45, 50, 12, 13, 1901);
19+
echo "\n-- Testing gmdate() function with less than the range of timestamp --\n";
20+
var_dump( gmdate(DATE_ISO8601, $timestamp) );
21+
22+
echo "\n-- Testing gmdate() function with maximum range of timestamp --\n";
23+
$timestamp = mktime(03, 14, 07, 1, 19, 2038);
24+
var_dump( gmdate(DATE_ISO8601, $timestamp) );
25+
26+
echo "\n-- Testing gmdate() function with greater than the range of timestamp --\n";
27+
$timestamp = mktime(03, 14, 10, 1, 19, 2038);
28+
var_dump( gmdate(DATE_ISO8601, $timestamp) );
29+
30+
?>
31+
--EXPECT--
32+
*** Testing gmdate() : usage variation ***
33+
34+
-- Testing gmdate() function with minimum range of timestamp --
35+
string(24) "1901-12-13T20:45:54+0000"
36+
37+
-- Testing gmdate() function with less than the range of timestamp --
38+
string(24) "1901-12-13T20:45:50+0000"
39+
40+
-- Testing gmdate() function with maximum range of timestamp --
41+
string(24) "2038-01-19T03:14:07+0000"
42+
43+
-- Testing gmdate() function with greater than the range of timestamp --
44+
string(24) "2038-01-19T03:14:10+0000"

ext/date/tests/gmmktime_variation9.phpt

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
--TEST--
2-
Test gmmktime() function : usage variation - Passing positive and negative float values to arguments.
2+
Test gmmktime() function : usage variation - Passing positive and negative float values to arguments 32 bits.
3+
--SKIPIF--
4+
<?php
5+
if (PHP_INT_SIZE != 4) die('skip 32 bit only');
6+
?>
37
--FILE--
48
<?php
59
echo "*** Testing gmmktime() : usage variation ***\n";
@@ -29,26 +33,36 @@ foreach($inputs as $key =>$value) {
2933
var_dump( gmmktime($hour, $min, $sec, $mon, $value, $value) );
3034
}
3135
?>
32-
--EXPECTREGEX--
33-
\*\*\* Testing gmmktime\(\) : usage variation \*\*\*
36+
--EXPECTF--
37+
*** Testing gmmktime() : usage variation ***
3438

3539
--float 123456--
36-
int\(1662595688\)
37-
int\(1225589768\)
38-
int\(1218306336\)
39-
(bool|int)\((false|325855037288)\)
40-
(bool|int)\((false|3844412784488)\)
40+
int(1662595688)
41+
int(1225589768)
42+
int(1218306336)
43+
44+
Warning: gmmktime(): Epoch doesn't fit in a PHP integer in %s on line %d
45+
bool(false)
46+
47+
Warning: gmmktime(): Epoch doesn't fit in a PHP integer in %s on line %d
48+
bool(false)
4149

4250
--float -123456--
43-
int\(773712488\)
44-
int\(1210775048\)
45-
int\(1218059424\)
46-
(bool|int)\((false|-323460834712)\)
47-
(bool|int)\((false|-3968710530712)\)
51+
int(773712488)
52+
int(1210775048)
53+
int(1218059424)
54+
55+
Warning: gmmktime(): Epoch doesn't fit in a PHP integer in %s on line %d
56+
bool(false)
57+
58+
Warning: gmmktime(): Epoch doesn't fit in a PHP integer in %s on line %d
59+
bool(false)
4860

4961
--float -10.5--
50-
int\(1218118088\)
51-
int\(1218181808\)
52-
int\(1218182870\)
53-
int\(1170922088\)
54-
(bool|int)\((false|-62465356312)\)
62+
int(1218118088)
63+
int(1218181808)
64+
int(1218182870)
65+
int(1170922088)
66+
67+
Warning: gmmktime(): Epoch doesn't fit in a PHP integer in %s on line %d
68+
bool(false)
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
--TEST--
2+
Test gmmktime() function : usage variation - Passing positive and negative float values to arguments 64 bits.
3+
--SKIPIF--
4+
<?php
5+
if (PHP_INT_SIZE == 4) die('skip 64 bit only');
6+
?>
7+
--FILE--
8+
<?php
9+
echo "*** Testing gmmktime() : usage variation ***\n";
10+
11+
//Initialise variables
12+
$hour = 8;
13+
$min = 8;
14+
$sec = 8;
15+
$mon = 8;
16+
$day = 8;
17+
$year = 2008;
18+
19+
$inputs = array(
20+
21+
'float 123456' => 123456,
22+
'float -123456' => -123456,
23+
'float -10.5' => -10.5,
24+
);
25+
26+
// loop through each element of the array for min
27+
foreach($inputs as $key =>$value) {
28+
echo "\n--$key--\n";
29+
var_dump( gmmktime($value, $min, $sec, $mon, $day, $year) );
30+
var_dump( gmmktime($hour, $value, $sec, $mon, $day, $year) );
31+
var_dump( gmmktime($hour, $min, $value, $mon, $day, $year) );
32+
var_dump( gmmktime($hour, $min, $sec, $value, $day, $year) );
33+
var_dump( gmmktime($hour, $min, $sec, $mon, $value, $value) );
34+
}
35+
?>
36+
--EXPECT--
37+
*** Testing gmmktime() : usage variation ***
38+
39+
--float 123456--
40+
int(1662595688)
41+
int(1225589768)
42+
int(1218306336)
43+
int(325855037288)
44+
int(3844412784488)
45+
46+
--float -123456--
47+
int(773712488)
48+
int(1210775048)
49+
int(1218059424)
50+
int(-323460834712)
51+
int(-3968710530712)
52+
53+
--float -10.5--
54+
int(1218118088)
55+
int(1218181808)
56+
int(1218182870)
57+
int(1170922088)
58+
int(-62465356312)

ext/date/tests/mktime-3.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ foreach ($tzs as $tz) {
1414
date_default_timezone_set($tz);
1515
foreach ($years as $year) {
1616
printf("Y: %4d - ", $year);
17-
$ret = mktime(1, 1, 1, 1, 1, $year);
17+
$ret = @mktime(1, 1, 1, 1, 1, $year);
1818
if ($ret == FALSE) {
1919
echo "out of range\n";
2020
} else {

ext/date/tests/strtotime-mysql.phpt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ foreach($d as $date) {
2121
}
2222
}
2323
?>
24-
--EXPECT--
24+
--EXPECTF--
2525
string(31) "Fri, 23 May 1997 09:15:28 +0000"
2626
string(31) "Sun, 31 Dec 2000 18:58:59 +0000"
27+
28+
Warning: strtotime(): Epoch doesn't fit in a PHP integer in %s on line %d
2729
bool(false)

ext/date/tests/strtotime3.phpt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ foreach ($strs as $str) {
4444
}
4545

4646
?>
47-
--EXPECT--
47+
--EXPECTF--
4848
bool(false)
4949
bool(false)
5050
string(31) "Thu, 15 Jun 2006 00:00:00 +0100"
@@ -53,6 +53,8 @@ bool(false)
5353
string(31) "Fri, 16 Jun 2006 23:49:12 +0100"
5454
bool(false)
5555
string(31) "Fri, 16 Jun 2006 02:22:00 +0100"
56+
57+
Warning: strtotime(): Epoch doesn't fit in a PHP integer in %s on line %d
5658
bool(false)
5759
string(31) "Fri, 16 Jun 2006 02:22:33 +0100"
5860
bool(false)

0 commit comments

Comments
 (0)