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
34if($space1 > $space2 )
35  echo "\n Free Space Value Is Correct\n";
36else {
37  echo "\n Free Space Value Is Incorrect\n";
38  var_dump($space1, $space2);
39}
40
41echo "*** Testing with Binary Input ***\n";
42var_dump( disk_free_space(b"$file_path") );
43
44echo"\n--- Done ---";
45?>
46--CLEAN--
47<?php
48$file_path = __DIR__;
49unlink($file_path."/disk_free_space/disk_free_space.tmp");
50rmdir($file_path."/disk_free_space");
51?>
52--EXPECTF--
53*** Testing with existing directory ***
54float(%f)
55float(%f)
56*** Testing with newly created directory ***
57
58 Free Space before writing to a file
59float(%f)
60
61 Free Space after writing to a file
62float(%f)
63
64 Free Space Value Is Correct
65*** Testing with Binary Input ***
66float(%f)
67
68--- Done ---
69