posix_access.phpt 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. --TEST--
  2. Test posix_access() function test
  3. --DESCRIPTION--
  4. checks for existence, read-access, write-access, execute-access
  5. --CREDITS--
  6. Moritz Neuhaeuser, info@xcompile.net
  7. PHP Testfest Berlin 2009-05-10
  8. --SKIPIF--
  9. <?php
  10. if (!extension_loaded('posix')) {
  11. die('SKIP The posix extension is not loaded.');
  12. }
  13. if (posix_geteuid() == 0) {
  14. die('SKIP Cannot run test as root.');
  15. }
  16. if (PHP_VERSION_ID < 503099) {
  17. die('SKIP Safe mode is no longer available.');
  18. }
  19. ?>
  20. --FILE--
  21. <?php
  22. $filename = dirname(__FILE__) . '/foo.test';
  23. $fp = fopen($filename,"w");
  24. fwrite($fp,"foo");
  25. fclose($fp);
  26. chmod ($filename, 0000);
  27. var_dump(posix_access($filename, POSIX_F_OK));
  28. chmod ($filename, 0400);
  29. var_dump(posix_access($filename, POSIX_R_OK));
  30. chmod ($filename, 0600);
  31. var_dump(posix_access($filename, POSIX_W_OK));
  32. chmod ($filename, 0700);
  33. var_dump(posix_access($filename, POSIX_X_OK));
  34. ?>
  35. ===DONE===
  36. --CLEAN--
  37. <?php
  38. $filename = dirname(__FILE__) . '/foo.test';
  39. chmod ($filename, 0700);
  40. unlink($filename);
  41. ?>
  42. --EXPECTF--
  43. Deprecated: Directive 'safe_mode' is deprecated in PHP 5.3 and greater in %s on line %d
  44. bool(true)
  45. bool(true)
  46. bool(true)
  47. bool(true)
  48. ===DONE===