1--TEST--
2Test disk_free_space and its alias diskfreespace() functions : error conditions.
3--SKIPIF--
4<?php
5if(substr(PHP_OS, 0, 3) == 'WIN')
6  die("skip Not valid on Windows");
7?>
8--FILE--
9<?php
10/*
11 *  Prototype: float disk_free_space( string directory )
12 *  Description: Given a string containing a directory, this function will
13 *               return the number of bytes available on the corresponding
14 *               filesystem or disk partition
15 */
16
17echo "*** Testing error conditions ***\n";
18$file_path = dirname(__FILE__);
19var_dump( disk_free_space() ); // Zero Arguments
20var_dump( diskfreespace() );
21
22var_dump( disk_free_space( $file_path, "extra argument") ); // More than valid number of arguments
23var_dump( diskfreespace( $file_path, "extra argument") );
24
25
26var_dump( disk_free_space( $file_path."/dir1" )); // Invalid directory
27var_dump( diskfreespace( $file_path."/dir1" ));
28
29$fh = fopen( $file_path."/disk_free_space.tmp", "w" );
30fwrite( $fh, (binary)" Garbage data for the temporary file" );
31var_dump( disk_free_space( $file_path."/disk_free_space.tmp" )); // file input instead of directory
32var_dump( diskfreespace( $file_path."/disk_free_space.tmp" ));
33fclose($fh);
34
35echo"\n-- Done --";
36?>
37--CLEAN--
38<?php
39$file_path = dirname(__FILE__);
40unlink($file_path."/disk_free_space.tmp");
41
42?>
43--EXPECTF--
44*** Testing error conditions ***
45
46Warning: disk_free_space() expects exactly 1 parameter, 0 given in %s on line %d
47NULL
48
49Warning: diskfreespace() expects exactly 1 parameter, 0 given in %s on line %d
50NULL
51
52Warning: disk_free_space() expects exactly 1 parameter, 2 given in %s on line %d
53NULL
54
55Warning: diskfreespace() expects exactly 1 parameter, 2 given in %s on line %d
56NULL
57
58Warning: disk_free_space(): No such file or directory in %s on line %d
59bool(false)
60
61Warning: diskfreespace(): No such file or directory in %s on line %d
62bool(false)
63float(%d)
64float(%d)
65
66-- Done --
67
68