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