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 = dirname(__FILE__);
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, (binary)$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
53--CLEAN--
54<?php
55$file_path = dirname(__FILE__);
56unlink($file_path."/disk_free_space/disk_free_space.tmp");
57rmdir($file_path."/disk_free_space");
58?>
59
60--EXPECTF--
61*** Testing with existing directory ***
62float(%d)
63float(%d)
64*** Testing with newly created directory ***
65
66 Free Space before writing to a file
67float(%d)
68
69 Free Space after writing to a file
70float(%d)
71
72 Free Space Value Is Correct
73*** Testing with Binary Input ***
74float(%d)
75
76--- Done ---
77