1--TEST-- 2Test gzdeflate() function : basic functionality 3--SKIPIF-- 4<?php 5if (!extension_loaded("zlib")) { 6 print "skip - ZLIB extension not loaded"; 7} 8?> 9--FILE-- 10<?php 11/* Prototype : string gzdeflate(string data [, int level, [int encoding]]) 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 21include(dirname(__FILE__) . '/data.inc'); 22 23echo "*** Testing gzdeflate() : basic functionality ***\n"; 24 25// Initialise all required variables 26 27$smallstring = "A small string to compress\n"; 28 29 30// Calling gzdeflate() with all possible arguments 31 32// Compressing a big string 33for($i = -1; $i < 10; $i++) { 34 echo "-- Compression level $i --\n"; 35 $output = gzdeflate($data, $i); 36 var_dump(md5($output)); 37 var_dump(strcmp(gzinflate($output), $data)); 38} 39 40// Compressing a smaller string 41for($i = -1; $i < 10; $i++) { 42 echo "-- Compression level $i --\n"; 43 $output = gzdeflate($smallstring, $i); 44 var_dump(bin2hex($output)); 45 var_dump(strcmp(gzinflate($output), $smallstring)); 46} 47 48// Calling gzdeflate() with just mandatory arguments 49echo "\n-- Testing with no specified compression level --\n"; 50var_dump( bin2hex(gzdeflate($smallstring) )); 51 52?> 53===Done=== 54--EXPECT-- 55*** Testing gzdeflate() : basic functionality *** 56-- Compression level -1 -- 57string(32) "078554fe65e06f6ff01eab51cfc7ae9b" 58int(0) 59-- Compression level 0 -- 60string(32) "a71e54d2499aff9e48643cb1c260b60c" 61int(0) 62-- Compression level 1 -- 63string(32) "05e80f4dc0d422e1f333cbed555d381f" 64int(0) 65-- Compression level 2 -- 66string(32) "0fb33656e4ed0750f977df83246fce7a" 67int(0) 68-- Compression level 3 -- 69string(32) "bc6e9c1dccc3e951e006315ee669ee08" 70int(0) 71-- Compression level 4 -- 72string(32) "a61727d7a28c634470eb6e97a4a81b24" 73int(0) 74-- Compression level 5 -- 75string(32) "a2a1a14b7542c82e8943200d093d5f27" 76int(0) 77-- Compression level 6 -- 78string(32) "078554fe65e06f6ff01eab51cfc7ae9b" 79int(0) 80-- Compression level 7 -- 81string(32) "078554fe65e06f6ff01eab51cfc7ae9b" 82int(0) 83-- Compression level 8 -- 84string(32) "078554fe65e06f6ff01eab51cfc7ae9b" 85int(0) 86-- Compression level 9 -- 87string(32) "078554fe65e06f6ff01eab51cfc7ae9b" 88int(0) 89-- Compression level -1 -- 90string(58) "735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee60200" 91int(0) 92-- Compression level 0 -- 93string(64) "011b00e4ff4120736d616c6c20737472696e6720746f20636f6d70726573730a" 94int(0) 95-- Compression level 1 -- 96string(58) "735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee60200" 97int(0) 98-- Compression level 2 -- 99string(58) "735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee60200" 100int(0) 101-- Compression level 3 -- 102string(58) "735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee60200" 103int(0) 104-- Compression level 4 -- 105string(58) "735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee60200" 106int(0) 107-- Compression level 5 -- 108string(58) "735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee60200" 109int(0) 110-- Compression level 6 -- 111string(58) "735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee60200" 112int(0) 113-- Compression level 7 -- 114string(58) "735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee60200" 115int(0) 116-- Compression level 8 -- 117string(58) "735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee60200" 118int(0) 119-- Compression level 9 -- 120string(58) "735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee60200" 121int(0) 122 123-- Testing with no specified compression level -- 124string(58) "735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee60200" 125===Done=== 126