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