symlink.phpt 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. --TEST--
  2. symlink() & friends
  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. $filename = __DIR__."/symlink.dat";
  12. $link = __DIR__."/symlink.link";
  13. var_dump(symlink($filename, $link));
  14. var_dump(readlink($link));
  15. var_dump(linkinfo($link));
  16. @unlink($link);
  17. var_dump(readlink($link));
  18. var_dump(linkinfo($link));
  19. touch($filename);
  20. var_dump(symlink($filename, __DIR__));
  21. @unlink($link);
  22. var_dump(symlink($filename, $link));
  23. @unlink($link);
  24. touch($link);
  25. var_dump(symlink($filename, $link));
  26. @unlink($link);
  27. var_dump(link($filename, $link));
  28. @unlink($filename);
  29. var_dump(link($filename, $link));
  30. @unlink($link);
  31. var_dump(symlink(".", "."));
  32. var_dump(link(".", "."));
  33. var_dump(readlink("."));
  34. var_dump(linkinfo("."));
  35. echo "Done\n";
  36. ?>
  37. --EXPECTF--
  38. bool(true)
  39. string(%d) "%ssymlink.dat"
  40. int(%d)
  41. Warning: readlink(): No such file or directory in %s on line %d
  42. bool(false)
  43. Warning: linkinfo(): No such file or directory in %s on line %d
  44. int(-1)
  45. Warning: symlink(): File exists in %s on line %d
  46. bool(false)
  47. bool(true)
  48. Warning: symlink(): File exists in %s on line %d
  49. bool(false)
  50. bool(true)
  51. Warning: link(): No such file or directory in %s on line %d
  52. bool(false)
  53. Warning: symlink(): %s in %s on line %d
  54. bool(false)
  55. Warning: link(): %s in %s on line %d
  56. bool(false)
  57. Warning: readlink(): Invalid argument in %s on line %d
  58. bool(false)
  59. int(%d)
  60. Done