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$file_path = __DIR__;
12
13echo "*** Testing with existing directory ***\n";
14var_dump( disk_free_space($file_path) );
15var_dump( diskfreespace($file_path) );
16
17echo "*** Testing with newly created directory ***\n";
18$dir = "/disk_free_space";
19mkdir($file_path.$dir);
20echo" \n Free Space before writing to a file\n";
21$space1 =  disk_free_space($file_path.$dir);
22var_dump( $space1 );
23
24$fh = fopen($file_path.$dir."/disk_free_space.tmp", "a");
25$data = str_repeat("x", 0xffff);
26fwrite($fh, $data);
27fclose($fh);
28
29echo "\n Free Space after writing to a file\n";
30$space2 =  disk_free_space($file_path.$dir);
31var_dump( $space2 );
32
33if($space1 > $space2 )
34  echo "\n Free Space Value Is Correct\n";
35else {
36  echo "\n Free Space Value Is Incorrect\n";
37  var_dump($space1, $space2);
38}
39
40echo "*** Testing with Binary Input ***\n";
41var_dump( disk_free_space(b"$file_path") );
42
43echo"\n--- Done ---";
44?>
45--CLEAN--
46<?php
47$file_path = __DIR__;
48unlink($file_path."/disk_free_space/disk_free_space.tmp");
49rmdir($file_path."/disk_free_space");
50?>
51--EXPECTF--
52*** Testing with existing directory ***
53float(%f)
54float(%f)
55*** Testing with newly created directory ***
56
57 Free Space before writing to a file
58float(%f)
59
60 Free Space after writing to a file
61float(%f)
62
63 Free Space Value Is Correct
64*** Testing with Binary Input ***
65float(%f)
66
67--- Done ---
68