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/* 12 * add a comment here to say what the test is supposed to do 13 */ 14 15include(__DIR__ . '/data.inc'); 16 17echo "*** Testing gzdeflate() : basic functionality ***\n"; 18 19// Initialise all required variables 20 21$smallstring = "A small string to compress\n"; 22 23 24// Calling gzdeflate() with all possible arguments 25 26// Compressing a big string 27for($i = -1; $i < 10; $i++) { 28 echo "-- Compression level $i --\n"; 29 $output = gzdeflate($data, $i); 30 var_dump(md5($output)); 31 var_dump(strcmp(gzinflate($output), $data)); 32} 33 34// Compressing a smaller string 35for($i = -1; $i < 10; $i++) { 36 echo "-- Compression level $i --\n"; 37 $output = gzdeflate($smallstring, $i); 38 var_dump(bin2hex($output)); 39 var_dump(strcmp(gzinflate($output), $smallstring)); 40} 41 42// Calling gzdeflate() with just mandatory arguments 43echo "\n-- Testing with no specified compression level --\n"; 44var_dump( bin2hex(gzdeflate($smallstring) )); 45 46?> 47--EXPECT-- 48*** Testing gzdeflate() : basic functionality *** 49-- Compression level -1 -- 50string(32) "078554fe65e06f6ff01eab51cfc7ae9b" 51int(0) 52-- Compression level 0 -- 53string(32) "a71e54d2499aff9e48643cb1c260b60c" 54int(0) 55-- Compression level 1 -- 56string(32) "05e80f4dc0d422e1f333cbed555d381f" 57int(0) 58-- Compression level 2 -- 59string(32) "0fb33656e4ed0750f977df83246fce7a" 60int(0) 61-- Compression level 3 -- 62string(32) "bc6e9c1dccc3e951e006315ee669ee08" 63int(0) 64-- Compression level 4 -- 65string(32) "a61727d7a28c634470eb6e97a4a81b24" 66int(0) 67-- Compression level 5 -- 68string(32) "a2a1a14b7542c82e8943200d093d5f27" 69int(0) 70-- Compression level 6 -- 71string(32) "078554fe65e06f6ff01eab51cfc7ae9b" 72int(0) 73-- Compression level 7 -- 74string(32) "078554fe65e06f6ff01eab51cfc7ae9b" 75int(0) 76-- Compression level 8 -- 77string(32) "078554fe65e06f6ff01eab51cfc7ae9b" 78int(0) 79-- Compression level 9 -- 80string(32) "078554fe65e06f6ff01eab51cfc7ae9b" 81int(0) 82-- Compression level -1 -- 83string(58) "735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee60200" 84int(0) 85-- Compression level 0 -- 86string(64) "011b00e4ff4120736d616c6c20737472696e6720746f20636f6d70726573730a" 87int(0) 88-- Compression level 1 -- 89string(58) "735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee60200" 90int(0) 91-- Compression level 2 -- 92string(58) "735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee60200" 93int(0) 94-- Compression level 3 -- 95string(58) "735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee60200" 96int(0) 97-- Compression level 4 -- 98string(58) "735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee60200" 99int(0) 100-- Compression level 5 -- 101string(58) "735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee60200" 102int(0) 103-- Compression level 6 -- 104string(58) "735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee60200" 105int(0) 106-- Compression level 7 -- 107string(58) "735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee60200" 108int(0) 109-- Compression level 8 -- 110string(58) "735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee60200" 111int(0) 112-- Compression level 9 -- 113string(58) "735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee60200" 114int(0) 115 116-- Testing with no specified compression level -- 117string(58) "735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee60200" 118