parent
a54b04118d
commit
0033a243d0
14 changed files with 452 additions and 12 deletions
@ -0,0 +1,2 @@ |
||||
<?php |
||||
list($micro, $time) = explode(" ", microtime()); |
||||
@ -0,0 +1,14 @@ |
||||
--TEST-- |
||||
strlen |
||||
--FILE-- |
||||
<?php |
||||
list($micro, $time) = explode(" ", microtime()); |
||||
var_dump($micro, $time); |
||||
|
||||
list(, $time) = explode(" ", microtime()); |
||||
var_dump($time); |
||||
?> |
||||
--EXPECTF-- |
||||
string(%d) "%s" |
||||
string(%d) "%s" |
||||
string(%d) "%s" |
||||
@ -0,0 +1,26 @@ |
||||
--TEST-- |
||||
Test that the Directory extension constants are correctly defined. |
||||
--SKIPIF-- |
||||
<?php |
||||
if (substr(PHP_OS, 0, 3) == 'WIN') { |
||||
die('skip.. Not valid for Windows'); |
||||
} |
||||
?> |
||||
--FILE-- |
||||
<?php |
||||
|
||||
echo DIRECTORY_SEPARATOR; |
||||
|
||||
echo "\n"; |
||||
|
||||
echo PATH_SEPARATOR; |
||||
|
||||
echo "\n"; |
||||
|
||||
echo "done"; |
||||
|
||||
?> |
||||
--EXPECT-- |
||||
/ |
||||
: |
||||
done |
||||
@ -0,0 +1,42 @@ |
||||
--TEST-- |
||||
Bug #25378 (unserialize() crashes with invalid data) |
||||
--FILE-- |
||||
<?php |
||||
var_dump(unserialize('b:0;')); |
||||
var_dump(unserialize('b:1;')); |
||||
var_dump(unserialize('i:823;')); |
||||
var_dump(unserialize('s:0:"";')); |
||||
var_dump(unserialize('s:3:"foo";')); |
||||
var_dump(unserialize('a:1:{i:0;s:2:"12";}')); |
||||
var_dump(unserialize('a:2:{i:0;a:0:{}i:1;a:0:{}}')); |
||||
var_dump(unserialize('a:3:{i:0;s:3:"foo";i:1;s:3:"bar";i:2;s:3:"baz";}')); |
||||
var_dump(unserialize('O:8:"stdClass":0:{}')); |
||||
?> |
||||
--EXPECTF-- |
||||
bool(false) |
||||
bool(true) |
||||
int(823) |
||||
string(0) "" |
||||
string(3) "foo" |
||||
array(1) { |
||||
[0]=> |
||||
string(2) "12" |
||||
} |
||||
array(2) { |
||||
[0]=> |
||||
array(0) { |
||||
} |
||||
[1]=> |
||||
array(0) { |
||||
} |
||||
} |
||||
array(3) { |
||||
[0]=> |
||||
string(3) "foo" |
||||
[1]=> |
||||
string(3) "bar" |
||||
[2]=> |
||||
string(3) "baz" |
||||
} |
||||
object(stdClass)#%d (0) { |
||||
} |
||||
@ -0,0 +1,33 @@ |
||||
--TEST-- |
||||
microtime() function |
||||
--SKIPIF-- |
||||
<?php |
||||
if (!function_exists('microtime')) die('skip microtime() not available'); |
||||
?> |
||||
--FILE-- |
||||
<?php |
||||
$passed = 0; |
||||
$failed = 0; |
||||
$last_m = 0; |
||||
$last_t = 0; |
||||
$result = ''; |
||||
|
||||
set_time_limit(0); |
||||
|
||||
for ($i=1;$i<=100000;$i++) { |
||||
list($micro,$time)=explode(" ",microtime()); |
||||
if ($time > $last_t || ($time == $last_t && $micro >= $last_m)) { |
||||
$passed++; |
||||
} else if ($failed++ <=10) { |
||||
$result .= sprintf('%06d', $i).": $time $micro < $last_t $last_m\n"; |
||||
} |
||||
$last_m = $micro; |
||||
$last_t = $time; |
||||
} |
||||
echo "Passed: $passed\n"; |
||||
echo "Failed: $failed\n"; |
||||
echo $result; |
||||
?> |
||||
--EXPECT-- |
||||
Passed: 100000 |
||||
Failed: 0 |
||||
@ -0,0 +1,34 @@ |
||||
--TEST-- |
||||
Bug #38524 (strptime() does not initialize the internal date storage structure) |
||||
--SKIPIF-- |
||||
<?php |
||||
if (!function_exists('strptime')) echo "SKIP"; |
||||
if (str_contains(PHP_OS, 'FreeBSD')) { |
||||
die("skip strptime() behaves differently on FreeBSD"); |
||||
} |
||||
?> |
||||
--FILE-- |
||||
<?php |
||||
var_dump(strptime('2006-08-20', '%Y-%m-%d')); |
||||
?> |
||||
--EXPECTF-- |
||||
array(9) { |
||||
["tm_sec"]=> |
||||
int(0) |
||||
["tm_min"]=> |
||||
int(0) |
||||
["tm_hour"]=> |
||||
int(0) |
||||
["tm_mday"]=> |
||||
int(20) |
||||
["tm_mon"]=> |
||||
int(7) |
||||
["tm_year"]=> |
||||
int(106) |
||||
["tm_wday"]=> |
||||
int(0) |
||||
["tm_yday"]=> |
||||
int(%d) |
||||
["unparsed"]=> |
||||
string(0) "" |
||||
} |
||||
@ -0,0 +1,19 @@ |
||||
--TEST-- |
||||
Bug #60222 (time_nanosleep() does validate input params) |
||||
--FILE-- |
||||
<?php |
||||
try { |
||||
time_nanosleep(-1, 0); |
||||
} catch (ValueError $exception) { |
||||
echo $exception->getMessage() . "\n"; |
||||
} |
||||
|
||||
try { |
||||
time_nanosleep(0, -1); |
||||
} catch (ValueError $exception) { |
||||
echo $exception->getMessage() . "\n"; |
||||
} |
||||
?> |
||||
--EXPECT-- |
||||
time_nanosleep(): Argument #1 ($seconds) must be greater than or equal to 0 |
||||
time_nanosleep(): Argument #2 ($nanoseconds) must be greater than or equal to 0 |
||||
@ -0,0 +1,33 @@ |
||||
--TEST-- |
||||
idate() function |
||||
--FILE-- |
||||
<?php |
||||
date_default_timezone_set('GMT0'); |
||||
$tmp = "UYozymndjHGhgistwNLBIW"; |
||||
for($a = 0;$a < strlen($tmp); $a++){ |
||||
echo $tmp[$a], ': ', idate($tmp[$a], 1043324459)."\n"; |
||||
} |
||||
?> |
||||
--EXPECT-- |
||||
U: 1043324459 |
||||
Y: 2003 |
||||
o: 2003 |
||||
z: 22 |
||||
y: 3 |
||||
m: 1 |
||||
n: 1 |
||||
d: 23 |
||||
j: 23 |
||||
H: 12 |
||||
G: 12 |
||||
h: 12 |
||||
g: 12 |
||||
i: 20 |
||||
s: 59 |
||||
t: 31 |
||||
w: 4 |
||||
N: 4 |
||||
L: 0 |
||||
B: 556 |
||||
I: 0 |
||||
W: 4 |
||||
@ -0,0 +1,23 @@ |
||||
--TEST-- |
||||
idate() function: ISO Day-of-Week and ISO Year |
||||
--FILE-- |
||||
<?php |
||||
date_default_timezone_set('UTC'); |
||||
$tmp = "UwNW"; |
||||
for ($a = 0; $a < strlen($tmp); $a++){ |
||||
echo $tmp[$a], ': ', idate($tmp[$a], 1041808859), "\n"; |
||||
} |
||||
$tmp = "UYoW"; |
||||
for ($a = 0; $a < strlen($tmp); $a++){ |
||||
echo $tmp[$a], ': ', idate($tmp[$a], 1072912859), "\n"; |
||||
} |
||||
?> |
||||
--EXPECT-- |
||||
U: 1041808859 |
||||
w: 0 |
||||
N: 7 |
||||
W: 1 |
||||
U: 1072912859 |
||||
Y: 2003 |
||||
o: 2004 |
||||
W: 1 |
||||
@ -0,0 +1,95 @@ |
||||
--TEST-- |
||||
Test strptime() function : basic functionality |
||||
--SKIPIF-- |
||||
<?php |
||||
if (!function_exists('strptime')) { |
||||
die("skip - strptime() function not available in this build"); |
||||
} |
||||
if (PHP_OS_FAMILY == 'Darwin' || PHP_OS_FAMILY == 'BSD') { |
||||
die("skip strptime() behaves differently on Darwin/BSD"); |
||||
} |
||||
if (!@strftime('%Z')) die('skip strftime does not support %Z'); |
||||
?> |
||||
--FILE-- |
||||
<?php |
||||
$orig = setlocale(LC_ALL, 'C'); |
||||
date_default_timezone_set("GMT"); |
||||
|
||||
echo "*** Testing strptime() : basic functionality ***\n"; |
||||
|
||||
$input = "10:00:00 AM July 2 1963"; |
||||
$tstamp = strtotime($input); |
||||
|
||||
$str = strftime("%r %B%e %Y %Z", $tstamp); |
||||
var_dump(strptime($str, '%H:%M:%S %p %B %d %Y')); |
||||
|
||||
$str = strftime("%T %D", $tstamp); |
||||
var_dump(strptime($str, '%H:%M:%S %m/%d/%y')); |
||||
|
||||
$str = strftime("%A %B %e %R", $tstamp); |
||||
var_dump(strptime($str, '%A %B %e %R')); |
||||
|
||||
setlocale(LC_ALL, $orig); |
||||
?> |
||||
--EXPECTF-- |
||||
*** Testing strptime() : basic functionality *** |
||||
array(9) { |
||||
["tm_sec"]=> |
||||
int(0) |
||||
["tm_min"]=> |
||||
int(0) |
||||
["tm_hour"]=> |
||||
int(10) |
||||
["tm_mday"]=> |
||||
int(2) |
||||
["tm_mon"]=> |
||||
int(6) |
||||
["tm_year"]=> |
||||
int(63) |
||||
["tm_wday"]=> |
||||
int(2) |
||||
["tm_yday"]=> |
||||
int(182) |
||||
["unparsed"]=> |
||||
string(4) " GMT" |
||||
} |
||||
array(9) { |
||||
["tm_sec"]=> |
||||
int(0) |
||||
["tm_min"]=> |
||||
int(0) |
||||
["tm_hour"]=> |
||||
int(10) |
||||
["tm_mday"]=> |
||||
int(2) |
||||
["tm_mon"]=> |
||||
int(6) |
||||
["tm_year"]=> |
||||
int(163) |
||||
["tm_wday"]=> |
||||
int(1) |
||||
["tm_yday"]=> |
||||
int(182) |
||||
["unparsed"]=> |
||||
string(0) "" |
||||
} |
||||
array(9) { |
||||
["tm_sec"]=> |
||||
int(0) |
||||
["tm_min"]=> |
||||
int(0) |
||||
["tm_hour"]=> |
||||
int(10) |
||||
["tm_mday"]=> |
||||
int(2) |
||||
["tm_mon"]=> |
||||
int(6) |
||||
["tm_year"]=> |
||||
int(0) |
||||
["tm_wday"]=> |
||||
int(2) |
||||
["tm_yday"]=> |
||||
int(182) |
||||
["unparsed"]=> |
||||
string(0) "" |
||||
} |
||||
@ -0,0 +1,25 @@ |
||||
--TEST-- |
||||
Test localtime() function : error conditions |
||||
--SKIPIF-- |
||||
<?php |
||||
if (!function_exists('strptime')) { |
||||
echo "SKIP strptime function not available in build"; |
||||
} |
||||
?> |
||||
--FILE-- |
||||
<?php |
||||
//Set the default time zone |
||||
date_default_timezone_set("Europe/London"); |
||||
|
||||
echo "*** Testing strptime() : error conditions ***\n"; |
||||
|
||||
echo "\n-- Testing strptime() function on failure --\n"; |
||||
$format = '%b %d %Y %H:%M:%S'; |
||||
var_dump( strptime('foo', $format) ); |
||||
|
||||
?> |
||||
--EXPECTF-- |
||||
*** Testing strptime() : error conditions *** |
||||
|
||||
-- Testing strptime() function on failure -- |
||||
bool(false) |
||||
@ -0,0 +1,69 @@ |
||||
--TEST-- |
||||
Test strptime() function : basic functionality |
||||
--SKIPIF-- |
||||
<?php |
||||
if (!function_exists('strptime')) { |
||||
die("skip - strptime() function not available in this build"); |
||||
} |
||||
if (!@strftime('%Z')) die('skip strftime does not support %Z'); |
||||
?> |
||||
--FILE-- |
||||
<?php |
||||
$orig = setlocale(LC_ALL, 'C'); |
||||
date_default_timezone_set("GMT"); |
||||
putenv("TZ=GMT"); |
||||
|
||||
echo "*** Testing strptime() : basic functionality ***\n"; |
||||
|
||||
$input = "10:01:20 AM July 2 1963"; |
||||
$tstamp = strtotime($input); |
||||
|
||||
$str = strftime("%r %B%e %Y %Z", $tstamp); |
||||
$res = strptime($str, '%H:%M:%S %p %B %d %Y %Z'); |
||||
var_dump($res["tm_sec"]); |
||||
var_dump($res["tm_min"]); |
||||
var_dump($res["tm_hour"]); |
||||
var_dump($res["tm_mday"]); |
||||
var_dump($res["tm_mon"]); |
||||
var_dump($res["tm_year"]); |
||||
|
||||
$str = strftime("%T %D", $tstamp); |
||||
$res = strptime($str, '%H:%M:%S %m/%d/%y'); |
||||
var_dump($res["tm_sec"]); |
||||
var_dump($res["tm_min"]); |
||||
var_dump($res["tm_hour"]); |
||||
var_dump($res["tm_mday"]); |
||||
var_dump($res["tm_mon"]); |
||||
var_dump($res["tm_year"]); |
||||
|
||||
$str = strftime("%A %B %e %R", $tstamp); |
||||
$res = strptime($str, '%A %B %e %R'); |
||||
var_dump($res["tm_sec"]); |
||||
var_dump($res["tm_min"]); |
||||
var_dump($res["tm_hour"]); |
||||
var_dump($res["tm_mday"]); |
||||
var_dump($res["tm_mon"]); |
||||
var_dump($res["tm_year"]); |
||||
|
||||
setlocale(LC_ALL, $orig); |
||||
?> |
||||
--EXPECTF-- |
||||
*** Testing strptime() : basic functionality *** |
||||
int(20) |
||||
int(1) |
||||
int(10) |
||||
int(2) |
||||
int(6) |
||||
int(63) |
||||
int(20) |
||||
int(1) |
||||
int(10) |
||||
int(2) |
||||
int(6) |
||||
int(163) |
||||
int(0) |
||||
int(1) |
||||
int(10) |
||||
int(2) |
||||
int(6) |
||||
int(0) |
||||
Loading…
Reference in new issue