Annotation of embedaddon/php/ext/zlib/tests/gzdeflate_error1.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test gzdeflate() function : error conditions
! 3: --SKIPIF--
! 4: <?php
! 5: if (!extension_loaded("zlib")) {
! 6: print "skip - ZLIB extension not loaded";
! 7: }
! 8: ?>
! 9: --FILE--
! 10: <?php
! 11: /* Prototype : string gzdeflate(string data [, int level])
! 12: * Description: Gzip-compress a string
! 13: * Source code: ext/zlib/zlib.c
! 14: * Alias to functions:
! 15: */
! 16:
! 17: /*
! 18: * add a comment here to say what the test is supposed to do
! 19: */
! 20:
! 21: echo "*** Testing gzdeflate() : error conditions ***\n";
! 22:
! 23: // Zero arguments
! 24: echo "\n-- Testing gzdeflate() function with Zero arguments --\n";
! 25: var_dump( gzdeflate() );
! 26:
! 27: //Test gzdeflate with one more than the expected number of arguments
! 28: echo "\n-- Testing gzdeflate() function with more than expected no. of arguments --\n";
! 29: $data = 'string_val';
! 30: $level = 2;
! 31: $extra_arg = 10;
! 32: var_dump( gzdeflate($data, $level, $extra_arg) );
! 33:
! 34: echo "\n-- Testing with incorrect compression level --\n";
! 35: $bad_level = 99;
! 36: var_dump(gzdeflate($data, $bad_level));
! 37:
! 38: class Tester {
! 39: function Hello() {
! 40: echo "Hello\n";
! 41: }
! 42: }
! 43:
! 44: echo "\n-- Testing with incorrect parameters --\n";
! 45: $testclass = new Tester();
! 46: var_dump(gzdeflate($testclass));
! 47: var_dump(gzdeflate($data, $testclass));
! 48:
! 49: ?>
! 50: ===Done===
! 51: --EXPECTF--
! 52: *** Testing gzdeflate() : error conditions ***
! 53:
! 54: -- Testing gzdeflate() function with Zero arguments --
! 55:
! 56: Warning: gzdeflate() expects at least 1 parameter, 0 given in %s on line %d
! 57: NULL
! 58:
! 59: -- Testing gzdeflate() function with more than expected no. of arguments --
! 60:
! 61: Warning: gzdeflate() expects at most 2 parameters, 3 given in %s on line %d
! 62: NULL
! 63:
! 64: -- Testing with incorrect compression level --
! 65:
! 66: Warning: gzdeflate(): compression level (99) must be within -1..9 in %s on line %d
! 67: bool(false)
! 68:
! 69: -- Testing with incorrect parameters --
! 70:
! 71: Warning: gzdeflate() expects parameter 1 to be string, object given in %s on line %d
! 72: NULL
! 73:
! 74: Warning: gzdeflate() expects parameter 2 to be long, object given in %s on line %d
! 75: NULL
! 76: ===Done===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>