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