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

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

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