gzopen_basic2.phpt 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. --TEST--
  2. Test gzopen() function : basic functionality for writing
  3. --SKIPIF--
  4. <?php
  5. if (!extension_loaded("zlib")) {
  6. print "skip - ZLIB extension not loaded";
  7. }
  8. ?>
  9. --FILE--
  10. <?php
  11. /* Prototype : resource gzopen(string filename, string mode [, int use_include_path])
  12. * Description: Open a .gz-file and return a .gz-file pointer
  13. * Source code: ext/zlib/zlib.c
  14. * Alias to functions:
  15. */
  16. echo "*** Testing gzopen() : basic functionality ***\n";
  17. // Initialise all required variables
  18. $filename = "gzopen_basic2.txt.gz";
  19. $modes = array('w', 'w+');
  20. $data = "This was the information that was written";
  21. foreach($modes as $mode) {
  22. echo "testing mode -- $mode --\n";
  23. $h = gzopen($filename, $mode);
  24. if ($h !== false) {
  25. gzwrite($h, $data);
  26. gzclose($h);
  27. $h = gzopen($filename, 'r');
  28. gzpassthru($h);
  29. gzclose($h);
  30. echo "\n";
  31. unlink($filename);
  32. }
  33. else {
  34. var_dump($h);
  35. }
  36. }
  37. ?>
  38. ===DONE===
  39. --EXPECTF--
  40. *** Testing gzopen() : basic functionality ***
  41. testing mode -- w --
  42. This was the information that was written
  43. testing mode -- w+ --
  44. Warning: gzopen(): cannot open a zlib stream for reading and writing at the same time! in %s on line %d
  45. bool(false)
  46. ===DONE===