fopen_variation16.phpt 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. require_once('fopen_include_path.inc');
  8. $thisTestDir = "fopenVariation16.dir";
  9. mkdir($thisTestDir);
  10. chdir($thisTestDir);
  11. $newpath = create_include_path();
  12. set_include_path($newpath);
  13. runtest();
  14. $newpath = generate_next_path();
  15. set_include_path($newpath);
  16. runtest();
  17. teardown_include_path();
  18. chdir("..");
  19. rmdir($thisTestDir);
  20. function runtest() {
  21. global $dir1;
  22. $extraDir = "extraDir16";
  23. mkdir($dir1.'/'.$extraDir);
  24. mkdir($extraDir);
  25. $tmpfile = $extraDir.'/fopen_variation16.tmp';
  26. $h = fopen($tmpfile, "w+", true);
  27. fwrite($h, "This is the test file");
  28. fclose($h);
  29. $h = @fopen($dir1.'/'.$tmpfile, "r");
  30. if ($h === false) {
  31. echo "Not created in dir1\n";
  32. }
  33. else {
  34. echo "created in dir1\n";
  35. fclose($h);
  36. }
  37. $h = fopen($tmpfile, "r", true);
  38. if ($h === false) {
  39. echo "could not find file for reading\n";
  40. }
  41. else {
  42. echo "found file - not in dir1\n";
  43. fclose($h);
  44. }
  45. unlink($tmpfile);
  46. rmdir($dir1.'/'.$extraDir);
  47. rmdir($extraDir);
  48. }
  49. ?>
  50. --EXPECT--
  51. Not created in dir1
  52. found file - not in dir1
  53. Not created in dir1
  54. found file - not in dir1