Annotation of embedaddon/php/ext/standard/tests/file/is_writable_variation3.phpt, revision 1.1.1.2
1.1 misho 1: --TEST--
2: Test is_writable() and its alias is_writeable() function: usage variations - invalid file names
3: --SKIPIF--
4: <?php
5: if (substr(PHP_OS, 0, 3) != 'WIN') {
6: // Skip if being run by root (files are always readable, writeable and executable)
7: $filename = dirname(__FILE__)."/is_writable_root_check.tmp";
8: $fp = fopen($filename, 'w');
9: fclose($fp);
10: if(fileowner($filename) == 0) {
11: unlink ($filename);
12: die('skip cannot be run as root');
13: }
14: unlink($filename);
15: }
16: ?>
17: --FILE--
18: <?php
19: /* Prototype: bool is_writable ( string $filename );
20: Description: Tells whether the filename is writable.
21:
22: is_writeable() is an alias of is_writable()
23: */
24:
25: /* test is_writable() & is_writeable() with invalid arguments */
26:
27: echo "*** Testing is_writable(): usage variations ***\n";
28:
29: echo "\n*** Testing is_writable() with invalid filenames ***\n";
30: $misc_files = array(
31: 0,
32: 1234,
33: -2.34555,
34: TRUE,
35: FALSE,
36: NULL,
37: " ",
38: @array(),
39: @$file_handle
40: );
41: /* loop through to test each element in the above array
42: is a writable file */
43: foreach( $misc_files as $misc_file ) {
44: var_dump( is_writable($misc_file) );
45: var_dump( is_writeable($misc_file) );
46: clearstatcache();
47: }
48:
49: echo "Done\n";
50: ?>
51: --EXPECTF--
52: *** Testing is_writable(): usage variations ***
53:
54: *** Testing is_writable() with invalid filenames ***
55: bool(false)
56: bool(false)
57: bool(false)
58: bool(false)
59: bool(false)
60: bool(false)
61: bool(false)
62: bool(false)
63: bool(false)
64: bool(false)
65: bool(false)
66: bool(false)
67: bool(false)
68: bool(false)
69:
1.1.1.2 ! misho 70: Warning: is_writable() expects parameter 1 to be a valid path, array given in %s on line %d
1.1 misho 71: NULL
72:
1.1.1.2 ! misho 73: Warning: is_writeable() expects parameter 1 to be a valid path, array given in %s on line %d
1.1 misho 74: NULL
75: bool(false)
76: bool(false)
77: Done
78:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>