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