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"); 6if (getenv('CIRRUS_CI')) die('skip Inaccurate on Cirrus'); 7?> 8--INI-- 9memory_limit=32M 10--FILE-- 11<?php 12$file_path = __DIR__; 13 14echo "*** Testing with existing directory ***\n"; 15var_dump( disk_free_space($file_path) ); 16var_dump( diskfreespace($file_path) ); 17 18echo "*** Testing with newly created directory ***\n"; 19$dir = "/disk_free_space"; 20mkdir($file_path.$dir); 21echo "\n Free Space before writing to a file\n"; 22$space1 = disk_free_space($file_path.$dir); 23var_dump( $space1 ); 24 25$fh = fopen($file_path.$dir."/disk_free_space.tmp", "a"); 26$data = str_repeat("x", 0xffff); 27fwrite($fh, $data); 28fclose($fh); 29 30echo "\n Free Space after writing to a file\n"; 31$space2 = disk_free_space($file_path.$dir); 32var_dump( $space2 ); 33 34// Some file systems (like BTRFS) have a fuzzy notion of "free space" and will thus claim the same amount of free space 35if ($space1 >= $space2) 36 echo "\n Free Space Value Is Correct\n"; 37else { 38 echo "\n Free Space Value Is Incorrect\n"; 39 var_dump($space1, $space2); 40} 41 42echo "*** Testing with Binary Input ***\n"; 43var_dump( disk_free_space(b"$file_path") ); 44 45echo"\n--- Done ---"; 46?> 47--CLEAN-- 48<?php 49$file_path = __DIR__; 50unlink($file_path."/disk_free_space/disk_free_space.tmp"); 51rmdir($file_path."/disk_free_space"); 52?> 53--EXPECTF-- 54*** Testing with existing directory *** 55float(%f) 56float(%f) 57*** Testing with newly created directory *** 58 59 Free Space before writing to a file 60float(%f) 61 62 Free Space after writing to a file 63float(%f) 64 65 Free Space Value Is Correct 66*** Testing with Binary Input *** 67float(%f) 68 69--- Done --- 70