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