1--TEST-- 2Test gzencode() function : basic functionality 3--EXTENSIONS-- 4zlib 5--FILE-- 6<?php 7/* 8 * Test basic function of gzencode 9 */ 10 11include(__DIR__ . '/data.inc'); 12 13echo "*** Testing gzencode() : basic functionality ***\n"; 14 15// Initialise all required variables 16 17$smallstring = "A small string to compress\n"; 18 19 20// Calling gzencode() with various compression levels 21 22// Compressing a big string 23for($i = -1; $i < 10; $i++) { 24 echo "-- Compression level $i --\n"; 25 $output = gzencode($data, $i); 26 var_dump(strcmp(gzdecode($output), $data)===0); 27} 28 29// Compressing a smaller string 30for($i = -1; $i < 10; $i++) { 31 echo "-- Compression level $i --\n"; 32 $output = gzencode($smallstring, $i); 33 var_dump(strcmp(gzdecode($output), $smallstring)===0); 34} 35 36// Calling gzencode() with mandatory arguments 37echo "\n-- Testing with no specified compression level --\n"; 38$output = gzencode($smallstring); 39var_dump(strcmp(gzdecode($output), $smallstring)===0); 40 41echo "\n-- Testing gzencode with mode specified --\n"; 42$outupt = gzencode($smallstring, -1, FORCE_GZIP); 43var_dump(strcmp(gzdecode($output), $smallstring)===0); 44?> 45--EXPECTF-- 46*** Testing gzencode() : basic functionality *** 47-- Compression level -1 -- 48bool(true) 49-- Compression level 0 -- 50bool(true) 51-- Compression level 1 -- 52bool(true) 53-- Compression level 2 -- 54bool(true) 55-- Compression level 3 -- 56bool(true) 57-- Compression level 4 -- 58bool(true) 59-- Compression level 5 -- 60bool(true) 61-- Compression level 6 -- 62bool(true) 63-- Compression level 7 -- 64bool(true) 65-- Compression level 8 -- 66bool(true) 67-- Compression level 9 -- 68bool(true) 69-- Compression level -1 -- 70bool(true) 71-- Compression level 0 -- 72bool(true) 73-- Compression level 1 -- 74bool(true) 75-- Compression level 2 -- 76bool(true) 77-- Compression level 3 -- 78bool(true) 79-- Compression level 4 -- 80bool(true) 81-- Compression level 5 -- 82bool(true) 83-- Compression level 6 -- 84bool(true) 85-- Compression level 7 -- 86bool(true) 87-- Compression level 8 -- 88bool(true) 89-- Compression level 9 -- 90bool(true) 91 92-- Testing with no specified compression level -- 93bool(true) 94 95-- Testing gzencode with mode specified -- 96bool(true) 97