Annotation of embedaddon/php/ext/zlib/tests/gzcompress_error1.phpt, revision 1.1.1.2
1.1 misho 1: --TEST--
2: Test gzcompress() 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
1.1.1.2 ! misho 11: /* Prototype : string gzcompress(string data [, int level, [int encoding]])
1.1 misho 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 gzcompress() : error conditions ***\n";
22:
23: // Zero arguments
24: echo "\n-- Testing gzcompress() function with Zero arguments --\n";
25: var_dump( gzcompress() );
26:
27: //Test gzcompress with one more than the expected number of arguments
28: echo "\n-- Testing gzcompress() function with more than expected no. of arguments --\n";
29: $data = 'string_val';
30: $level = 2;
1.1.1.2 ! misho 31: $encoding = ZLIB_ENCODING_RAW;
1.1 misho 32: $extra_arg = 10;
1.1.1.2 ! misho 33: var_dump( gzcompress($data, $level, $encoding, $extra_arg) );
1.1 misho 34:
35: echo "\n-- Testing with incorrect compression level --\n";
36: $bad_level = 99;
37: var_dump(gzcompress($data, $bad_level));
38:
1.1.1.2 ! misho 39: echo "\n-- Testing with invalid encoding --\n";
! 40: $data = 'string_val';
! 41: $encoding = 99;
! 42: var_dump(gzcompress($data, $level, $encoding));
! 43:
! 44: echo "\n-- Testing with incorrect parameters --\n";
! 45:
1.1 misho 46: class Tester {
47: function Hello() {
48: echo "Hello\n";
49: }
50: }
51:
52: $testclass = new Tester();
53: var_dump(gzcompress($testclass));
54:
55: ?>
56: ===Done===
57: --EXPECTF--
58: *** Testing gzcompress() : error conditions ***
59:
60: -- Testing gzcompress() function with Zero arguments --
61:
62: Warning: gzcompress() expects at least 1 parameter, 0 given in %s on line %d
63: NULL
64:
65: -- Testing gzcompress() function with more than expected no. of arguments --
66:
1.1.1.2 ! misho 67: Warning: gzcompress() expects at most 3 parameters, 4 given in %s on line %d
1.1 misho 68: NULL
69:
70: -- Testing with incorrect compression level --
71:
72: Warning: gzcompress(): compression level (99) must be within -1..9 in %s on line %d
73: bool(false)
74:
1.1.1.2 ! misho 75: -- Testing with invalid encoding --
! 76:
! 77: Warning: gzcompress(): encoding mode must be either ZLIB_ENCODING_RAW, ZLIB_ENCODING_GZIP or ZLIB_ENCODING_DEFLATE in %s on line %d
! 78: bool(false)
! 79:
1.1 misho 80: -- Testing with incorrect parameters --
81:
82: Warning: gzcompress() expects parameter 1 to be string, object given in %s on line %d
83: NULL
1.1.1.2 ! misho 84: ===Done===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>