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