gzdeflate_error1.phpt 967 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. --TEST--
  2. Test gzdeflate() function : error conditions
  3. --EXTENSIONS--
  4. zlib
  5. --FILE--
  6. <?php
  7. /*
  8. * add a comment here to say what the test is supposed to do
  9. */
  10. echo "*** Testing gzdeflate() : error conditions ***\n";
  11. $data = 'string_val';
  12. echo "\n-- Testing with incorrect compression level --\n";
  13. $bad_level = 99;
  14. try {
  15. var_dump(gzdeflate($data, $bad_level));
  16. } catch (\ValueError $e) {
  17. echo $e->getMessage() . \PHP_EOL;
  18. }
  19. echo "\n-- Testing with incorrect encoding --\n";
  20. $level = 2;
  21. $bad_encoding = 99;
  22. try {
  23. var_dump(gzdeflate($data, $level, $bad_encoding));
  24. } catch (\ValueError $e) {
  25. echo $e->getMessage() . \PHP_EOL;
  26. }
  27. ?>
  28. --EXPECT--
  29. *** Testing gzdeflate() : error conditions ***
  30. -- Testing with incorrect compression level --
  31. gzdeflate(): Argument #2 ($level) must be between -1 and 9
  32. -- Testing with incorrect encoding --
  33. gzdeflate(): Argument #3 ($encoding) must be one of ZLIB_ENCODING_RAW, ZLIB_ENCODING_GZIP, or ZLIB_ENCODING_DEFLATE