1--TEST--
2Test is_executable() function: usage variations - diff. path notations
3--SKIPIF--
4<?php
5if (substr(PHP_OS, 0, 3) == 'WIN') {
6    die('skip not for windows');
7}
8?>
9--FILE--
10<?php
11/* test is_executable() with file having different filepath notation */
12
13require __DIR__.'/file.inc';
14echo "*** Testing is_executable(): usage variations ***\n";
15
16$file_path = __DIR__;
17mkdir("$file_path/is_executable_variation1");
18
19// create a new temporary file
20$fp = fopen("$file_path/is_executable_variation1/bar.tmp", "w");
21fclose($fp);
22
23/* array of files checked to see if they are executable files
24   using is_executable() function */
25$files_arr = array(
26  "$file_path/is_executable_variation1/bar.tmp",
27
28  /* Testing a file with trailing slash */
29  "$file_path/is_executable_variation1/bar.tmp/",
30
31  /* Testing file with double slashes */
32  "$file_path/is_executable_variation1//bar.tmp",
33  "$file_path/is_executable_variation1/*.tmp",
34  "$file_path/is_executable_variation1/b*.tmp",
35
36  /* Testing Binary safe */
37  "$file_path/is_executable_variation1".chr(0)."bar.temp",
38  "$file_path".chr(0)."is_executable_variation1/bar.temp",
39  "$file_path/is_executable_variation1x000/",
40
41  /* Testing directories */
42  ".",  // current directory, exp: bool(true)
43  "$file_path/is_executable_variation1"  // temp directory, exp: bool(true)
44);
45$counter = 1;
46/* loop through to test each element in the above array
47   is an executable file */
48foreach($files_arr as $file) {
49  echo "-- Iteration $counter --\n";
50  try {
51    var_dump( is_executable($file) );
52  } catch (Error $e) {
53    echo $e->getMessage(), "\n";
54  }
55  $counter++;
56  clearstatcache();
57}
58
59echo "Done\n";
60?>
61--CLEAN--
62<?php
63unlink(__DIR__."/is_executable_variation1/bar.tmp");
64rmdir(__DIR__."/is_executable_variation1/");
65?>
66--EXPECT--
67*** Testing is_executable(): usage variations ***
68-- Iteration 1 --
69bool(false)
70-- Iteration 2 --
71bool(false)
72-- Iteration 3 --
73bool(false)
74-- Iteration 4 --
75bool(false)
76-- Iteration 5 --
77bool(false)
78-- Iteration 6 --
79bool(false)
80-- Iteration 7 --
81bool(false)
82-- Iteration 8 --
83bool(false)
84-- Iteration 9 --
85bool(true)
86-- Iteration 10 --
87bool(true)
88Done
89