1--TEST--
2Test gzcompress() 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 gzcompress() : error conditions ***\n";
12
13echo "\n-- Testing with incorrect compression level --\n";
14$data = 'string_val';
15$bad_level = 99;
16try {
17    var_dump(gzcompress($data, $bad_level));
18} catch (\ValueError $e) {
19    echo $e->getMessage() . \PHP_EOL;
20}
21
22echo "\n-- Testing with invalid encoding --\n";
23$data = 'string_val';
24$level = 2;
25$encoding = 99;
26try {
27    var_dump(gzcompress($data, $level, $encoding));
28} catch (\ValueError $e) {
29    echo $e->getMessage() . \PHP_EOL;
30}
31
32?>
33--EXPECT--
34*** Testing gzcompress() : error conditions ***
35
36-- Testing with incorrect compression level --
37gzcompress(): Argument #2 ($level) must be between -1 and 9
38
39-- Testing with invalid encoding --
40gzcompress(): Argument #3 ($encoding) must be one of ZLIB_ENCODING_RAW, ZLIB_ENCODING_GZIP, or ZLIB_ENCODING_DEFLATE
41