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 Valid only for 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, " 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(): The system cannot find the path specified.
59 in %s on line %d
60bool(false)
61
62Warning: diskfreespace(): The system cannot find the path specified.
63 in %s on line %d
64bool(false)
65
66Warning: disk_free_space(): The directory name is invalid.
67 in %s on line %d
68bool(false)
69
70Warning: diskfreespace(): The directory name is invalid.
71 in %s on line %d
72bool(false)
73
74-- Done --
75