readlink_variation1.phpt 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. --TEST--
  2. Test readlink() function: usage variations - invalid filenames
  3. --CREDITS--
  4. Dave Kelsey <d_kelsey@uk.ibm.com>
  5. --SKIPIF--
  6. <?php
  7. if (substr(PHP_OS, 0, 3) == 'WIN') {
  8. die('skip no links on Windows');
  9. }
  10. ?>
  11. --FILE--
  12. <?php
  13. /* Prototype: string readlink ( string $path );
  14. Description: Returns the target of a symbolic link */
  15. /* Testing readlink() with invalid arguments -int, float, bool, NULL, resource */
  16. $file_path = dirname(__FILE__);
  17. $file_handle = fopen($file_path."/readlink_variation2.tmp", "w");
  18. echo "*** Testing Invalid file types ***\n";
  19. $filenames = array(
  20. /* Invalid filenames */
  21. -2.34555,
  22. "",
  23. TRUE,
  24. FALSE,
  25. NULL,
  26. $file_handle,
  27. /* scalars */
  28. 1234,
  29. 0
  30. );
  31. /* loop through to test each element the above array */
  32. foreach( $filenames as $filename ) {
  33. var_dump( readlink($filename) );
  34. clearstatcache();
  35. }
  36. fclose($file_handle);
  37. echo "\n*** Done ***";
  38. ?>
  39. --CLEAN--
  40. <?php
  41. $file_path = dirname(__FILE__);
  42. unlink($file_path."/readlink_variation2.tmp");
  43. ?>
  44. --EXPECTF--
  45. *** Testing Invalid file types ***
  46. Warning: readlink(): %s in %s on line %d
  47. bool(false)
  48. Warning: readlink(): %s in %s on line %d
  49. bool(false)
  50. Warning: readlink(): %s in %s on line %d
  51. bool(false)
  52. Warning: readlink(): %s in %s on line %d
  53. bool(false)
  54. Warning: readlink(): %s in %s on line %d
  55. bool(false)
  56. Warning: readlink() expects parameter 1 to be a valid path, resource given in %s on line %d
  57. NULL
  58. Warning: readlink(): %s in %s on line %d
  59. bool(false)
  60. Warning: readlink(): %s in %s on line %d
  61. bool(false)
  62. *** Done ***