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