fopen_variation13.phpt 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. --TEST--
  2. Test fopen() function : variation: use include path create a file (absolute)
  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. echo "*** Testing fopen() : variation ***\n";
  14. $newpath = create_include_path();
  15. set_include_path($newpath);
  16. runtest();
  17. $newpath = generate_next_path();
  18. set_include_path($newpath);
  19. runtest();
  20. teardown_include_path();
  21. restore_include_path();
  22. function runtest() {
  23. $tempDir = 'fopen_variation13.dir.tmp';
  24. $tmpfile = 'fopen_variation13.tmp';
  25. $absFile = getcwd().'/'.$tempDir.'/'.$tmpfile;
  26. mkdir($tempDir);
  27. $h = fopen($absFile, "w", true);
  28. fwrite($h, "This is the test file");
  29. fclose($h);
  30. $h = fopen($absFile, "r");
  31. if ($h === false) {
  32. echo "Not created absolute location\n";
  33. }
  34. else {
  35. echo "Created in correct location\n";
  36. fclose($h);
  37. }
  38. unlink($absFile);
  39. rmdir($tempDir);
  40. }
  41. ?>
  42. ===DONE===
  43. --EXPECT--
  44. *** Testing fopen() : variation ***
  45. Created in correct location
  46. Created in correct location
  47. ===DONE===