1--TEST-- 2Test disk_free_space and its alias diskfreespace() functions : basic functionality 3--INI-- 4memory_limit=32M 5--FILE-- 6<?php 7/* 8 * Prototype: float disk_free_space( string directory ) 9 * Description: Given a string containing a directory, this function 10 * will return the number of bytes available on the corresponding 11 * filesystem or disk partition 12 */ 13 14$file_path = dirname(__FILE__); 15 16echo "*** Testing with existing directory ***\n"; 17var_dump( disk_free_space($file_path) ); 18var_dump( diskfreespace($file_path) ); 19 20echo "*** Testing with newly created directory ***\n"; 21$dir = "/disk_free_space"; 22mkdir($file_path.$dir); 23echo" \n Free Space before writing to a file\n"; 24$space1 = disk_free_space($file_path.$dir); 25var_dump( $space1 ); 26 27$fh = fopen($file_path.$dir."/disk_free_space.tmp", "a"); 28$data = str_repeat("x", 4096); 29fwrite($fh, (binary)$data); 30fclose($fh); 31 32echo "\n Free Space after writing to a file\n"; 33$space2 = disk_free_space($file_path.$dir); 34var_dump( $space2 ); 35 36if( $space1 > $space2 ) 37 echo "\n Free Space Value Is Correct\n"; 38else 39 echo "\n Free Space Value Is Incorrect\n"; 40 41echo "*** Testing with Binary Input ***\n"; 42var_dump( disk_free_space(b"$file_path") ); 43 44echo"\n--- Done ---"; 45?> 46 47--CLEAN-- 48<?php 49$file_path = dirname(__FILE__); 50unlink($file_path."/disk_free_space/disk_free_space.tmp"); 51rmdir($file_path."/disk_free_space"); 52?> 53 54--EXPECTF-- 55*** Testing with existing directory *** 56float(%d) 57float(%d) 58*** Testing with newly created directory *** 59 60 Free Space before writing to a file 61float(%d) 62 63 Free Space after writing to a file 64float(%d) 65 66 Free Space Value Is Correct 67*** Testing with Binary Input *** 68float(%d) 69 70--- Done --- 71