Annotation of embedaddon/php/ext/standard/tests/file/is_readable_variation3.phpt, revision 1.1.1.2

1.1       misho       1: --TEST--
                      2: Test is_readable() function: usage variations - invalid file names
                      3: --SKIPIF--
                      4: <?php
                      5: if (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: 
                     26: echo "*** Testing is_readable(): usage variations ***\n";
                     27: 
                     28: $file_handle = fopen(__FILE__, "r");
                     29: unset($file_handle);
                     30: 
                     31: echo "\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 */
                     45: foreach( $misc_files as $misc_file ) {
                     46:   var_dump( is_readable($misc_file) );
                     47:   clearstatcache();
                     48: }
                     49: 
                     50: echo "Done\n";
                     51: ?>
                     52: --EXPECTF--
                     53: *** Testing is_readable(): usage variations ***
                     54: 
                     55: *** Testing is_readable() on miscelleneous filenames ***
                     56: bool(false)
                     57: bool(false)
                     58: bool(false)
                     59: bool(false)
                     60: bool(false)
                     61: bool(false)
                     62: bool(false)
                     63: 
1.1.1.2 ! misho      64: Warning: is_readable() expects parameter 1 to be a valid path, array given in %s on line %d
1.1       misho      65: NULL
                     66: bool(false)
                     67: Done
                     68: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>