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