1--TEST-- 2Test gzcompress() 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 gzcompress() : basic functionality ***\n"; 18 19// Initialise all required variables 20 21$smallstring = "A small string to compress\n"; 22 23 24// Calling gzcompress() with all possible arguments 25 26// Compressing a big string 27for($i = -1; $i < 10; $i++) { 28 echo "-- Compression level $i --\n"; 29 $output = gzcompress($data, $i); 30 var_dump(md5($output)); 31 var_dump(strcmp(gzuncompress($output), $data)); 32} 33 34// Compressing a smaller string 35for($i = -1; $i < 10; $i++) { 36 echo "-- Compression level $i --\n"; 37 $output = gzcompress($smallstring, $i); 38 var_dump(bin2hex($output)); 39 var_dump(strcmp(gzuncompress($output), $smallstring)); 40} 41 42// Calling gzcompress() with mandatory arguments 43echo "\n-- Testing with no specified compression level --\n"; 44var_dump( bin2hex(gzcompress($smallstring) )); 45 46?> 47--EXPECT-- 48*** Testing gzcompress() : basic functionality *** 49-- Compression level -1 -- 50string(32) "764809aef15bb34cb73ad49ecb600d99" 51int(0) 52-- Compression level 0 -- 53string(32) "d0136b3fb5424142c0eb26dfec8f56fe" 54int(0) 55-- Compression level 1 -- 56string(32) "c2e070f4320d1f674965eaab95b53d9c" 57int(0) 58-- Compression level 2 -- 59string(32) "36922f486410d08209d0d0d21b26030e" 60int(0) 61-- Compression level 3 -- 62string(32) "a441a2f5169bb303cd45b860a5a9dbf9" 63int(0) 64-- Compression level 4 -- 65string(32) "d5b7451e9de2864beccc9de1fc55eb87" 66int(0) 67-- Compression level 5 -- 68string(32) "32ba4a01120449ec25508cabfad41f56" 69int(0) 70-- Compression level 6 -- 71string(32) "764809aef15bb34cb73ad49ecb600d99" 72int(0) 73-- Compression level 7 -- 74string(32) "e083e7e8d05471fed3c2182b9cd0d9eb" 75int(0) 76-- Compression level 8 -- 77string(32) "e083e7e8d05471fed3c2182b9cd0d9eb" 78int(0) 79-- Compression level 9 -- 80string(32) "e083e7e8d05471fed3c2182b9cd0d9eb" 81int(0) 82-- Compression level -1 -- 83string(70) "789c735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee6020087a509cb" 84int(0) 85-- Compression level 0 -- 86string(76) "7801011b00e4ff4120736d616c6c20737472696e6720746f20636f6d70726573730a87a509cb" 87int(0) 88-- Compression level 1 -- 89string(70) "7801735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee6020087a509cb" 90int(0) 91-- Compression level 2 -- 92string(70) "785e735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee6020087a509cb" 93int(0) 94-- Compression level 3 -- 95string(70) "785e735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee6020087a509cb" 96int(0) 97-- Compression level 4 -- 98string(70) "785e735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee6020087a509cb" 99int(0) 100-- Compression level 5 -- 101string(70) "785e735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee6020087a509cb" 102int(0) 103-- Compression level 6 -- 104string(70) "789c735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee6020087a509cb" 105int(0) 106-- Compression level 7 -- 107string(70) "78da735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee6020087a509cb" 108int(0) 109-- Compression level 8 -- 110string(70) "78da735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee6020087a509cb" 111int(0) 112-- Compression level 9 -- 113string(70) "78da735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee6020087a509cb" 114int(0) 115 116-- Testing with no specified compression level -- 117string(70) "789c735428ce4dccc951282e29cacc4b5728c95748cecf2d284a2d2ee6020087a509cb" 118