1--TEST--
2Test disk_free_space and its alias diskfreespace() functions : Usage Variations
3--FILE--
4<?php
5$file_path = __DIR__;
6
7echo "*** Testing with a directory ***\n";
8var_dump( disk_free_space($file_path."/..") );
9var_dump( diskfreespace($file_path."/..") );
10
11echo "\nTesting for the return type ***\n";
12$return_value = disk_free_space($file_path);
13var_dump( is_float($return_value) );
14
15echo "\n*** Testing with different directory combinations ***";
16$dir = "/disk_free_space_variation";
17mkdir($file_path.$dir);
18
19$dirs_arr = array(
20  ".",
21  $file_path.$dir,
22  $file_path."/.".$dir,
23
24  /* Testing a file trailing slash */
25  $file_path."".$dir."/",
26  $file_path."/.".$dir."/",
27
28  /* Testing file with double trailing slashes */
29  $file_path.$dir."//",
30  $file_path."/.".$dir."//",
31  $file_path."/./".$dir."//",
32
33  /* Testing Binary safe */
34  $file_path.$dir.chr(0),
35  $file_path."/.".$dir.chr(0),
36  ".".chr(0).$file_path.$dir,
37  ".".chr(0).$file_path.$dir.chr(0)
38);
39
40$count = 1;
41/* loop through to test each element the above array */
42foreach($dirs_arr as $dir1) {
43  echo "\n-- Iteration $count --\n";
44  try {
45    var_dump( disk_free_space( $dir1 ) );
46  } catch (Error $e) {
47    echo $e->getMessage(), "\n";
48  }
49  try {
50    var_dump( diskfreespace( $dir1 ) );
51  } catch (Error $e) {
52    echo $e->getMessage(), "\n";
53  }
54  $count++;
55}
56
57echo"\n--- Done ---";
58?>
59--CLEAN--
60<?php
61$file_path = __DIR__;
62rmdir($file_path."/disk_free_space_variation");
63?>
64--EXPECTF--
65*** Testing with a directory ***
66float(%f)
67float(%f)
68
69Testing for the return type ***
70bool(true)
71
72*** Testing with different directory combinations ***
73-- Iteration 1 --
74float(%f)
75float(%f)
76
77-- Iteration 2 --
78float(%f)
79float(%f)
80
81-- Iteration 3 --
82float(%f)
83float(%f)
84
85-- Iteration 4 --
86float(%f)
87float(%f)
88
89-- Iteration 5 --
90float(%f)
91float(%f)
92
93-- Iteration 6 --
94float(%f)
95float(%f)
96
97-- Iteration 7 --
98float(%f)
99float(%f)
100
101-- Iteration 8 --
102float(%f)
103float(%f)
104
105-- Iteration 9 --
106disk_free_space(): Argument #1 ($directory) must not contain any null bytes
107diskfreespace(): Argument #1 ($directory) must not contain any null bytes
108
109-- Iteration 10 --
110disk_free_space(): Argument #1 ($directory) must not contain any null bytes
111diskfreespace(): Argument #1 ($directory) must not contain any null bytes
112
113-- Iteration 11 --
114disk_free_space(): Argument #1 ($directory) must not contain any null bytes
115diskfreespace(): Argument #1 ($directory) must not contain any null bytes
116
117-- Iteration 12 --
118disk_free_space(): Argument #1 ($directory) must not contain any null bytes
119diskfreespace(): Argument #1 ($directory) must not contain any null bytes
120
121--- Done ---
122