1--TEST-- 2Testing disk_total_space() functions : Usage Variations. 3--FILE-- 4<?php 5/* 6 * Prototype: float disk_total_space( string directory ) 7 * Description: given a string containing a directory, this function 8 * will return the total number of bytes on the corresponding 9 * filesystem or disk partition. 10 */ 11 12$file_path = dirname(__FILE__); 13 14echo "*** Testing with a directory ***\n"; 15var_dump( disk_total_space($file_path."/..") ); 16 17echo "\nTesting for the return type ***\n"; 18$return_value = disk_total_space($file_path); 19var_dump( is_float($return_value) ); 20 21echo "\n*** Testing with different directory combinations ***"; 22$dir = "/disk_total_space"; 23 24mkdir($file_path.$dir); 25 26$dirs_arr = array( 27 ".", 28 $file_path.$dir, 29 $file_path."/.".$dir, 30 31 /* Testing a file trailing slash */ 32 $file_path."".$dir."/", 33 $file_path."/.".$dir."/", 34 35 /* Testing file with double trailing slashes */ 36 $file_path.$dir."//", 37 $file_path."/.".$dir."//", 38 $file_path."/./".$dir."//", 39 40 /* Testing Binary safe */ 41 $file_path.$dir.chr(0), 42 $file_path."/.".$dir.chr(0), 43 ".".chr(0).$file_path.$dir, 44 ".".chr(0).$file_path.$dir.chr(0) 45); 46 47 48$count = 1; 49/* loop through to test each element the above array */ 50foreach($dirs_arr as $dir1) { 51 echo "\n-- Iteration $count --\n"; 52 var_dump( disk_total_space( $dir1 ) ); 53 $count++; 54} 55 56echo "*** Testing with Binary Input ***\n"; 57var_dump( disk_total_space(b"$file_path") ); 58 59echo"\n--- Done ---"; 60?> 61--CLEAN-- 62<?php 63$file_path = dirname(__FILE__); 64rmdir($file_path."/disk_total_space"); 65?> 66--EXPECTF-- 67*** Testing with a directory *** 68float(%d) 69 70Testing for the return type *** 71bool(true) 72 73*** Testing with different directory combinations *** 74-- Iteration 1 -- 75float(%d) 76 77-- Iteration 2 -- 78float(%d) 79 80-- Iteration 3 -- 81float(%d) 82 83-- Iteration 4 -- 84float(%d) 85 86-- Iteration 5 -- 87float(%d) 88 89-- Iteration 6 -- 90float(%d) 91 92-- Iteration 7 -- 93float(%d) 94 95-- Iteration 8 -- 96float(%d) 97 98-- Iteration 9 -- 99 100Warning: disk_total_space() expects parameter 1 to be a valid path, string given in %s on line %d 101NULL 102 103-- Iteration 10 -- 104 105Warning: disk_total_space() expects parameter 1 to be a valid path, string given in %s on line %d 106NULL 107 108-- Iteration 11 -- 109 110Warning: disk_total_space() expects parameter 1 to be a valid path, string given in %s on line %d 111NULL 112 113-- Iteration 12 -- 114 115Warning: disk_total_space() expects parameter 1 to be a valid path, string given in %s on line %d 116NULL 117*** Testing with Binary Input *** 118float(%d) 119 120--- Done --- 121