fileperms_variation2.phpt 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. --TEST--
  2. Test fileperms() function: usage variations - invalid filenames
  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. /* Testing fileperms() with invalid arguments -int, float, bool, NULL, resource */
  11. $file_path = dirname(__FILE__);
  12. $file_handle = fopen($file_path."/fileperms_variation2.tmp", "w");
  13. echo "*** Testing Invalid file types ***\n";
  14. $filenames = array(
  15. /* Invalid filenames */
  16. -2.34555,
  17. " ",
  18. "",
  19. TRUE,
  20. FALSE,
  21. NULL,
  22. $file_handle,
  23. /* scalars */
  24. 1234,
  25. 0
  26. );
  27. /* loop through to test each element the above array */
  28. foreach( $filenames as $filename ) {
  29. var_dump( fileperms($filename) );
  30. clearstatcache();
  31. }
  32. fclose($file_handle);
  33. echo "\n*** Done ***";
  34. ?>
  35. --CLEAN--
  36. <?php
  37. $file_path = dirname(__FILE__);
  38. unlink($file_path."/fileperms_variation2.tmp");
  39. ?>
  40. --EXPECTF--
  41. *** Testing Invalid file types ***
  42. Warning: fileperms(): stat failed for -2.34555 in %s on line %d
  43. bool(false)
  44. Warning: fileperms(): stat failed for in %s on line %d
  45. bool(false)
  46. bool(false)
  47. Warning: fileperms(): stat failed for 1 in %s on line %d
  48. bool(false)
  49. bool(false)
  50. bool(false)
  51. Warning: fileperms() expects parameter 1 to be a valid path, resource given in %s on line %d
  52. NULL
  53. Warning: fileperms(): stat failed for 1234 in %s on line %d
  54. bool(false)
  55. Warning: fileperms(): stat failed for 0 in %s on line %d
  56. bool(false)
  57. *** Done ***