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