fileperms_variation3.phpt 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. --TEST--
  2. Test fileperms() function: usage variations - diff. path notations
  3. --CREDITS--
  4. Dave Kelsey <d_kelsey@uk.ibm.com>
  5. --FILE--
  6. <?php
  7. /* Prototype: int fileperms ( string $filename )
  8. * Description: Returns the group ID of the file, or FALSE in case of an error.
  9. */
  10. /* Passing file names with different notations, using slashes, wild-card chars */
  11. $file_path = dirname(__FILE__);
  12. echo "*** Testing fileperms() with different notations of file names ***\n";
  13. $dir_name = $file_path."/fileperms_variation3";
  14. mkdir($dir_name);
  15. $file_handle = fopen($dir_name."/fileperms_variation3.tmp", "w");
  16. fclose($file_handle);
  17. $files_arr = array(
  18. "/fileperms_variation3/fileperms_variation3.tmp",
  19. /* Testing a file trailing slash */
  20. "/fileperms_variation3/fileperms_variation3.tmp/",
  21. /* Testing file with double slashes */
  22. "/fileperms_variation3//fileperms_variation3.tmp",
  23. "//fileperms_variation3//fileperms_variation3.tmp",
  24. "/fileperms_variation3/*.tmp",
  25. "fileperms_variation3/fileperms*.tmp",
  26. /* Testing Binary safe */
  27. "/fileperms_variation3/fileperms_variation3.tmp".chr(0),
  28. "/fileperms_variation3/fileperms_variation3.tmp\0"
  29. );
  30. $count = 1;
  31. /* loop through to test each element in the above array */
  32. foreach($files_arr as $file) {
  33. echo "- Iteration $count -\n";
  34. var_dump( fileperms( $file_path."/".$file ) );
  35. clearstatcache();
  36. $count++;
  37. }
  38. echo "\n*** Done ***";
  39. ?>
  40. --CLEAN--
  41. <?php
  42. $file_path = dirname(__FILE__);
  43. $dir_name = $file_path."/fileperms_variation3";
  44. unlink($dir_name."/fileperms_variation3.tmp");
  45. rmdir($dir_name);
  46. ?>
  47. --EXPECTF--
  48. *** Testing fileperms() with different notations of file names ***
  49. - Iteration 1 -
  50. int(%d)
  51. - Iteration 2 -
  52. Warning: fileperms(): stat failed for %s//fileperms_variation3/fileperms_variation3.tmp/ in %s on line %d
  53. bool(false)
  54. - Iteration 3 -
  55. int(%d)
  56. - Iteration 4 -
  57. int(%d)
  58. - Iteration 5 -
  59. Warning: fileperms(): stat failed for %s//fileperms_variation3/*.tmp in %s on line %d
  60. bool(false)
  61. - Iteration 6 -
  62. Warning: fileperms(): stat failed for %s/fileperms_variation3/fileperms*.tmp in %s on line %d
  63. bool(false)
  64. - Iteration 7 -
  65. Warning: fileperms() expects parameter 1 to be a valid path, string given in %s on line %d
  66. NULL
  67. - Iteration 8 -
  68. Warning: fileperms() expects parameter 1 to be a valid path, string given in %s on line %d
  69. NULL
  70. *** Done ***