fopen_variation16.phpt 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. --TEST--
  2. Test fopen() function : variation: use include path create and read a file (relative)
  3. --CREDITS--
  4. Dave Kelsey <d_kelsey@uk.ibm.com>
  5. --FILE--
  6. <?php
  7. /* Prototype : resource fopen(string filename, string mode [, bool use_include_path [, resource context]])
  8. * Description: Open a file or a URL and return a file pointer
  9. * Source code: ext/standard/file.c
  10. * Alias to functions:
  11. */
  12. require_once('fopen_include_path.inc');
  13. $thisTestDir = "fopenVariation16.dir";
  14. mkdir($thisTestDir);
  15. chdir($thisTestDir);
  16. $newpath = create_include_path();
  17. set_include_path($newpath);
  18. runtest();
  19. $newpath = generate_next_path();
  20. set_include_path($newpath);
  21. runtest();
  22. teardown_include_path();
  23. restore_include_path();
  24. chdir("..");
  25. rmdir($thisTestDir);
  26. function runtest() {
  27. global $dir1;
  28. $extraDir = "extraDir16";
  29. mkdir($dir1.'/'.$extraDir);
  30. mkdir($extraDir);
  31. $tmpfile = $extraDir.'/fopen_variation16.tmp';
  32. $h = fopen($tmpfile, "w+", true);
  33. fwrite($h, (binary) "This is the test file");
  34. fclose($h);
  35. $h = @fopen($dir1.'/'.$tmpfile, "r");
  36. if ($h === false) {
  37. echo "Not created in dir1\n";
  38. }
  39. else {
  40. echo "created in dir1\n";
  41. fclose($h);
  42. }
  43. $h = fopen($tmpfile, "r", true);
  44. if ($h === false) {
  45. echo "could not find file for reading\n";
  46. }
  47. else {
  48. echo "found file - not in dir1\n";
  49. fclose($h);
  50. }
  51. unlink($tmpfile);
  52. rmdir($dir1.'/'.$extraDir);
  53. rmdir($extraDir);
  54. }
  55. ?>
  56. ===DONE===
  57. --EXPECT--
  58. Not created in dir1
  59. found file - not in dir1
  60. Not created in dir1
  61. found file - not in dir1
  62. ===DONE===