2007-06-06 12:53:58 +00:00
|
|
|
--TEST--
|
2007-11-05 17:43:21 +00:00
|
|
|
Test disk_free_space and its alias diskfreespace() functions : Usage Variations
|
2007-06-06 12:53:58 +00:00
|
|
|
--FILE--
|
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
* Prototype: float disk_free_space( string directory )
|
|
|
|
* Description: Given a string containing a directory, this function
|
|
|
|
* will return the number of bytes available on the corresponding
|
|
|
|
* filesystem or disk partition
|
|
|
|
*/
|
|
|
|
|
|
|
|
$file_path = dirname(__FILE__);
|
|
|
|
|
2007-11-05 17:43:21 +00:00
|
|
|
echo "*** Testing with a directory ***\n";
|
2007-06-06 12:53:58 +00:00
|
|
|
var_dump( disk_free_space($file_path."/..") );
|
|
|
|
var_dump( diskfreespace($file_path."/..") );
|
|
|
|
|
2007-11-05 17:43:21 +00:00
|
|
|
echo "\nTesting for the return type ***\n";
|
2007-06-06 12:53:58 +00:00
|
|
|
$return_value = disk_free_space($file_path);
|
|
|
|
var_dump( is_float($return_value) );
|
|
|
|
|
2007-11-05 17:43:21 +00:00
|
|
|
echo "\n*** Testing with different directory combinations ***";
|
2007-06-06 12:53:58 +00:00
|
|
|
$dir = "/disk_free_space";
|
|
|
|
mkdir($file_path.$dir);
|
|
|
|
|
|
|
|
$dirs_arr = array(
|
|
|
|
".",
|
|
|
|
$file_path.$dir,
|
|
|
|
$file_path."/.".$dir,
|
|
|
|
|
|
|
|
/* Testing a file trailing slash */
|
|
|
|
$file_path."".$dir."/",
|
|
|
|
$file_path."/.".$dir."/",
|
|
|
|
|
|
|
|
/* Testing file with double trailing slashes */
|
|
|
|
$file_path.$dir."//",
|
|
|
|
$file_path."/.".$dir."//",
|
|
|
|
$file_path."/./".$dir."//",
|
|
|
|
|
|
|
|
/* Testing Binary safe */
|
|
|
|
$file_path.$dir.chr(0),
|
|
|
|
$file_path."/.".$dir.chr(0),
|
|
|
|
".".chr(0).$file_path.$dir,
|
2007-11-05 17:43:21 +00:00
|
|
|
".".chr(0).$file_path.$dir.chr(0)
|
2007-06-06 12:53:58 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
$count = 1;
|
|
|
|
/* loop through to test each element the above array */
|
2007-11-05 17:43:21 +00:00
|
|
|
foreach($dirs_arr as $dir1) {
|
2007-06-06 12:53:58 +00:00
|
|
|
echo "\n-- Iteration $count --\n";
|
2007-11-05 17:43:21 +00:00
|
|
|
var_dump( disk_free_space( $dir1 ) );
|
|
|
|
var_dump( diskfreespace( $dir1 ) );
|
2007-06-06 12:53:58 +00:00
|
|
|
$count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
echo"\n--- Done ---";
|
|
|
|
?>
|
|
|
|
|
|
|
|
--CLEAN--
|
|
|
|
<?php
|
2007-11-05 17:43:21 +00:00
|
|
|
$file_path = dirname(__FILE__);
|
|
|
|
rmdir($file_path."/disk_free_space");
|
2007-06-06 12:53:58 +00:00
|
|
|
?>
|
|
|
|
|
2007-11-05 17:43:21 +00:00
|
|
|
|
2007-06-06 12:53:58 +00:00
|
|
|
--EXPECTF--
|
2007-11-05 17:43:21 +00:00
|
|
|
*** Testing with a directory ***
|
2007-06-06 12:53:58 +00:00
|
|
|
float(%d)
|
|
|
|
float(%d)
|
|
|
|
|
2007-11-05 17:43:21 +00:00
|
|
|
Testing for the return type ***
|
2007-06-06 12:53:58 +00:00
|
|
|
bool(true)
|
|
|
|
|
2007-11-05 17:43:21 +00:00
|
|
|
*** Testing with different directory combinations ***
|
2007-06-06 12:53:58 +00:00
|
|
|
-- Iteration 1 --
|
|
|
|
float(%d)
|
|
|
|
float(%d)
|
|
|
|
|
|
|
|
-- Iteration 2 --
|
|
|
|
float(%d)
|
|
|
|
float(%d)
|
|
|
|
|
|
|
|
-- Iteration 3 --
|
|
|
|
float(%d)
|
|
|
|
float(%d)
|
|
|
|
|
|
|
|
-- Iteration 4 --
|
|
|
|
float(%d)
|
|
|
|
float(%d)
|
|
|
|
|
|
|
|
-- Iteration 5 --
|
|
|
|
float(%d)
|
|
|
|
float(%d)
|
|
|
|
|
|
|
|
-- Iteration 6 --
|
|
|
|
float(%d)
|
|
|
|
float(%d)
|
|
|
|
|
|
|
|
-- Iteration 7 --
|
|
|
|
float(%d)
|
|
|
|
float(%d)
|
|
|
|
|
|
|
|
-- Iteration 8 --
|
|
|
|
float(%d)
|
|
|
|
float(%d)
|
|
|
|
|
|
|
|
-- Iteration 9 --
|
|
|
|
float(%d)
|
|
|
|
float(%d)
|
|
|
|
|
|
|
|
-- Iteration 10 --
|
|
|
|
float(%d)
|
|
|
|
float(%d)
|
|
|
|
|
|
|
|
-- Iteration 11 --
|
|
|
|
float(%d)
|
|
|
|
float(%d)
|
|
|
|
|
|
|
|
-- Iteration 12 --
|
|
|
|
float(%d)
|
|
|
|
float(%d)
|
|
|
|
|
|
|
|
--- Done ---
|