add new tests

This commit is contained in:
Antony Dovgal 2006-11-15 17:26:54 +00:00
parent 097a8db329
commit bbc854a4bd
7 changed files with 372 additions and 0 deletions

View File

@ -0,0 +1,46 @@
--TEST--
disk_total_space() and disk_free_space() tests
--SKIPIF--
<?php
if (substr(PHP_OS, 0, 3) == 'WIN') {
die('skip not for Windows');
}
?>
--FILE--
<?php
var_dump(disk_free_space());
var_dump(disk_total_space());
var_dump(disk_free_space(-1));
var_dump(disk_total_space(-1));
var_dump(disk_free_space("/"));
var_dump(disk_total_space("/"));
var_dump(disk_free_space("/some/path/here"));
var_dump(disk_total_space("/some/path/here"));
echo "Done\n";
?>
--EXPECTF--
Warning: disk_free_space() expects exactly 1 parameter, 0 given in %s on line %d
NULL
Warning: disk_total_space() expects exactly 1 parameter, 0 given in %s on line %d
NULL
Warning: disk_free_space(): No such file or directory in %s on line %d
bool(false)
Warning: disk_total_space(): No such file or directory in %s on line %d
bool(false)
float(%d)
float(%d)
Warning: disk_free_space(): No such file or directory in %s on line %d
bool(false)
Warning: disk_total_space(): No such file or directory in %s on line %d
bool(false)
Done

View File

@ -0,0 +1,63 @@
--TEST--
various file stat func tests
--FILE--
<?php
var_dump(fileinode("."));
var_dump(fileowner("."));
var_dump(filegroup("."));
var_dump(fileatime("."));
var_dump(filectime("."));
var_dump(fileinode("./.."));
var_dump(fileowner("./.."));
var_dump(filegroup("./.."));
var_dump(fileatime("./.."));
var_dump(filectime("./.."));
var_dump(fileinode(__FILE__));
var_dump(fileowner(__FILE__));
var_dump(filegroup(__FILE__));
var_dump(fileatime(__FILE__));
var_dump(filectime(__FILE__));
var_dump(fileinode("/no/such/file/or/dir"));
var_dump(fileowner("/no/such/file/or/dir"));
var_dump(filegroup("/no/such/file/or/dir"));
var_dump(fileatime("/no/such/file/or/dir"));
var_dump(filectime("/no/such/file/or/dir"));
echo "Done\n";
?>
--EXPECTF--
int(%d)
int(%d)
int(%d)
int(%d)
int(%d)
int(%d)
int(%d)
int(%d)
int(%d)
int(%d)
int(%d)
int(%d)
int(%d)
int(%d)
int(%d)
Warning: fileinode(): stat failed for /no/such/file/or/dir in %s on line %d
bool(false)
Warning: fileowner(): stat failed for /no/such/file/or/dir in %s on line %d
bool(false)
Warning: filegroup(): stat failed for /no/such/file/or/dir in %s on line %d
bool(false)
Warning: fileatime(): stat failed for /no/such/file/or/dir in %s on line %d
bool(false)
Warning: filectime(): stat failed for /no/such/file/or/dir in %s on line %d
bool(false)
Done

View File

@ -0,0 +1,31 @@
--TEST--
getrusage() tests
--SKIPIF--
<?php if (!function_exists("getrusage")) print "skip"; ?>
--FILE--
<?php
var_dump(gettype(getrusage()));
var_dump(gettype(getrusage(1)));
var_dump(gettype(getrusage(-1)));
var_dump(getrusage(array()));
echo "Done\n";
?>
--EXPECTF--
string(5) "array"
string(5) "array"
string(5) "array"
Warning: getrusage() expects parameter 1 to be long, array given in %s on line %d
NULL
Done
--UEXPECTF--
unicode(5) "array"
unicode(5) "array"
unicode(5) "array"
Warning: getrusage() expects parameter 1 to be long, array given in %s on line %d
NULL
Done

View File

@ -0,0 +1,53 @@
--TEST--
header() and friends
--SKIPIF--
<?php
if (php_sapi_name() != "cli") {
die("skip this test is for CLI");
}
?>
--FILE--
<?php
$v1 = headers_sent();
$v2 = headers_list();
var_dump(header("HTTP 1.0", true, 200));
var_dump($v1);
var_dump($v2);
var_dump(header(""));
var_dump(header("", true));
var_dump(headers_sent());
var_dump(headers_list());
var_dump(header("HTTP blah"));
var_dump(header("HTTP blah", true));
var_dump(headers_sent());
var_dump(headers_list());
echo "Done\n";
?>
--EXPECTF--
NULL
bool(false)
array(0) {
}
Warning: Cannot modify header information - headers already sent by (output started at %s:%d) in %s on line %d
NULL
Warning: Cannot modify header information - headers already sent by (output started at %s:%d) in %s on line %d
NULL
bool(true)
array(0) {
}
Warning: Cannot modify header information - headers already sent by (output started at %s:%d) in %s on line %d
NULL
Warning: Cannot modify header information - headers already sent by (output started at %s:%d) in %s on line %d
NULL
bool(true)
array(0) {
}
Done

View File

@ -0,0 +1,41 @@
--TEST--
metaphone() tests
--FILE--
<?php
var_dump(metaphone());
var_dump(metaphone(""));
var_dump(metaphone(-1));
var_dump(metaphone(-1, -1));
var_dump(metaphone("valid phrase", -1));
var_dump(metaphone("valid phrase", 0));
var_dump(metaphone("valid phrase", 10000));
$array = array(
"They fell forward, grovelling heedlessly on the cold earth.",
"But the shadow of horror wheeled and returned, passing lower now, right above them, sweeping the fen-reek with its ghastly wings.",
"And then it was gone, flying back to Mordor with the speed of the wrath of Sauron; and behind it the wind roared away, leaving the Dead Marshes bare and bleak.",
"The naked waste, as far as the eye could pierce, even to the distant menace of the mountains, was dappled with the fitful moonlight."
);
foreach($array as $str) {
var_dump(metaphone($str));
}
echo "Done\n";
?>
--EXPECTF--
Warning: metaphone() expects at least 1 parameter, 0 given in %s on line %d
NULL
string(0) ""
string(0) ""
bool(false)
bool(false)
string(6) "FLTFRS"
string(6) "FLTFRS"
string(26) "0FLFRWRTKRFLNKHTLSLN0KLTR0"
string(56) "BT0XTFHRRHLTNTRTRNTPSNKLWRNRFTBF0MSWPNK0FNRKW0TSFSTLWNKS"
string(69) "ANT0NTWSKNFLYNKBKTMRTRW00SPTF0R0FSRNNTBHNTT0WNTRRTWLFNK0TTMRXSBRNTBLK"
string(56) "0NKTWSTSFRS0YKLTPRSFNT0TSTNTMNSF0MNTNSWSTPLTW00FTFLMNLFT"
Done

View File

@ -0,0 +1,77 @@
--TEST--
soundex() tests
--FILE--
<?php
var_dump(soundex(""));
var_dump(soundex(-1));
var_dump(soundex(array()));
$array = array(
"From",
"that",
"time",
"on",
"Sam",
"thought",
"that",
"he",
"sensed",
"a",
"change",
"in",
"Gollum",
"again.",
"He was more fawning and would-be friendly; but Sam surprised some strange looks in his eyes at times, especially towards Frodo."
);
foreach ($array as $str) {
var_dump(soundex($str));
}
echo "Done\n";
?>
--EXPECTF--
bool(false)
string(4) "0000"
Warning: soundex() expects parameter 1 to be string, array given in %s on line %d
NULL
string(4) "F650"
string(4) "T300"
string(4) "T500"
string(4) "O500"
string(4) "S500"
string(4) "T230"
string(4) "T300"
string(4) "H000"
string(4) "S523"
string(4) "A000"
string(4) "C520"
string(4) "I500"
string(4) "G450"
string(4) "A250"
string(4) "H256"
Done
--UEXPECTF--
bool(false)
string(4) "0000"
Warning: soundex() expects parameter 1 to be binary string, array given in %s on line %d
NULL
string(4) "F650"
string(4) "T300"
string(4) "T500"
string(4) "O500"
string(4) "S500"
string(4) "T230"
string(4) "T300"
string(4) "H000"
string(4) "S523"
string(4) "A000"
string(4) "C520"
string(4) "I500"
string(4) "G450"
string(4) "A250"
string(4) "H256"
Done

View File

@ -0,0 +1,61 @@
--TEST--
uuencode family tests
--FILE--
<?php
var_dump(convert_uuencode(array()));
var_dump(convert_uudecode(array()));
var_dump(convert_uuencode(""));
var_dump(convert_uudecode(""));
var_dump($enc = convert_uuencode("~!@#$%^&*()_}{POIUYTREWQQSDFGHJKL:<MNBVCXZ"));
var_dump(convert_uudecode("!@#$%^YUGFDFGHJKLUYTFBNMLOYT"));
var_dump(convert_uudecode($enc));
var_dump($enc = convert_uuencode("not very sophisticated"));
var_dump(convert_uudecode($enc));
var_dump(convert_uudecode(substr($enc, 0, -10)));
echo "Done\n";
?>
--EXPECTF--
Warning: convert_uuencode() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d
bool(false)
Warning: convert_uudecode() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d
bool(false)
bool(false)
bool(false)
string(60) "J?B%`(R0E7B8J*"E??7M03TE5651215=145-$1D=(2DM,.CQ-3D)60UA:
`
"
string(1) "%s"
string(42) "~!@#$%^&*()_}{POIUYTREWQQSDFGHJKL:<MNBVCXZ"
string(36) "6;F]T('9E<GD@<V]P:&ES=&EC871E9```
`
"
string(22) "not very sophisticated"
Warning: convert_uudecode(): The given parameter is not a valid uuencoded string in %s on line %d
bool(false)
Done
--UEXPECTF--
Warning: convert_uuencode() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d
bool(false)
Warning: convert_uudecode() expects parameter 1 to be string (Unicode or binary), array given in %s on line %d
bool(false)
bool(false)
bool(false)
unicode(60) "J?B%`(R0E7B8J*"E??7M03TE5651215=145-$1D=(2DM,.CQ-3D)60UA:
`
"
string(1) "%s"
string(42) "~!@#$%^&*()_}{POIUYTREWQQSDFGHJKL:<MNBVCXZ"
unicode(36) "6;F]T('9E<GD@<V]P:&ES=&EC871E9```
`
"
string(22) "not very sophisticated"
Warning: convert_uudecode(): The given parameter is not a valid uuencoded string in %s on line %d
bool(false)
Done