readgzfile_variation15.phpt 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. --TEST--
  2. Test readgzfile() function : variation: use include path (relative directories in path)
  3. --SKIPIF--
  4. <?php
  5. if (!extension_loaded("zlib")) {
  6. print "skip - ZLIB extension not loaded";
  7. }
  8. ?>
  9. --FILE--
  10. <?php
  11. require_once('reading_include_path.inc');
  12. //define the files to go into these directories, create one in dir2
  13. set_include_path($newIncludePath);
  14. test_readgzfile();
  15. restore_include_path();
  16. // remove the directory structure
  17. chdir($baseDir);
  18. rmdir($workingDir);
  19. foreach($newdirs as $newdir) {
  20. rmdir($newdir);
  21. }
  22. chdir("..");
  23. rmdir($thisTestDir);
  24. function test_readgzfile() {
  25. global $scriptFile, $secondFile, $firstFile, $filename;
  26. // create a file in the middle directory
  27. $h = gzopen($secondFile, "w");
  28. gzwrite($h, "This is a file in dir2");
  29. gzclose($h);
  30. // should read dir2 file
  31. echo "file content:";
  32. readgzfile($filename, true);
  33. echo "\n";
  34. //create a file in dir1
  35. $h = gzopen($firstFile, "w");
  36. gzwrite($h, "This is a file in dir1");
  37. gzclose($h);
  38. //should now read dir1 file
  39. echo "file content:";
  40. readgzfile($filename, true);
  41. echo "\n";
  42. // create a file in working directory
  43. $h = gzopen($filename, "w");
  44. gzwrite($h, "This is a file in working dir");
  45. gzclose($h);
  46. //should still read dir1 file
  47. echo "file content:";
  48. readgzfile($filename, true);
  49. echo "\n";
  50. unlink($firstFile);
  51. unlink($secondFile);
  52. //should read the file in working dir
  53. echo "file content:";
  54. readgzfile($filename, true);
  55. echo "\n";
  56. // create a file in the script directory
  57. $h = gzopen($scriptFile, "w");
  58. gzwrite($h, "This is a file in script dir");
  59. gzclose($h);
  60. //should read the file in script dir
  61. echo "file content:";
  62. readgzfile($filename, true);
  63. echo "\n";
  64. //cleanup
  65. unlink($filename);
  66. unlink($scriptFile);
  67. }
  68. ?>
  69. ===DONE===
  70. --EXPECT--
  71. file content:This is a file in dir2
  72. file content:This is a file in dir1
  73. file content:This is a file in dir1
  74. file content:This is a file in working dir
  75. file content:This is a file in script dir
  76. ===DONE===