1--TEST-- 2Test gzencode() 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/* 12 * Test basic function of gzencode 13 */ 14 15include(__DIR__ . '/data.inc'); 16 17echo "*** Testing gzencode() : basic functionality ***\n"; 18 19// Initialise all required variables 20 21$smallstring = "A small string to compress\n"; 22 23 24// Calling gzencode() with various compression levels 25 26// Compressing a big string 27for($i = -1; $i < 10; $i++) { 28 echo "-- Compression level $i --\n"; 29 $output = gzencode($data, $i); 30 31 // Clear OS byte before encode 32 $output[9] = "\x00"; 33 34 var_dump(md5($output)); 35} 36 37// Compressing a smaller string 38for($i = -1; $i < 10; $i++) { 39 echo "-- Compression level $i --\n"; 40 $output = gzencode($smallstring, $i); 41 42 // Clear OS byte before encode 43 $output[9] = "\x00"; 44 45 var_dump(md5($output)); 46} 47 48// Calling gzencode() with mandatory arguments 49echo "\n-- Testing with no specified compression level --\n"; 50var_dump(bin2hex(gzencode($smallstring))); 51 52echo "\n-- Testing gzencode with mode specified --\n"; 53var_dump(bin2hex(gzencode($smallstring, -1, FORCE_GZIP))); 54 55?> 56--EXPECTF-- 57*** Testing gzencode() : basic functionality *** 58-- Compression level -1 -- 59string(32) "d9ede02415ce91d21e5a94274e2b9c42" 60-- Compression level 0 -- 61string(32) "bbf32d5508e5f1f4e6d42790489dae15" 62-- Compression level 1 -- 63string(32) "0bfaaa7a5a57f8fb533074fca6c85eeb" 64-- Compression level 2 -- 65string(32) "7ddbfed63a76c42808722b66f1c133fc" 66-- Compression level 3 -- 67string(32) "ca2b85d194dfa2a4e8a162b646c99265" 68-- Compression level 4 -- 69string(32) "cfe28033eaf260bc33ddc04b53d3ba39" 70-- Compression level 5 -- 71string(32) "ae357fada2b515422f8bea0aa3bcc48f" 72-- Compression level 6 -- 73string(32) "d9ede02415ce91d21e5a94274e2b9c42" 74-- Compression level 7 -- 75string(32) "d9ede02415ce91d21e5a94274e2b9c42" 76-- Compression level 8 -- 77string(32) "d9ede02415ce91d21e5a94274e2b9c42" 78-- Compression level 9 -- 79string(32) "0f220a09e9895bcb3a1308d2bc99cfdf" 80-- Compression level -1 -- 81string(32) "f77bd31e1e4dd11d12828fb661a08010" 82-- Compression level 0 -- 83string(32) "9c5005db88490d6fe102ea2c233b2872" 84-- Compression level 1 -- 85string(32) "d24ff7c4c20cef69b9c3abd603368db9" 86-- Compression level 2 -- 87string(32) "f77bd31e1e4dd11d12828fb661a08010" 88-- Compression level 3 -- 89string(32) "f77bd31e1e4dd11d12828fb661a08010" 90-- Compression level 4 -- 91string(32) "f77bd31e1e4dd11d12828fb661a08010" 92-- Compression level 5 -- 93string(32) "f77bd31e1e4dd11d12828fb661a08010" 94-- Compression level 6 -- 95string(32) "f77bd31e1e4dd11d12828fb661a08010" 96-- Compression level 7 -- 97string(32) "f77bd31e1e4dd11d12828fb661a08010" 98-- Compression level 8 -- 99string(32) "f77bd31e1e4dd11d12828fb661a08010" 100-- Compression level 9 -- 101string(32) "8849e9a1543c04b3f882b5ce20839ed2" 102 103-- Testing with no specified compression level -- 104string(94) "1f8b08000000000000%c%c735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee60200edc4e40b1b000000" 105 106-- Testing gzencode with mode specified -- 107string(94) "1f8b08000000000000%c%c735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee60200edc4e40b1b000000" 108