mirror of
https://github.com/php/php-src.git
synced 2024-11-25 19:05:31 +08:00
add new tests
This commit is contained in:
parent
cf64728899
commit
36d66521c9
15
ext/standard/tests/file/get_current_user.phpt
Normal file
15
ext/standard/tests/file/get_current_user.phpt
Normal file
@ -0,0 +1,15 @@
|
||||
--TEST--
|
||||
get_current_user() tests
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
var_dump(get_current_user("blah"));
|
||||
var_dump(get_current_user());
|
||||
|
||||
echo "Done\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: Wrong parameter count for get_current_user() in %s on line %d
|
||||
NULL
|
||||
string(%d) "%s"
|
||||
Done
|
61
ext/standard/tests/file/magic_quotes.phpt
Normal file
61
ext/standard/tests/file/magic_quotes.phpt
Normal file
@ -0,0 +1,61 @@
|
||||
--TEST--
|
||||
various magic quotes tests
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$filename = dirname(__FILE__)."/magic_quotes.dat";
|
||||
|
||||
var_dump(get_magic_quotes_runtime());
|
||||
var_dump(get_magic_quotes_runtime("blah"));
|
||||
|
||||
file_put_contents($filename, "some'content'here\"and}there");
|
||||
|
||||
var_dump(set_magic_quotes_runtime(true));
|
||||
var_dump(get_magic_quotes_runtime());
|
||||
var_dump(set_magic_quotes_runtime(-1));
|
||||
var_dump(get_magic_quotes_runtime());
|
||||
|
||||
var_dump(file_get_contents($filename));
|
||||
|
||||
var_dump(set_magic_quotes_runtime(0));
|
||||
var_dump(get_magic_quotes_runtime());
|
||||
|
||||
var_dump(file_get_contents($filename));
|
||||
|
||||
var_dump(set_magic_quotes_runtime(1));
|
||||
var_dump(get_magic_quotes_runtime());
|
||||
|
||||
file_put_contents($filename, "some'content'here\"and}there");
|
||||
|
||||
var_dump(file_get_contents($filename));
|
||||
|
||||
var_dump(set_magic_quotes_runtime(0));
|
||||
var_dump(set_magic_quotes_runtime());
|
||||
var_dump(get_magic_quotes_runtime());
|
||||
|
||||
var_dump(file_get_contents($filename));
|
||||
|
||||
|
||||
@unlink($filename);
|
||||
|
||||
echo "Done\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
int(0)
|
||||
int(0)
|
||||
bool(true)
|
||||
int(1)
|
||||
bool(true)
|
||||
int(1)
|
||||
string(30) "some\'content\'here\"and}there"
|
||||
bool(true)
|
||||
int(0)
|
||||
string(27) "some'content'here"and}there"
|
||||
bool(true)
|
||||
int(1)
|
||||
string(30) "some\'content\'here\"and}there"
|
||||
bool(true)
|
||||
bool(false)
|
||||
int(0)
|
||||
string(27) "some'content'here"and}there"
|
||||
Done
|
49
ext/standard/tests/file/touch.phpt
Normal file
49
ext/standard/tests/file/touch.phpt
Normal file
@ -0,0 +1,49 @@
|
||||
--TEST--
|
||||
touch() tests
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$filename = dirname(__FILE__)."/touch.dat";
|
||||
|
||||
var_dump(touch());
|
||||
var_dump(touch($filename));
|
||||
var_dump(filemtime($filename));
|
||||
@unlink($filename);
|
||||
var_dump(touch($filename, 101));
|
||||
var_dump(filemtime($filename));
|
||||
|
||||
@unlink($filename);
|
||||
var_dump(touch($filename, -1));
|
||||
var_dump(filemtime($filename));
|
||||
|
||||
@unlink($filename);
|
||||
var_dump(touch($filename, 100, 100));
|
||||
var_dump(filemtime($filename));
|
||||
|
||||
@unlink($filename);
|
||||
var_dump(touch($filename, 100, -100));
|
||||
var_dump(filemtime($filename));
|
||||
|
||||
var_dump(touch("/no/such/file/or/directory"));
|
||||
|
||||
@unlink($filename);
|
||||
|
||||
echo "Done\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: Wrong parameter count for touch() in %s on line %d
|
||||
NULL
|
||||
bool(true)
|
||||
int(%d)
|
||||
bool(true)
|
||||
int(101)
|
||||
bool(true)
|
||||
int(-1)
|
||||
bool(true)
|
||||
int(100)
|
||||
bool(true)
|
||||
int(100)
|
||||
|
||||
Warning: touch(): Unable to create file /no/such/file/or/directory because No such file or directory in %s on line %d
|
||||
bool(false)
|
||||
Done
|
43
ext/standard/tests/general_functions/error_get_last.phpt
Normal file
43
ext/standard/tests/general_functions/error_get_last.phpt
Normal file
@ -0,0 +1,43 @@
|
||||
--TEST--
|
||||
error_get_last() tests
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
var_dump(error_get_last());
|
||||
var_dump(error_get_last(true));
|
||||
var_dump(error_get_last());
|
||||
|
||||
$a = $b;
|
||||
|
||||
var_dump(error_get_last());
|
||||
|
||||
echo "Done\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
NULL
|
||||
|
||||
Warning: Wrong parameter count for error_get_last() in %s on line %d
|
||||
NULL
|
||||
array(4) {
|
||||
["type"]=>
|
||||
int(2)
|
||||
["message"]=>
|
||||
string(42) "Wrong parameter count for error_get_last()"
|
||||
["file"]=>
|
||||
string(%d) "%s"
|
||||
["line"]=>
|
||||
int(%d)
|
||||
}
|
||||
|
||||
Notice: Undefined variable: b in %s on line %d
|
||||
array(4) {
|
||||
["type"]=>
|
||||
int(8)
|
||||
["message"]=>
|
||||
string(21) "Undefined variable: b"
|
||||
["file"]=>
|
||||
string(%d) "%s"
|
||||
["line"]=>
|
||||
int(%d)
|
||||
}
|
||||
Done
|
78
ext/standard/tests/general_functions/import_request.phpt
Normal file
78
ext/standard/tests/general_functions/import_request.phpt
Normal file
@ -0,0 +1,78 @@
|
||||
--TEST--
|
||||
import_request_variables() tests
|
||||
--GET--
|
||||
a=1&b=heh&c=3&d[]=5&GLOBALS=test&1=hm
|
||||
--POST--
|
||||
ap=25&bp=test&cp=blah3&dp[]=ar
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
var_dump(import_request_variables());
|
||||
var_dump(import_request_variables(""));
|
||||
var_dump(import_request_variables("", ""));
|
||||
|
||||
var_dump(import_request_variables("g", ""));
|
||||
var_dump($a, $b, $c, $ap);
|
||||
|
||||
var_dump(import_request_variables("g", "g_"));
|
||||
var_dump($g_a, $g_b, $g_c, $g_ap, $g_1);
|
||||
|
||||
var_dump(import_request_variables("GP", "i_"));
|
||||
var_dump($i_a, $i_b, $i_c, $i_ap, $i_bp, $i_cp, $i_dp);
|
||||
|
||||
var_dump(import_request_variables("gGg", "r_"));
|
||||
var_dump($r_a, $r_b, $r_c, $r_ap);
|
||||
|
||||
echo "Done\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: Wrong parameter count for import_request_variables() in %s on line %d
|
||||
NULL
|
||||
|
||||
Notice: import_request_variables(): No prefix specified - possible security hazard in %s on line %d
|
||||
NULL
|
||||
|
||||
Notice: import_request_variables(): No prefix specified - possible security hazard in %s on line %d
|
||||
NULL
|
||||
|
||||
Notice: import_request_variables(): No prefix specified - possible security hazard in %s on line %d
|
||||
|
||||
Warning: import_request_variables(): Attempted GLOBALS variable overwrite. in %s on line %d
|
||||
|
||||
Warning: import_request_variables(): Numeric key detected - possible security hazard. in %s on line %d
|
||||
NULL
|
||||
|
||||
Notice: Undefined variable: ap in %s on line %d
|
||||
string(1) "1"
|
||||
string(3) "heh"
|
||||
string(1) "3"
|
||||
NULL
|
||||
NULL
|
||||
|
||||
Notice: Undefined variable: g_ap in %s on line %d
|
||||
|
||||
Notice: Undefined variable: g_1 in %s on line %d
|
||||
string(1) "1"
|
||||
string(3) "heh"
|
||||
string(1) "3"
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
string(1) "1"
|
||||
string(3) "heh"
|
||||
string(1) "3"
|
||||
string(2) "25"
|
||||
string(4) "test"
|
||||
string(5) "blah3"
|
||||
array(1) {
|
||||
[0]=>
|
||||
string(2) "ar"
|
||||
}
|
||||
NULL
|
||||
|
||||
Notice: Undefined variable: r_ap in %s on line %d
|
||||
string(1) "1"
|
||||
string(3) "heh"
|
||||
string(1) "3"
|
||||
NULL
|
||||
Done
|
75
ext/standard/tests/general_functions/include_path.phpt
Normal file
75
ext/standard/tests/general_functions/include_path.phpt
Normal file
@ -0,0 +1,75 @@
|
||||
--TEST--
|
||||
*_include_path() tests
|
||||
--INI--
|
||||
include_path=.
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
var_dump(get_include_path());
|
||||
var_dump(get_include_path("var"));
|
||||
|
||||
var_dump(restore_include_path());
|
||||
var_dump(restore_include_path(""));
|
||||
|
||||
|
||||
var_dump(set_include_path());
|
||||
var_dump(get_include_path());
|
||||
var_dump(set_include_path("var"));
|
||||
var_dump(get_include_path());
|
||||
|
||||
var_dump(restore_include_path());
|
||||
var_dump(get_include_path());
|
||||
|
||||
var_dump(set_include_path(".:/path/to/dir"));
|
||||
var_dump(get_include_path());
|
||||
|
||||
var_dump(restore_include_path());
|
||||
var_dump(get_include_path());
|
||||
|
||||
var_dump(set_include_path(""));
|
||||
var_dump(get_include_path());
|
||||
|
||||
var_dump(restore_include_path());
|
||||
var_dump(get_include_path());
|
||||
|
||||
var_dump(set_include_path(array()));
|
||||
var_dump(get_include_path());
|
||||
|
||||
var_dump(restore_include_path());
|
||||
var_dump(get_include_path());
|
||||
|
||||
|
||||
echo "Done\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
string(1) "."
|
||||
|
||||
Warning: Wrong parameter count for get_include_path() in %s on line %d
|
||||
NULL
|
||||
NULL
|
||||
|
||||
Warning: Wrong parameter count for restore_include_path() in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: Wrong parameter count for set_include_path() in %s on line %d
|
||||
NULL
|
||||
string(1) "."
|
||||
string(1) "."
|
||||
string(3) "var"
|
||||
NULL
|
||||
string(1) "."
|
||||
string(1) "."
|
||||
string(14) ".:/path/to/dir"
|
||||
NULL
|
||||
string(1) "."
|
||||
string(1) "."
|
||||
string(1) "."
|
||||
NULL
|
||||
string(1) "."
|
||||
|
||||
Notice: Array to string conversion in %s on line %d
|
||||
string(1) "."
|
||||
string(5) "Array"
|
||||
NULL
|
||||
string(1) "."
|
||||
Done
|
175
ext/standard/tests/general_functions/parse_ini_file.phpt
Normal file
175
ext/standard/tests/general_functions/parse_ini_file.phpt
Normal file
@ -0,0 +1,175 @@
|
||||
--TEST--
|
||||
parse_ini_file() tests
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$filename = dirname(__FILE__)."/parse_ini_file.dat";
|
||||
|
||||
var_dump(parse_ini_file());
|
||||
var_dump(parse_ini_file(1,1,1));
|
||||
var_dump(parse_ini_file($filename));
|
||||
var_dump(parse_ini_file($filename, true));
|
||||
|
||||
$ini = "
|
||||
test =
|
||||
";
|
||||
file_put_contents($filename, $ini);
|
||||
var_dump(parse_ini_file($filename));
|
||||
|
||||
$ini = "
|
||||
test==
|
||||
";
|
||||
file_put_contents($filename, $ini);
|
||||
var_dump(parse_ini_file($filename));
|
||||
|
||||
$ini = "
|
||||
test=test=
|
||||
";
|
||||
file_put_contents($filename, $ini);
|
||||
var_dump(parse_ini_file($filename));
|
||||
|
||||
$ini = "
|
||||
test= \"new
|
||||
line\"
|
||||
";
|
||||
file_put_contents($filename, $ini);
|
||||
var_dump(parse_ini_file($filename));
|
||||
|
||||
define("TEST_CONST", "test const value");
|
||||
$ini = "
|
||||
test=TEST_CONST
|
||||
";
|
||||
file_put_contents($filename, $ini);
|
||||
var_dump(parse_ini_file($filename));
|
||||
|
||||
$ini = "
|
||||
[section]
|
||||
test=hello
|
||||
";
|
||||
file_put_contents($filename, $ini);
|
||||
var_dump(parse_ini_file($filename, true));
|
||||
|
||||
$ini = "
|
||||
[section]
|
||||
test=hello
|
||||
";
|
||||
file_put_contents($filename, $ini);
|
||||
var_dump(parse_ini_file($filename, false));
|
||||
|
||||
$ini = "
|
||||
section.test=hello
|
||||
";
|
||||
file_put_contents($filename, $ini);
|
||||
var_dump(parse_ini_file($filename, true));
|
||||
|
||||
$ini = "
|
||||
[section]
|
||||
section.test=hello
|
||||
";
|
||||
file_put_contents($filename, $ini);
|
||||
var_dump(parse_ini_file($filename, true));
|
||||
|
||||
$ini = "
|
||||
[section]
|
||||
1=2
|
||||
";
|
||||
file_put_contents($filename, $ini);
|
||||
var_dump(parse_ini_file($filename, true));
|
||||
|
||||
$ini = "
|
||||
1=2
|
||||
";
|
||||
file_put_contents($filename, $ini);
|
||||
var_dump(parse_ini_file($filename, true));
|
||||
|
||||
$ini = "
|
||||
test=test2
|
||||
test=test3
|
||||
test=test4
|
||||
";
|
||||
file_put_contents($filename, $ini);
|
||||
var_dump(parse_ini_file($filename, true));
|
||||
|
||||
|
||||
@unlink($filename);
|
||||
echo "Done\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: Wrong parameter count for parse_ini_file() in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: Wrong parameter count for parse_ini_file() in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: parse_ini_file(%sparse_ini_file.dat): failed to open stream: No such file or directory in %s on line %d
|
||||
array(0) {
|
||||
}
|
||||
|
||||
Warning: parse_ini_file(%sparse_ini_file.dat): failed to open stream: No such file or directory in %s on line %d
|
||||
array(0) {
|
||||
}
|
||||
array(1) {
|
||||
["test"]=>
|
||||
string(0) ""
|
||||
}
|
||||
|
||||
Warning: Error parsing %sparse_ini_file.dat on line 2
|
||||
in %s on line %d
|
||||
array(1) {
|
||||
["test"]=>
|
||||
string(0) ""
|
||||
}
|
||||
|
||||
Warning: Error parsing %sparse_ini_file.dat on line 2
|
||||
in %s on line %d
|
||||
array(1) {
|
||||
["test"]=>
|
||||
string(4) "test"
|
||||
}
|
||||
array(1) {
|
||||
["test"]=>
|
||||
string(8) "new
|
||||
line"
|
||||
}
|
||||
array(1) {
|
||||
["test"]=>
|
||||
string(16) "test const value"
|
||||
}
|
||||
array(1) {
|
||||
["section"]=>
|
||||
array(1) {
|
||||
["test"]=>
|
||||
string(5) "hello"
|
||||
}
|
||||
}
|
||||
array(1) {
|
||||
["test"]=>
|
||||
string(5) "hello"
|
||||
}
|
||||
array(1) {
|
||||
["section.test"]=>
|
||||
string(5) "hello"
|
||||
}
|
||||
array(1) {
|
||||
["section"]=>
|
||||
array(1) {
|
||||
["section.test"]=>
|
||||
string(5) "hello"
|
||||
}
|
||||
}
|
||||
array(1) {
|
||||
["section"]=>
|
||||
array(1) {
|
||||
[1]=>
|
||||
string(1) "2"
|
||||
}
|
||||
}
|
||||
array(1) {
|
||||
[1]=>
|
||||
string(1) "2"
|
||||
}
|
||||
array(1) {
|
||||
["test"]=>
|
||||
string(5) "test4"
|
||||
}
|
||||
Done
|
63
ext/standard/tests/general_functions/rand.phpt
Normal file
63
ext/standard/tests/general_functions/rand.phpt
Normal file
@ -0,0 +1,63 @@
|
||||
--TEST--
|
||||
rand() and mt_rand() tests
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
var_dump(mt_rand());
|
||||
var_dump(mt_rand(-1));
|
||||
var_dump(mt_rand(-1,1));
|
||||
var_dump(mt_rand(0,3));
|
||||
|
||||
var_dump(rand());
|
||||
var_dump(rand(-1));
|
||||
var_dump(rand(-1,1));
|
||||
var_dump(rand(0,3));
|
||||
|
||||
var_dump(srand());
|
||||
var_dump(srand(-1));
|
||||
var_dump(srand(array()));
|
||||
|
||||
var_dump(mt_srand());
|
||||
var_dump(mt_srand(-1));
|
||||
var_dump(mt_srand(array()));
|
||||
|
||||
var_dump(getrandmax());
|
||||
var_dump(getrandmax(1));
|
||||
|
||||
var_dump(mt_getrandmax());
|
||||
var_dump(mt_getrandmax(1));
|
||||
|
||||
echo "Done\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
int(%d)
|
||||
|
||||
Warning: mt_rand() expects exactly 2 parameters, 1 given in %s on line %d
|
||||
NULL
|
||||
int(%i)
|
||||
int(%d)
|
||||
int(%d)
|
||||
|
||||
Warning: rand() expects exactly 2 parameters, 1 given in %s on line %d
|
||||
NULL
|
||||
int(%i)
|
||||
int(%d)
|
||||
NULL
|
||||
NULL
|
||||
|
||||
Warning: srand() expects parameter 1 to be long, array given in %s on line %d
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
|
||||
Warning: mt_srand() expects parameter 1 to be long, array given in %s on line %d
|
||||
NULL
|
||||
int(%d)
|
||||
|
||||
Warning: Wrong parameter count for getrandmax() in %s on line %d
|
||||
NULL
|
||||
int(%d)
|
||||
|
||||
Warning: Wrong parameter count for mt_getrandmax() in %s on line %d
|
||||
NULL
|
||||
Done
|
28
ext/standard/tests/general_functions/sys_getloadavg.phpt
Normal file
28
ext/standard/tests/general_functions/sys_getloadavg.phpt
Normal file
@ -0,0 +1,28 @@
|
||||
--TEST--
|
||||
sys_getloadavg() tests
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
var_dump(sys_getloadavg(""));
|
||||
var_dump(sys_getloadavg());
|
||||
|
||||
echo "Done\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
array(3) {
|
||||
[0]=>
|
||||
float(%f)
|
||||
[1]=>
|
||||
float(%f)
|
||||
[2]=>
|
||||
float(%f)
|
||||
}
|
||||
array(3) {
|
||||
[0]=>
|
||||
float(%f)
|
||||
[1]=>
|
||||
float(%f)
|
||||
[2]=>
|
||||
float(%f)
|
||||
}
|
||||
Done
|
79
ext/standard/tests/network/inet.phpt
Normal file
79
ext/standard/tests/network/inet.phpt
Normal file
@ -0,0 +1,79 @@
|
||||
--TEST--
|
||||
inet_ntop() & inet_pton() tests
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!function_exists("inet_ntop")) die("skip no inet_ntop()");
|
||||
if (!function_exists("inet_pton")) die("skip no inet_pton()");
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$packed = chr(127) . chr(0) . chr(0) . chr(1);
|
||||
var_dump(inet_ntop($packed));
|
||||
|
||||
$packed = chr(255) . chr(255) . chr(255) . chr(0);
|
||||
var_dump(inet_ntop($packed));
|
||||
|
||||
$packed = str_repeat(chr(0), 15) . chr(38);
|
||||
var_dump(inet_ntop($packed));
|
||||
|
||||
var_dump(inet_ntop());
|
||||
var_dump(inet_ntop(-1));
|
||||
var_dump(inet_ntop(""));
|
||||
var_dump(inet_ntop("blah-blah"));
|
||||
|
||||
var_dump(inet_pton());
|
||||
var_dump(inet_pton(""));
|
||||
var_dump(inet_pton(-1));
|
||||
var_dump(inet_pton("abra"));
|
||||
|
||||
$array = array(
|
||||
"127.0.0.1",
|
||||
"66.163.161.116",
|
||||
"255.255.255.255",
|
||||
"0.0.0.0",
|
||||
);
|
||||
foreach ($array as $val) {
|
||||
var_dump($packed = inet_pton($val));
|
||||
var_dump(inet_ntop($packed));
|
||||
}
|
||||
|
||||
echo "Done\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
string(9) "127.0.0.1"
|
||||
string(13) "255.255.255.0"
|
||||
string(4) "::26"
|
||||
|
||||
Warning: inet_ntop() expects exactly 1 parameter, 0 given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: inet_ntop(): Invalid in_addr value in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: inet_ntop(): Invalid in_addr value in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: inet_ntop(): Invalid in_addr value in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: inet_pton() expects exactly 1 parameter, 0 given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: inet_pton(): Unrecognized address in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: inet_pton(): Unrecognized address -1 in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: inet_pton(): Unrecognized address abra in %s on line %d
|
||||
bool(false)
|
||||
string(4) "%s"
|
||||
string(9) "127.0.0.1"
|
||||
string(4) "%s"
|
||||
string(14) "66.163.161.116"
|
||||
string(4) "%s"
|
||||
string(15) "255.255.255.255"
|
||||
string(4) "%s"
|
||||
string(7) "0.0.0.0"
|
||||
Done
|
63
ext/standard/tests/network/ip.phpt
Normal file
63
ext/standard/tests/network/ip.phpt
Normal file
@ -0,0 +1,63 @@
|
||||
--TEST--
|
||||
ip2long() & long2ip() tests
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$array = array(
|
||||
"127.0.0.1",
|
||||
"10.0.0.1",
|
||||
"255.255.255.255",
|
||||
"255.255.255.0",
|
||||
"0.0.0.0",
|
||||
"66.163.161.116",
|
||||
);
|
||||
|
||||
foreach ($array as $ip) {
|
||||
var_dump($long = ip2long($ip));
|
||||
var_dump(long2ip($long));
|
||||
}
|
||||
|
||||
var_dump(ip2long());
|
||||
var_dump(ip2long(""));
|
||||
var_dump(ip2long("777.777.777.777"));
|
||||
var_dump(ip2long("111.111.111.111"));
|
||||
var_dump(ip2long(array()));
|
||||
|
||||
var_dump(long2ip());
|
||||
var_dump(long2ip(-110000));
|
||||
var_dump(long2ip(""));
|
||||
var_dump(long2ip(array()));
|
||||
|
||||
echo "Done\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
int(2130706433)
|
||||
string(9) "127.0.0.1"
|
||||
int(167772161)
|
||||
string(8) "10.0.0.1"
|
||||
int(-1)
|
||||
string(15) "255.255.255.255"
|
||||
int(-256)
|
||||
string(13) "255.255.255.0"
|
||||
int(0)
|
||||
string(7) "0.0.0.0"
|
||||
int(1118019956)
|
||||
string(14) "66.163.161.116"
|
||||
|
||||
Warning: Wrong parameter count for ip2long() in %s on line %d
|
||||
NULL
|
||||
int(-1)
|
||||
bool(false)
|
||||
int(1869573999)
|
||||
|
||||
Notice: Array to string conversion in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: Wrong parameter count for long2ip() in %s on line %d
|
||||
NULL
|
||||
string(13) "255.254.82.80"
|
||||
string(7) "0.0.0.0"
|
||||
|
||||
Notice: Array to string conversion in %s on line %d
|
||||
string(7) "0.0.0.0"
|
||||
Done
|
68
ext/standard/tests/strings/highlight_file.phpt
Normal file
68
ext/standard/tests/strings/highlight_file.phpt
Normal file
@ -0,0 +1,68 @@
|
||||
--TEST--
|
||||
highlight_file() tests
|
||||
--INI--
|
||||
highlight.string=#DD0000
|
||||
highlight.comment=#FF9900
|
||||
highlight.keyword=#007700
|
||||
highlight.bg=#FFFFFF
|
||||
highlight.default=#0000BB
|
||||
highlight.html=#000000
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$filename = dirname(__FILE__)."/highlight_file.dat";
|
||||
|
||||
var_dump(highlight_file());
|
||||
var_dump(highlight_file($filename));
|
||||
|
||||
$data = <<<DATA
|
||||
<?php echo "test"; ?>
|
||||
DATA;
|
||||
|
||||
file_put_contents($filename, $data);
|
||||
var_dump(highlight_file($filename));
|
||||
|
||||
$data = <<<DATA
|
||||
<?php echo "test ?>
|
||||
DATA;
|
||||
|
||||
file_put_contents($filename, $data);
|
||||
var_dump(highlight_file($filename));
|
||||
|
||||
$data = '
|
||||
<?php
|
||||
class test {
|
||||
public $var = 1;
|
||||
private function foo() { echo "foo"; }
|
||||
public function bar() { var_dump(test::foo()); }
|
||||
}
|
||||
?>';
|
||||
|
||||
file_put_contents($filename, $data);
|
||||
var_dump(highlight_file($filename));
|
||||
|
||||
|
||||
@unlink($filename);
|
||||
echo "Done\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: highlight_file() expects at least 1 parameter, 0 given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: highlight_file(%shighlight_file.dat): failed to open stream: No such file or directory in %s on line %d
|
||||
|
||||
Warning: highlight_file(): Failed opening '%shighlight_file.dat' for highlighting in %s on line %d
|
||||
bool(false)
|
||||
<code><span style="color: #000000">
|
||||
<span style="color: #0000BB"><?php </span><span style="color: #007700">echo </span><span style="color: #DD0000">"test"</span><span style="color: #007700">; </span><span style="color: #0000BB">?></span>
|
||||
</span>
|
||||
</code>bool(true)
|
||||
<code><span style="color: #000000">
|
||||
<span style="color: #0000BB"><?php </span><span style="color: #007700">echo </span><span style="color: #DD0000">"test ?></span>
|
||||
</span>
|
||||
</code>bool(true)
|
||||
<code><span style="color: #000000">
|
||||
<br /><span style="color: #0000BB"><?php <br /> </span><span style="color: #007700">class </span><span style="color: #0000BB">test </span><span style="color: #007700">{ <br /> public </span><span style="color: #0000BB">$var </span><span style="color: #007700">= </span><span style="color: #0000BB">1</span><span style="color: #007700">; <br /> private function </span><span style="color: #0000BB">foo</span><span style="color: #007700">() { echo </span><span style="color: #DD0000">"foo"</span><span style="color: #007700">; }<br /> public function </span><span style="color: #0000BB">bar</span><span style="color: #007700">() { </span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">test</span><span style="color: #007700">::</span><span style="color: #0000BB">foo</span><span style="color: #007700">()); }<br /> } <br /></span><span style="color: #0000BB">?></span>
|
||||
</span>
|
||||
</code>bool(true)
|
||||
Done
|
52
ext/standard/tests/strings/php_strip_whitespace.phpt
Normal file
52
ext/standard/tests/strings/php_strip_whitespace.phpt
Normal file
@ -0,0 +1,52 @@
|
||||
--TEST--
|
||||
php_strip_whitespace() tests
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$filename = dirname(__FILE__)."/php_strip_whitespace.dat";
|
||||
|
||||
var_dump(php_strip_whitespace());
|
||||
var_dump(php_strip_whitespace($filename));
|
||||
|
||||
$data = '/* test comment */';
|
||||
file_put_contents($filename, $data);
|
||||
var_dump(php_strip_whitespace($filename));
|
||||
|
||||
$data = '<?php /* test comment */ ?>';
|
||||
file_put_contents($filename, $data);
|
||||
var_dump(php_strip_whitespace($filename));
|
||||
|
||||
$data = '<?php
|
||||
/* test class */
|
||||
class test {
|
||||
|
||||
/* function foo () */
|
||||
|
||||
function foo () /* {{{ */
|
||||
{
|
||||
|
||||
|
||||
echo $var; //does not exist
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
}
|
||||
?>';
|
||||
|
||||
file_put_contents($filename, $data);
|
||||
var_dump(php_strip_whitespace($filename));
|
||||
|
||||
@unlink($filename);
|
||||
echo "Done\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: php_strip_whitespace() expects exactly 1 parameter, 0 given in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: php_strip_whitespace(%sphp_strip_whitespace.dat): failed to open stream: No such file or directory in %s on line %d
|
||||
string(0) ""
|
||||
string(18) "/* test comment */"
|
||||
string(9) "<?php ?>"
|
||||
string(55) "<?php
|
||||
class test { function foo () { echo $var; } } ?>"
|
||||
Done
|
@ -2,13 +2,50 @@
|
||||
sha1() with ASCII output
|
||||
--FILE--
|
||||
<?php
|
||||
echo sha1("abc")."\n";
|
||||
echo sha1("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq")."\n";
|
||||
echo sha1("a")."\n";
|
||||
echo sha1("0123456701234567012345670123456701234567012345670123456701234567")."\n";
|
||||
|
||||
$filename = dirname(__FILE__)."/sha1.dat";
|
||||
$a = array(
|
||||
"abc",
|
||||
"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
|
||||
"a",
|
||||
"0123456701234567012345670123456701234567012345670123456701234567",
|
||||
""
|
||||
);
|
||||
|
||||
foreach ($a as $str) {
|
||||
var_dump($val1 = sha1($str));
|
||||
file_put_contents($filename, $str);
|
||||
var_dump($val2 = sha1_file($filename));
|
||||
var_dump($val1 === $val2);
|
||||
}
|
||||
|
||||
var_dump(sha1($str, true));
|
||||
var_dump(sha1_file($filename, true));
|
||||
|
||||
@unlink($filename);
|
||||
|
||||
sha1_file($filename);
|
||||
|
||||
echo "Done\n";
|
||||
?>
|
||||
--EXPECT--
|
||||
a9993e364706816aba3e25717850c26c9cd0d89d
|
||||
84983e441c3bd26ebaae4aa1f95129e5e54670f1
|
||||
86f7e437faa5a7fce15d1ddcb9eaeaea377667b8
|
||||
e0c094e867ef46c350ef54a7f59dd60bed92ae83
|
||||
--EXPECTF--
|
||||
string(40) "a9993e364706816aba3e25717850c26c9cd0d89d"
|
||||
string(40) "a9993e364706816aba3e25717850c26c9cd0d89d"
|
||||
bool(true)
|
||||
string(40) "84983e441c3bd26ebaae4aa1f95129e5e54670f1"
|
||||
string(40) "84983e441c3bd26ebaae4aa1f95129e5e54670f1"
|
||||
bool(true)
|
||||
string(40) "86f7e437faa5a7fce15d1ddcb9eaeaea377667b8"
|
||||
string(40) "86f7e437faa5a7fce15d1ddcb9eaeaea377667b8"
|
||||
bool(true)
|
||||
string(40) "e0c094e867ef46c350ef54a7f59dd60bed92ae83"
|
||||
string(40) "e0c094e867ef46c350ef54a7f59dd60bed92ae83"
|
||||
bool(true)
|
||||
string(40) "da39a3ee5e6b4b0d3255bfef95601890afd80709"
|
||||
string(40) "da39a3ee5e6b4b0d3255bfef95601890afd80709"
|
||||
bool(true)
|
||||
string(20) "%s"
|
||||
string(20) "%s"
|
||||
|
||||
Warning: sha1_file(%ssha1.dat): failed to open stream: No such file or directory in %s on line %d
|
||||
Done
|
||||
|
Loading…
Reference in New Issue
Block a user