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

1.1       misho       1: --TEST--
                      2: Test is_readable() function: usage variations - diff. file notations
                      3: --SKIPIF--
                      4: <?php
                      5: if (substr(PHP_OS, 0, 3) != 'WIN') {
                      6:   // Skip if being run by root (files are always readable, writeable and executable)
                      7:   $filename = dirname(__FILE__)."/is_readable_root_check.tmp";
                      8:   $fp = fopen($filename, 'w');
                      9:   fclose($fp);
                     10:   if(fileowner($filename) == 0) {
                     11:         unlink ($filename);
                     12:         die('skip cannot be run as root');
                     13:   }
                     14:   unlink($filename);
                     15: }
                     16: ?>
                     17: --FILE--
                     18: <?php
                     19: /* Prototype: bool is_readable ( string $filename );
                     20:    Description: Tells whether the filename is readable.
                     21: */
                     22: 
                     23: /* test is_readable() with file having different filepath notation */
                     24: 
                     25: require dirname(__FILE__).'/file.inc';
                     26: echo "*** Testing is_readable(): usage variations ***\n";
                     27: 
                     28: $file_path = dirname(__FILE__);
                     29: mkdir("$file_path/is_readable_variation1");
                     30: 
                     31: // create a new temporary file
                     32: $fp = fopen("$file_path/is_readable_variation1/bar.tmp", "w");
                     33: fclose($fp);
                     34: 
                     35: /* array of files to be tested if they are readable by using
                     36:    is_readable() function */
                     37: $files_arr = array(
                     38:   "$file_path/is_readable_variation1/bar.tmp",
                     39: 
                     40:   /* Testing a file trailing slash */
                     41:   "$file_path/is_readable_variation1/bar.tmp/",
                     42: 
                     43:   /* Testing file with double slashes */
                     44:   "$file_path/is_readable_variation1//bar.tmp",
                     45:   "$file_path//is_readable_variation1//bar.tmp",
                     46:   "$file_path/is_readable_variation1/*.tmp",
                     47:   "$file_path/is_readable_variation1/b*.tmp", 
                     48: 
                     49:   /* Testing Binary safe */
                     50:   "$file_path/is_readable_variation1".chr(0)."bar.tmp",
                     51:   "$file_path".chr(0)."is_readable_variation1/bar.tmp",
                     52:   "$file_path".chr(0)."is_readable_variation1/bar.tmp",
                     53:   
                     54:   /* Testing directories */
                     55:   ".",  // current directory, exp: bool(true)
                     56:   "$file_path/is_readable_variation1"  // temp directory, exp: bool(true)
                     57: );
                     58: $counter = 1;
                     59: /* loop through to test each element in the above array 
                     60:    is a writable file */
                     61: foreach($files_arr as $file) {
                     62:   echo "-- Iteration $counter --\n";
                     63:   var_dump( is_readable($file) );
                     64:   $counter++;
                     65:   clearstatcache();
                     66: }
                     67: 
                     68: echo "Done\n";
                     69: ?>
                     70: --CLEAN--
                     71: <?php
                     72: unlink(dirname(__FILE__)."/is_readable_variation1/bar.tmp");
                     73: rmdir(dirname(__FILE__)."/is_readable_variation1/");
                     74: ?>
                     75: --EXPECTF--
                     76: *** Testing is_readable(): usage variations ***
                     77: -- Iteration 1 --
                     78: bool(true)
                     79: -- Iteration 2 --
                     80: bool(%s)
                     81: -- Iteration 3 --
                     82: bool(true)
                     83: -- Iteration 4 --
                     84: bool(true)
                     85: -- Iteration 5 --
                     86: bool(false)
                     87: -- Iteration 6 --
                     88: bool(false)
                     89: -- Iteration 7 --
1.1.1.2 ! misho      90: 
        !            91: Warning: is_readable() expects parameter 1 to be a valid path, string given in %s on line %d
        !            92: NULL
1.1       misho      93: -- Iteration 8 --
1.1.1.2 ! misho      94: 
        !            95: Warning: is_readable() expects parameter 1 to be a valid path, string given in %s on line %d
        !            96: NULL
1.1       misho      97: -- Iteration 9 --
1.1.1.2 ! misho      98: 
        !            99: Warning: is_readable() expects parameter 1 to be a valid path, string given in %s on line %d
        !           100: NULL
1.1       misho     101: -- Iteration 10 --
                    102: bool(true)
                    103: -- Iteration 11 --
                    104: bool(true)
                    105: Done

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