006_basic.phpt 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. --TEST--
  2. Test fileperms() & chmod() functions: basic functionality
  3. --SKIPIF--
  4. <?php
  5. if (substr(PHP_OS, 0, 3) == 'WIN') {
  6. die('skip Not on Windows');
  7. }
  8. // Skip if being run by root
  9. $filename = dirname(__FILE__)."/006_root_check.tmp";
  10. $fp = fopen($filename, 'w');
  11. fclose($fp);
  12. if(fileowner($filename) == 0) {
  13. unlink ($filename);
  14. die('skip cannot be run as root');
  15. }
  16. unlink($filename);
  17. ?>
  18. --FILE--
  19. <?php
  20. /*
  21. Prototype: int fileperms ( string $filename );
  22. Description: Returns the permissions on the file, or FALSE in case of an error
  23. Prototype: bool chmod ( string $filename, int $mode );
  24. Description: Attempts to change the mode of the file specified by
  25. filename to that given in mode
  26. */
  27. $path = dirname(__FILE__);
  28. echo "*** Testing fileperms(), chmod() with files and dirs ***\n";
  29. fopen($path."/perm.tmp", "w");
  30. var_dump( chmod($path."/perm.tmp", 0755 ) );
  31. printf("%o", fileperms($path."/perm.tmp") );
  32. echo "\n";
  33. clearstatcache();
  34. mkdir($path."/perm");
  35. var_dump( chmod( $path."/perm", 0777 ) );
  36. printf("%o", fileperms($path."/perm") );
  37. echo "\n";
  38. clearstatcache();
  39. echo "Done\n";
  40. ?>
  41. --CLEAN--
  42. <?php
  43. unlink(dirname(__FILE__)."/perm.tmp");
  44. rmdir(dirname(__FILE__)."/perm");
  45. ?>
  46. --EXPECTF--
  47. *** Testing fileperms(), chmod() with files and dirs ***
  48. bool(true)
  49. 100755
  50. bool(true)
  51. 40777
  52. Done