1--TEST--
2Test is_executable() function: usage variations - file/dir with diff. perms
3--SKIPIF--
4<?php
5if (substr(PHP_OS, 0, 3) == 'WIN') {
6    die('skip not for windows');
7}
8// Skip if being run by root
9$filename = dirname(__FILE__)."/is_readable_root_check.tmp";
10$fp = fopen($filename, 'w');
11fclose($fp);
12if(fileowner($filename) == 0) {
13        unlink ($filename);
14        die('skip cannot be run as root');
15}
16
17unlink($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 file/dir having different permissions */
26
27require dirname(__FILE__).'/file.inc';
28echo "*** Testing is_executable(): usage variations ***\n";
29
30$file_path = dirname(__FILE__);
31mkdir("$file_path/is_executable_variation2");
32
33echo "\n*** Testing is_executable() on directory without execute permission ***\n";
34chmod("$file_path/is_executable_variation2", 0444);
35var_dump( is_executable("$file_path/is_executable_variation2") );  // exp: bool(false)
36chmod("$file_path/is_executable_variation2", 0777);  // chmod to enable deletion of directory
37
38echo "\n*** Testing miscelleneous input for is_executable() function ***\n";
39$name_prefix = "is_executable_variation2";
40create_files(dirname(__FILE__), 1, "numeric", 0755, 1, "w", $name_prefix, 1);
41create_files(dirname(__FILE__), 1, "text", 0755, 1, "w", $name_prefix, 2);
42create_files(dirname(__FILE__), 1, "empty", 0755, 1, "w", $name_prefix, 3);
43create_files(dirname(__FILE__), 1, "numeric", 0755, 1, "w", $name_prefix, 4);
44create_files(dirname(__FILE__), 1, "text", 0222, 1, "w", $name_prefix, 5);
45create_files(dirname(__FILE__), 1, "numeric", 0711, 1, "w", $name_prefix, 6);
46create_files(dirname(__FILE__), 1, "text", 0714, 1, "w", $name_prefix, 7);
47create_files(dirname(__FILE__), 1, "numeric", 0744, 1, "w", $name_prefix, 8);
48create_files(dirname(__FILE__), 1, "text", 0421, 1, "w", $name_prefix, 9);
49create_files(dirname(__FILE__), 1, "text", 0712, 1, "w", $name_prefix, 10);
50
51$files = array (
52  "$file_path/is_executable_variation21.tmp",
53  "$file_path/is_executable_variation22.tmp",
54  "$file_path/is_executable_variation23.tmp",
55  "$file_path/is_executable_variation24.tmp",
56  "$file_path/is_executable_variation25.tmp",
57  "$file_path/is_executable_variation26.tmp",
58  "$file_path/is_executable_variation27.tmp",
59  "$file_path/is_executable_variation28.tmp",
60  "$file_path/is_executable_variation29.tmp",
61  "$file_path/is_executable_variation210.tmp",
62);
63$counter = 1;
64/* loop through to test each element in the above array
65   is an executable file */
66foreach($files as $file) {
67  echo "-- Iteration $counter --\n";
68  var_dump( is_executable($file) );
69  $counter++;
70  clearstatcache();
71}
72
73// change all file's permissions to 777 before deleting
74change_file_perms($file_path, 10, 0777, $name_prefix);
75delete_files($file_path, 10, $name_prefix);
76
77echo "Done\n";
78?>
79--CLEAN--
80<?php
81rmdir(dirname(__FILE__)."/is_executable_variation2/");
82?>
83--EXPECTF--
84*** Testing is_executable(): usage variations ***
85
86*** Testing is_executable() on directory without execute permission ***
87bool(false)
88
89*** Testing miscelleneous input for is_executable() function ***
90-- Iteration 1 --
91bool(true)
92-- Iteration 2 --
93bool(true)
94-- Iteration 3 --
95bool(true)
96-- Iteration 4 --
97bool(true)
98-- Iteration 5 --
99bool(false)
100-- Iteration 6 --
101bool(true)
102-- Iteration 7 --
103bool(true)
104-- Iteration 8 --
105bool(true)
106-- Iteration 9 --
107bool(false)
108-- Iteration 10 --
109bool(true)
110Done
111