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