1--TEST--
2Test is_readable() 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}
8require __DIR__ . '/../skipif_root.inc';
9?>
10--FILE--
11<?php
12/* test is_executable() with file/dir having different permissions */
13
14require __DIR__.'/file.inc';
15echo "*** Testing is_readable(): usage variations ***\n";
16
17$file_path = __DIR__;
18mkdir("$file_path/is_readable_variation2");
19
20echo "\n*** Testing is_readable() on directory without read permission ***\n";
21chmod("$file_path/is_readable_variation2", 0001);
22var_dump( is_readable("$file_path/is_readable_variation2") );  // exp: bool(false)
23chmod("$file_path/is_readable_variation2", 0777);  // chmod to enable deletion of directory
24
25echo "\n*** Testing miscellaneous input for is_readable() function ***\n";
26$name_prefix = "is_readable_variation2";
27create_files(__DIR__, 1, "numeric", 0755, 1, "w", $name_prefix, 1);
28create_files(__DIR__, 1, "text", 0755, 1, "w", $name_prefix, 2);
29create_files(__DIR__, 1, "empty", 0755, 1, "w", $name_prefix, 3);
30create_files(__DIR__, 1, "numeric", 0555, 1, "w", $name_prefix, 4);
31create_files(__DIR__, 1, "text", 0222, 1, "w", $name_prefix, 5);
32create_files(__DIR__, 1, "numeric", 0711, 1, "w", $name_prefix, 6);
33create_files(__DIR__, 1, "text", 0411, 1, "w", $name_prefix, 7);
34create_files(__DIR__, 1, "numeric", 0444, 1, "w", $name_prefix, 8);
35create_files(__DIR__, 1, "text", 0421, 1, "w", $name_prefix, 9);
36create_files(__DIR__, 1, "text", 0422, 1, "w", $name_prefix, 10);
37
38$files = array (
39  "$file_path/is_readable_variation21.tmp",
40  "$file_path/is_readable_variation22.tmp",
41  "$file_path/is_readable_variation23.tmp",
42  "$file_path/is_readable_variation24.tmp",
43  "$file_path/is_readable_variation25.tmp",
44  "$file_path/is_readable_variation26.tmp",
45  "$file_path/is_readable_variation27.tmp",
46  "$file_path/is_readable_variation28.tmp",
47  "$file_path/is_readable_variation29.tmp",
48  "$file_path/is_readable_variation210.tmp"
49);
50$counter = 1;
51/* loop through to test each element in the above array
52   is a readable file */
53foreach($files as $file) {
54  echo "-- Iteration $counter --\n";
55  var_dump( is_readable($file) );
56  $counter++;
57  clearstatcache();
58}
59
60// change all file's permissions to 777 before deleting
61change_file_perms($file_path, 10, 0777, $name_prefix);
62delete_files($file_path, 10, $name_prefix);
63
64echo "Done\n";
65?>
66--CLEAN--
67<?php
68rmdir(__DIR__."/is_readable_variation2/");
69?>
70--EXPECT--
71*** Testing is_readable(): usage variations ***
72
73*** Testing is_readable() on directory without read permission ***
74bool(false)
75
76*** Testing miscellaneous input for is_readable() function ***
77-- Iteration 1 --
78bool(true)
79-- Iteration 2 --
80bool(true)
81-- Iteration 3 --
82bool(true)
83-- Iteration 4 --
84bool(true)
85-- Iteration 5 --
86bool(false)
87-- Iteration 6 --
88bool(true)
89-- Iteration 7 --
90bool(true)
91-- Iteration 8 --
92bool(true)
93-- Iteration 9 --
94bool(true)
95-- Iteration 10 --
96bool(true)
97Done
98