rename_variation13.phpt 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. --TEST--
  2. Test rename() function : variation - various invalid paths
  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. Not for Windows");
  9. ?>
  10. --CONFLICTS--
  11. obscure_filename
  12. --FILE--
  13. <?php
  14. echo "*** Testing rename() with obscure files ***\n";
  15. $file_path = __DIR__."/renameVar13";
  16. $aFile = $file_path.'/afile.tmp';
  17. mkdir($file_path);
  18. /* An array of files */
  19. $names_arr = array(
  20. /* Invalid args */
  21. -1,
  22. TRUE,
  23. FALSE,
  24. "",
  25. " ",
  26. /* prefix with path separator of a non existing directory*/
  27. "/no/such/file/dir",
  28. "php/php"
  29. );
  30. for( $i=0; $i<count($names_arr); $i++ ) {
  31. $name = $names_arr[$i];
  32. echo @"-- testing '$name' --\n";
  33. touch($aFile);
  34. var_dump(rename($aFile, $name));
  35. if (file_exists($name)) {
  36. unlink($name);
  37. }
  38. if (file_exists($aFile)) {
  39. unlink($aFile);
  40. }
  41. var_dump(rename($name, $aFile));
  42. if (file_exists($aFile)) {
  43. unlink($aFile);
  44. }
  45. }
  46. rmdir($file_path);
  47. ?>
  48. --EXPECTF--
  49. *** Testing rename() with obscure files ***
  50. -- testing '-1' --
  51. bool(true)
  52. Warning: rename(-1,%s/renameVar13/afile.tmp): No such file or directory in %s on line %d
  53. bool(false)
  54. -- testing '1' --
  55. bool(true)
  56. Warning: rename(1,%s/renameVar13/afile.tmp): No such file or directory in %s on line %d
  57. bool(false)
  58. -- testing '' --
  59. Warning: rename(%s/renameVar13/afile.tmp,): %s in %s on line %d
  60. bool(false)
  61. Warning: rename(,%s/renameVar13/afile.tmp): %s in %s on line %d
  62. bool(false)
  63. -- testing '' --
  64. Warning: rename(%s/renameVar13/afile.tmp,): %s in %s on line %d
  65. bool(false)
  66. Warning: rename(,%s/renameVar13/afile.tmp): %s in %s on line %d
  67. bool(false)
  68. -- testing ' ' --
  69. bool(true)
  70. Warning: rename( ,%s/renameVar13/afile.tmp): No such file or directory in %s on line %d
  71. bool(false)
  72. -- testing '/no/such/file/dir' --
  73. Warning: rename(%s/renameVar13/afile.tmp,/no/such/file/dir): No such file or directory in %s on line %d
  74. bool(false)
  75. Warning: rename(/no/such/file/dir,%s/renameVar13/afile.tmp): No such file or directory in %s on line %d
  76. bool(false)
  77. -- testing 'php/php' --
  78. Warning: rename(%s/renameVar13/afile.tmp,php/php): %s directory in %s on line %d
  79. bool(false)
  80. Warning: rename(php/php,%s/renameVar13/afile.tmp): %s directory in %s on line %d
  81. bool(false)