Annotation of embedaddon/php/ext/zlib/tests/gzencode_error1.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: Test gzencode() 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 gzencode  ( string $data  [, int $level  [, int $encoding_mode  ]] )
        !            12:  * Description: Gzip-compress a string 
        !            13:  * Source code: ext/zlib/zlib.c
        !            14:  * Alias to functions: 
        !            15:  */
        !            16: 
        !            17: /*
        !            18:  * Test error cases for gzencode
        !            19:  */
        !            20: 
        !            21: echo "*** Testing gzencode() : error conditions ***\n";
        !            22: 
        !            23: // Zero arguments
        !            24: echo "\n-- Testing gzencode() function with Zero arguments --\n";
        !            25: var_dump( gzencode() );
        !            26: 
        !            27: //Test gzencode with one more than the expected number of arguments
        !            28: echo "\n-- Testing gzencode() function with more than expected no. of arguments --\n";
        !            29: $data = 'string_val';
        !            30: $level = 2;
        !            31: $encoding_mode = FORCE_DEFLATE;
        !            32: $extra_arg = 10;
        !            33: var_dump( gzencode($data, $level, $encoding_mode, $extra_arg) );
        !            34: 
        !            35: echo "\n-- Testing with incorrect compression level --\n";
        !            36: $bad_level = 99;
        !            37: var_dump(gzencode($data, $bad_level));
        !            38: 
        !            39: echo "\n-- Testing with incorrect encoding_mode --\n";
        !            40: $bad_mode = 99; 
        !            41: var_dump(gzencode($data, $level, $bad_mode));
        !            42: 
        !            43: class Tester {
        !            44:     function Hello() {
        !            45:         echo "Hello\n"; 
        !            46:     }
        !            47: }
        !            48: 
        !            49: echo "\n-- Testing with incorrect parameters --\n";
        !            50: $testclass = new Tester();
        !            51: var_dump(gzencode($testclass));
        !            52: var_dump(gzencode($data, $testclass));
        !            53: var_dump(gzencode($data, -1, 99.99));
        !            54: var_dump(gzencode($data, -1, $testclass));
        !            55: var_dump(gzencode($data, "a very none numeric string\n"));
        !            56: 
        !            57: ?>
        !            58: ===Done===
        !            59: --EXPECTF--
        !            60: *** Testing gzencode() : error conditions ***
        !            61: 
        !            62: -- Testing gzencode() function with Zero arguments --
        !            63: 
        !            64: Warning: gzencode() expects at least 1 parameter, 0 given in %s on line %d
        !            65: NULL
        !            66: 
        !            67: -- Testing gzencode() function with more than expected no. of arguments --
        !            68: 
        !            69: Warning: gzencode() expects at most 3 parameters, 4 given in %s on line %d
        !            70: NULL
        !            71: 
        !            72: -- Testing with incorrect compression level --
        !            73: 
        !            74: Warning: gzencode(): compression level(99) must be within -1..9 in %s on line %d
        !            75: bool(false)
        !            76: 
        !            77: -- Testing with incorrect encoding_mode --
        !            78: 
        !            79: Warning: gzencode(): encoding mode must be FORCE_GZIP or FORCE_DEFLATE in %s on line %d
        !            80: bool(false)
        !            81: 
        !            82: -- Testing with incorrect parameters --
        !            83: 
        !            84: Warning: gzencode() expects parameter 1 to be string, object given in %s on line %d
        !            85: NULL
        !            86: 
        !            87: Warning: gzencode() expects parameter 2 to be long, object given in %s on line %d
        !            88: NULL
        !            89: 
        !            90: Warning: gzencode(): encoding mode must be FORCE_GZIP or FORCE_DEFLATE in %s on line %d
        !            91: bool(false)
        !            92: 
        !            93: Warning: gzencode() expects parameter 3 to be long, object given in %s on line %d
        !            94: NULL
        !            95: 
        !            96: Warning: gzencode() expects parameter 2 to be long, string given in %s on line %d
        !            97: NULL
        !            98: ===Done===

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>