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