copy_variation15.phpt 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. --TEST--
  2. Test copy() function: usage variations - destination dir access perms
  3. --SKIPIF--
  4. <?php
  5. if(substr(PHP_OS, 0, 3) == 'WIN')
  6. die("skip do not run on Windows");
  7. require __DIR__ . '/../skipif_root.inc';
  8. ?>
  9. --FILE--
  10. <?php
  11. /* Test copy(): Trying to create a copy of file in a dir which doesn't have write permissions */
  12. $file_path = __DIR__;
  13. echo "*** Test copy() function: Trying to create a copy of file in a dir which doesn't have write permissions ***";
  14. $file = $file_path."/copy_variation15.tmp";
  15. $file_handle = fopen($file, "w");
  16. fwrite($file_handle, str_repeat("Hello, world...", 20));
  17. fclose($file_handle);
  18. $dir = $file_path."/copy_variation15";
  19. mkdir($dir);
  20. $old_perms = fileperms($dir);
  21. chmod($dir, 0555); //dir without write permissions
  22. $dest = $dir."/copy_copy_variation15.tmp";
  23. var_dump( copy($file, $dir."/copy_copy_variation15.tmp") );
  24. var_dump( file_exists($dir."/copy_copy_variation15_dir.tmp") );
  25. var_dump( filesize($file) ); //size of source
  26. chmod($dir, $old_perms);
  27. echo "*** Done ***\n";
  28. ?>
  29. --CLEAN--
  30. <?php
  31. unlink(__DIR__."/copy_variation15.tmp");
  32. rmdir(__DIR__."/copy_variation15");
  33. ?>
  34. --EXPECTF--
  35. *** Test copy() function: Trying to create a copy of file in a dir which doesn't have write permissions ***
  36. Warning: copy(%s): %s
  37. bool(false)
  38. bool(false)
  39. int(300)
  40. *** Done ***