fopen_variation17.phpt 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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 = basename(__FILE__, ".php") . ".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 = "extraDir17";
  23. mkdir($dir1.'/'.$extraDir);
  24. mkdir($extraDir);
  25. $tmpfile = $extraDir . '/' . basename(__FILE__, ".php") . ".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 for reading\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 for reading
  53. Not created in dir1
  54. found file for reading