1--TEST-- 2Test gzuncompress() 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/* Prototype : string gzuncompress(string data [, int length]) 12 * Description: Unzip a gzip-compressed string 13 * Source code: ext/zlib/zlib.c 14 * Alias to functions: 15 */ 16 17 18 19echo "*** Testing gzuncompress() : error conditions ***\n"; 20 21// Zero arguments 22echo "\n-- Testing gzuncompress() function with Zero arguments --\n"; 23var_dump( gzuncompress() ); 24 25//Test gzuncompress with one more than the expected number of arguments 26echo "\n-- Testing gzuncompress() function with more than expected no. of arguments --\n"; 27$data = 'string_val'; 28$length = 10; 29$extra_arg = 10; 30var_dump( gzuncompress($data, $length, $extra_arg) ); 31 32 33echo "\n-- Testing with a buffer that is too small --\n"; 34$short_len = strlen($data) - 1; 35$compressed = gzcompress($data); 36 37var_dump(gzuncompress($compressed, $short_len)); 38 39 40echo "\n-- Testing with incorrect arguments --\n"; 41var_dump(gzuncompress(123)); 42 43class Tester { 44 function Hello() { 45 echo "Hello\n"; 46 } 47} 48 49$testclass = new Tester(); 50var_dump(gzuncompress($testclass)); 51 52var_dump(gzuncompress($compressed, "this is not a number\n")); 53 54?> 55===DONE=== 56--EXPECTF-- 57*** Testing gzuncompress() : error conditions *** 58 59-- Testing gzuncompress() function with Zero arguments -- 60 61Warning: gzuncompress() expects at least 1 parameter, 0 given in %s on line %d 62NULL 63 64-- Testing gzuncompress() function with more than expected no. of arguments -- 65 66Warning: gzuncompress() expects at most 2 parameters, 3 given in %s on line %d 67NULL 68 69-- Testing with a buffer that is too small -- 70 71Warning: gzuncompress(): buffer error in %s on line %d 72bool(false) 73 74-- Testing with incorrect arguments -- 75 76Warning: gzuncompress(): data error in %s on line %d 77bool(false) 78 79Warning: gzuncompress() expects parameter 1 to be string, object given in %s on line %d 80NULL 81 82Warning: gzuncompress() expects parameter 2 to be long, string given in %s on line %d 83NULL 84===DONE===