fopen_variation9.phpt 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. --TEST--
  2. Test fopen() function : variation: use include path and stream context create a file, relative path
  3. --CREDITS--
  4. Dave Kelsey <d_kelsey@uk.ibm.com>
  5. --FILE--
  6. <?php
  7. require_once('fopen_include_path.inc');
  8. $thisTestDir = basename(__FILE__, ".php") . ".dir";
  9. mkdir($thisTestDir);
  10. chdir($thisTestDir);
  11. $newpath = relative_include_path();
  12. set_include_path($newpath);
  13. runtest();
  14. $newpath = generate_next_rel_path();
  15. set_include_path($newpath);
  16. runtest();
  17. teardown_relative_path();
  18. chdir("..");
  19. rmdir($thisTestDir);
  20. function runtest() {
  21. $tmpfile = basename(__FILE__, ".php") . ".tmp";
  22. $h = fopen($tmpfile, "w", true);
  23. fwrite($h, "This is the test file");
  24. fclose($h);
  25. $h = @fopen($tmpfile, "r");
  26. if ($h === false) {
  27. echo "Not created in working dir\n";
  28. }
  29. else {
  30. echo "created in working dir\n";
  31. fclose($h);
  32. unlink($tmpfile);
  33. }
  34. $h = @fopen('dir1/'.$tmpfile, "r");
  35. if ($h === false) {
  36. echo "Not created in dir1\n";
  37. }
  38. else {
  39. echo "created in dir1\n";
  40. fclose($h);
  41. unlink('dir1/'.$tmpfile);
  42. }
  43. }
  44. ?>
  45. --EXPECT--
  46. created in working dir
  47. Not created in dir1
  48. created in working dir
  49. Not created in dir1