fileinode_variation3.phpt 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. --TEST--
  2. Test fileinode() function: usage variations - diff. path notations
  3. --CREDITS--
  4. Dave Kelsey <d_kelsey@uk.ibm.com>
  5. --FILE--
  6. <?php
  7. /*
  8. Prototype: int fileinode ( string $filename );
  9. Description: Returns the inode number of the file, or FALSE in case of an error.
  10. */
  11. /* Passing file names with different notations, using slashes, wild-card chars */
  12. $file_path = dirname(__FILE__);
  13. echo "*** Testing fileinode() with different notations of file names ***\n";
  14. $dir_name = $file_path."/fileinode_variation3";
  15. mkdir($dir_name);
  16. $file_handle = fopen($dir_name."/fileinode_variation3.tmp", "w");
  17. fclose($file_handle);
  18. $files_arr = array(
  19. "/fileinode_variation3/fileinode_variation3.tmp",
  20. /* Testing a file trailing slash */
  21. "/fileinode_variation3/fileinode_variation3.tmp/",
  22. /* Testing file with double slashes */
  23. "/fileinode_variation3//fileinode_variation3.tmp",
  24. "//fileinode_variation3//fileinode_variation3.tmp",
  25. "/fileinode_variation3/*.tmp",
  26. "fileinode_variation3/fileinode*.tmp",
  27. /* Testing Binary safe */
  28. "/fileinode_variation3/fileinode_variation3.tmp".chr(0),
  29. "/fileinode_variation3/fileinode_variation3.tmp\0"
  30. );
  31. $count = 1;
  32. /* loop through to test each element in the above array */
  33. foreach($files_arr as $file) {
  34. echo "- Iteration $count -\n";
  35. var_dump( fileinode( $file_path."/".$file ) );
  36. clearstatcache();
  37. $count++;
  38. }
  39. echo "\n*** Done ***";
  40. ?>
  41. --CLEAN--
  42. <?php
  43. $file_path = dirname(__FILE__);
  44. $dir_name = $file_path."/fileinode_variation3";
  45. unlink($dir_name."/fileinode_variation3.tmp");
  46. rmdir($dir_name);
  47. ?>
  48. --EXPECTF--
  49. *** Testing fileinode() with different notations of file names ***
  50. - Iteration 1 -
  51. int(%i)
  52. - Iteration 2 -
  53. Warning: fileinode(): stat failed for %s//fileinode_variation3/fileinode_variation3.tmp/ in %s on line %d
  54. bool(false)
  55. - Iteration 3 -
  56. int(%i)
  57. - Iteration 4 -
  58. int(%i)
  59. - Iteration 5 -
  60. Warning: fileinode(): stat failed for %s//fileinode_variation3/*.tmp in %s on line %d
  61. bool(false)
  62. - Iteration 6 -
  63. Warning: fileinode(): stat failed for %s/fileinode_variation3/fileinode*.tmp in %s on line %d
  64. bool(false)
  65. - Iteration 7 -
  66. Warning: fileinode() expects parameter 1 to be a valid path, string given in %s on line %d
  67. NULL
  68. - Iteration 8 -
  69. Warning: fileinode() expects parameter 1 to be a valid path, string given in %s on line %d
  70. NULL
  71. *** Done ***