Annotation of embedaddon/php/ext/standard/tests/file/is_executable_variation2.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Test is_executable() function: usage variations - file/dir with diff. perms
                      3: --SKIPIF--
                      4: <?php
                      5: if (substr(PHP_OS, 0, 3) == 'WIN') {
                      6:     die('skip not for windows');
                      7: }
                      8: // Skip if being run by root 
                      9: $filename = dirname(__FILE__)."/is_readable_root_check.tmp";
                     10: $fp = fopen($filename, 'w');
                     11: fclose($fp);
                     12: if(fileowner($filename) == 0) {
                     13:         unlink ($filename);
                     14:         die('skip cannot be run as root');
                     15: }
                     16: 
                     17: unlink($filename);
                     18: ?>
                     19: --FILE--
                     20: <?php
                     21: /* Prototype: bool is_executable ( string $filename );
                     22:    Description: Tells whether the filename is executable
                     23: */
                     24: 
                     25: /* test is_executable() with file/dir having different permissions */
                     26: 
                     27: require dirname(__FILE__).'/file.inc';
                     28: echo "*** Testing is_executable(): usage variations ***\n";
                     29: 
                     30: $file_path = dirname(__FILE__);
                     31: mkdir("$file_path/is_executable_variation2");
                     32: 
                     33: echo "\n*** Testing is_executable() on directory without execute permission ***\n";
                     34: chmod("$file_path/is_executable_variation2", 0444);
                     35: var_dump( is_executable("$file_path/is_executable_variation2") );  // exp: bool(false)
                     36: chmod("$file_path/is_executable_variation2", 0777);  // chmod to enable deletion of directory
                     37: 
                     38: echo "\n*** Testing miscelleneous input for is_executable() function ***\n";
                     39: $name_prefix = "is_executable_variation2";
                     40: create_files(dirname(__FILE__), 1, "numeric", 0755, 1, "w", $name_prefix, 1);
                     41: create_files(dirname(__FILE__), 1, "text", 0755, 1, "w", $name_prefix, 2);
                     42: create_files(dirname(__FILE__), 1, "empty", 0755, 1, "w", $name_prefix, 3);
                     43: create_files(dirname(__FILE__), 1, "numeric", 0755, 1, "w", $name_prefix, 4);
                     44: create_files(dirname(__FILE__), 1, "text", 0222, 1, "w", $name_prefix, 5);
                     45: create_files(dirname(__FILE__), 1, "numeric", 0711, 1, "w", $name_prefix, 6);
                     46: create_files(dirname(__FILE__), 1, "text", 0714, 1, "w", $name_prefix, 7);
                     47: create_files(dirname(__FILE__), 1, "numeric", 0744, 1, "w", $name_prefix, 8);
                     48: create_files(dirname(__FILE__), 1, "text", 0421, 1, "w", $name_prefix, 9);
                     49: create_files(dirname(__FILE__), 1, "text", 0712, 1, "w", $name_prefix, 10);
                     50: 
                     51: $files = array (
                     52:   "$file_path/is_executable_variation21.tmp",
                     53:   "$file_path/is_executable_variation22.tmp",
                     54:   "$file_path/is_executable_variation23.tmp",
                     55:   "$file_path/is_executable_variation24.tmp",
                     56:   "$file_path/is_executable_variation25.tmp",
                     57:   "$file_path/is_executable_variation26.tmp",
                     58:   "$file_path/is_executable_variation27.tmp",
                     59:   "$file_path/is_executable_variation28.tmp",
                     60:   "$file_path/is_executable_variation29.tmp",
                     61:   "$file_path/is_executable_variation210.tmp",
                     62: );
                     63: $counter = 1;
                     64: /* loop through to test each element in the above array
                     65:    is an executable file */
                     66: foreach($files as $file) {
                     67:   echo "-- Iteration $counter --\n";
                     68:   var_dump( is_executable($file) );
                     69:   $counter++;
                     70:   clearstatcache();
                     71: }
                     72: 
                     73: // change all file's permissions to 777 before deleting
                     74: change_file_perms($file_path, 10, 0777, $name_prefix);
                     75: delete_files($file_path, 10, $name_prefix);
                     76: 
                     77: echo "Done\n";
                     78: ?>
                     79: --CLEAN--
                     80: <?php
                     81: rmdir(dirname(__FILE__)."/is_executable_variation2/");
                     82: ?>
                     83: --EXPECTF--
                     84: *** Testing is_executable(): usage variations ***
                     85: 
                     86: *** Testing is_executable() on directory without execute permission ***
                     87: bool(false)
                     88: 
                     89: *** Testing miscelleneous input for is_executable() function ***
                     90: -- Iteration 1 --
                     91: bool(true)
                     92: -- Iteration 2 --
                     93: bool(true)
                     94: -- Iteration 3 --
                     95: bool(true)
                     96: -- Iteration 4 --
                     97: bool(true)
                     98: -- Iteration 5 --
                     99: bool(false)
                    100: -- Iteration 6 --
                    101: bool(true)
                    102: -- Iteration 7 --
                    103: bool(true)
                    104: -- Iteration 8 --
                    105: bool(true)
                    106: -- Iteration 9 --
                    107: bool(false)
                    108: -- Iteration 10 --
                    109: bool(true)
                    110: Done

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