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