1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

ext/zlib: Refactor tests (#18887)

- Use INI sections
- Use CGI sections
- Move data into a subfolder
- Remove ZPP tests
- Fix various bugs within tests
- Simplify some


Found while working on #18879
This commit is contained in:
Gina Peter Banyard
2025-06-21 18:03:50 +01:00
committed by GitHub
parent 89be689f77
commit 5bd18e3fdc
83 changed files with 171 additions and 698 deletions

View File

@@ -8,14 +8,14 @@ $original = str_repeat("hallo php",4096);
$packed=gzcompress($original);
echo strlen($packed)." ".strlen($original)."\n";
$unpacked=gzuncompress($packed);
if (strcmp($original,$unpacked)==0) echo "Strings are equal\n";
if ($original === $unpacked) echo "Strings are equal\n";
/* with explicit compression level, length */
$original = str_repeat("hallo php",4096);
$packed=gzcompress($original, 9);
echo strlen($packed)." ".strlen($original)."\n";
$unpacked=gzuncompress($packed, 40000);
if (strcmp($original,$unpacked)==0) echo "Strings are equal\n";
if ($original === $unpacked) echo "Strings are equal\n";
?>
--EXPECT--
106 36864

View File

@@ -7,7 +7,7 @@ zlib
$original = str_repeat("hallo php",4096);
$packed = gzencode($original);
echo strlen($packed)." ".strlen($original). "\n";
if (strcmp($original, gzdecode($packed)) == 0) echo "Strings are equal";
if ($original === gzdecode($packed)) echo "Strings are equal\n";
?>
--EXPECT--
118 36864

Binary file not shown.

View File

@@ -2,14 +2,13 @@
checks zlib compression output size is always the same
--EXTENSIONS--
zlib
--INI--
zlib.output_compression=4096
zlib.output_compression_level=9
--CGI--
--FILE--
<?php
// the INI directives from bug #60761 report
ini_set('zlib.output_compression', '4096');
ini_set('zlib.output_compression_level', '9');
// try to duplicate the original bug by running this as a CGI
// test using ob_start and zlib.output_compression(or ob_gzhandler)
// so it follows more of the original code-path than just calling

View File

@@ -9,7 +9,7 @@ gzopen('someFile', 'c');
?>
--CLEAN--
<?php
unlink('someFile');
unlink('someFile');
?>
--EXPECTF--
Warning: gzopen(): gzopen failed in %s on line %d

View File

@@ -45,7 +45,7 @@ function test($case) {
// The gzdecode() function applied to the corrupted compressed data always
// detects the error:
// --> gzdecode(): PHP Fatal error: Uncaught ErrorException: gzdecode(): data error in ...
echo "gzdecode(): ", rawurldecode(gzdecode($compressed)), "\n";
echo "gzdecode(): ", rawurldecode((string) gzdecode($compressed)), "\n";
file_put_contents($fn, $compressed);

View File

@@ -2,11 +2,11 @@
Bug #74240 (deflate_add can allocate too much memory)
--EXTENSIONS--
zlib
--INI--
memory_limit=64M
--FILE--
<?php
ini_set('memory_limit', '64M');
$deflator = deflate_init(ZLIB_ENCODING_RAW);
$bytes = str_repeat("*", 65536);

View File

@@ -4,16 +4,14 @@ compress.zlib:// wrapper
zlib
--FILE--
<?php
chdir(__DIR__. "/../../..");
$pfx = str_repeat('../', substr_count($_SERVER['PHP_SELF'], '../'));
chdir(__DIR__. "/data");
// Relative path
$fp = fopen("compress.zlib://{$pfx}ext/xsl/tests/xslt.xsl.gz", "rb");
$fp = fopen("compress.zlib://test.txt.gz", "rb");
fclose($fp);
// Absolute path
$fp = fopen("compress.zlib://". __DIR__. "/../../../ext/xsl/tests/xslt.xsl.gz", "rb");
$fp = fopen("compress.zlib://". __DIR__. "/data/test.txt.gz", "rb");
fclose($fp);
echo "ok\n";

View File

@@ -17,8 +17,9 @@ foreach (range("a", "z") as $char) {
$compressed .= deflate_add($resource, $char, ZLIB_NO_FLUSH);
}
$compressed .= deflate_add($resource, "", ZLIB_FINISH);
assert($uncompressed === zlib_decode($compressed));
var_dump($uncompressed === zlib_decode($compressed));
?>
===DONE===
--EXPECT--
bool(true)
===DONE===

View File

@@ -29,9 +29,9 @@ stream_context_set_default([
$f = gzopen('http://'.PHP_CLI_SERVER_HOSTNAME.':'.PHP_CLI_SERVER_PORT, 'r');
var_dump(stream_get_contents($f));
var_dump(gzfile('http://'.PHP_CLI_SERVER_HOSTNAME.':'.PHP_CLI_SERVER_PORT, 'r'));
var_dump(gzfile('http://'.PHP_CLI_SERVER_HOSTNAME.':'.PHP_CLI_SERVER_PORT));
var_dump(readgzfile('http://'.PHP_CLI_SERVER_HOSTNAME.':'.PHP_CLI_SERVER_PORT, 'r'));
var_dump(readgzfile('http://'.PHP_CLI_SERVER_HOSTNAME.':'.PHP_CLI_SERVER_PORT));
?>
--EXPECT--

View File

@@ -7,7 +7,7 @@ zlib
// note that gzclose is an alias to fclose. parameter checking tests will be
// the same as fclose
$f = __DIR__."/004.txt.gz";
$f = __DIR__."/data/test.txt.gz";
$h = gzopen($f, 'r');
gzread($h, 20);
var_dump(gzclose($h));

View File

@@ -8,7 +8,7 @@ zlib
* add a comment here to say what the test is supposed to do
*/
include(__DIR__ . '/data.inc');
include(__DIR__ . '/data/data.inc');
echo "*** Testing gzcompress() : basic functionality ***\n";
@@ -23,68 +23,68 @@ $smallstring = "A small string to compress\n";
for($i = -1; $i < 10; $i++) {
echo "-- Compression level $i --\n";
$output = gzcompress($data, $i);
var_dump(strcmp(gzuncompress($output), $data));
var_dump(gzuncompress($output) === $data);
}
// Compressing a smaller string
for($i = -1; $i < 10; $i++) {
echo "-- Compression level $i --\n";
$output = gzcompress($smallstring, $i);
var_dump(strcmp(gzuncompress($output), $smallstring));
var_dump(gzuncompress($output) === $smallstring);
}
// Calling gzcompress() with mandatory arguments
echo "\n-- Testing with no specified compression level --\n";
$output = gzcompress($smallstring);
var_dump(strcmp(gzuncompress($output), $smallstring));
var_dump(gzuncompress($output) === $smallstring);
?>
--EXPECT--
*** Testing gzcompress() : basic functionality ***
-- Compression level -1 --
int(0)
bool(true)
-- Compression level 0 --
int(0)
bool(true)
-- Compression level 1 --
int(0)
bool(true)
-- Compression level 2 --
int(0)
bool(true)
-- Compression level 3 --
int(0)
bool(true)
-- Compression level 4 --
int(0)
bool(true)
-- Compression level 5 --
int(0)
bool(true)
-- Compression level 6 --
int(0)
bool(true)
-- Compression level 7 --
int(0)
bool(true)
-- Compression level 8 --
int(0)
bool(true)
-- Compression level 9 --
int(0)
bool(true)
-- Compression level -1 --
int(0)
bool(true)
-- Compression level 0 --
int(0)
bool(true)
-- Compression level 1 --
int(0)
bool(true)
-- Compression level 2 --
int(0)
bool(true)
-- Compression level 3 --
int(0)
bool(true)
-- Compression level 4 --
int(0)
bool(true)
-- Compression level 5 --
int(0)
bool(true)
-- Compression level 6 --
int(0)
bool(true)
-- Compression level 7 --
int(0)
bool(true)
-- Compression level 8 --
int(0)
bool(true)
-- Compression level 9 --
int(0)
bool(true)
-- Testing with no specified compression level --
int(0)
bool(true)

View File

@@ -20,7 +20,6 @@ try {
}
echo "\n-- Testing with invalid encoding --\n";
$data = 'string_val';
$level = 2;
$encoding = 99;
try {

View File

@@ -4,7 +4,7 @@ Test gzcompress() function : variation
zlib
--FILE--
<?php
include(__DIR__ . '/data.inc');
include(__DIR__ . '/data/data.inc');
echo "*** Testing gzcompress() : variation ***\n";

View File

@@ -8,7 +8,7 @@ zlib
* add a comment here to say what the test is supposed to do
*/
include(__DIR__ . '/data.inc');
include(__DIR__ . '/data/data.inc');
echo "*** Testing gzdeflate() : basic functionality ***\n";
@@ -23,68 +23,68 @@ $smallstring = "A small string to compress\n";
for($i = -1; $i < 10; $i++) {
echo "-- Compression level $i --\n";
$output = gzdeflate($data, $i);
var_dump(strcmp(gzinflate($output), $data));
var_dump(gzinflate($output) === $data);
}
// Compressing a smaller string
for($i = -1; $i < 10; $i++) {
echo "-- Compression level $i --\n";
$output = gzdeflate($smallstring, $i);
var_dump(strcmp(gzinflate($output), $smallstring));
var_dump(gzinflate($output) === $smallstring);
}
// Calling gzdeflate() with just mandatory arguments
echo "\n-- Testing with no specified compression level --\n";
$output = gzdeflate($smallstring);
var_dump(strcmp(gzinflate($output), $smallstring));
var_dump(gzinflate($output) === $smallstring);
?>
--EXPECT--
*** Testing gzdeflate() : basic functionality ***
-- Compression level -1 --
int(0)
bool(true)
-- Compression level 0 --
int(0)
bool(true)
-- Compression level 1 --
int(0)
bool(true)
-- Compression level 2 --
int(0)
bool(true)
-- Compression level 3 --
int(0)
bool(true)
-- Compression level 4 --
int(0)
bool(true)
-- Compression level 5 --
int(0)
bool(true)
-- Compression level 6 --
int(0)
bool(true)
-- Compression level 7 --
int(0)
bool(true)
-- Compression level 8 --
int(0)
bool(true)
-- Compression level 9 --
int(0)
bool(true)
-- Compression level -1 --
int(0)
bool(true)
-- Compression level 0 --
int(0)
bool(true)
-- Compression level 1 --
int(0)
bool(true)
-- Compression level 2 --
int(0)
bool(true)
-- Compression level 3 --
int(0)
bool(true)
-- Compression level 4 --
int(0)
bool(true)
-- Compression level 5 --
int(0)
bool(true)
-- Compression level 6 --
int(0)
bool(true)
-- Compression level 7 --
int(0)
bool(true)
-- Compression level 8 --
int(0)
bool(true)
-- Compression level 9 --
int(0)
bool(true)
-- Testing with no specified compression level --
int(0)
bool(true)

View File

@@ -4,12 +4,10 @@ Test gzdeflate() function : variation
zlib
--FILE--
<?php
include(__DIR__ . '/data.inc');
include(__DIR__ . '/data/data.inc');
echo "*** Testing gzdeflate() : variation ***\n";
echo "\n-- Testing multiple compression --\n";
$output = gzdeflate($data);
var_dump(strlen($output));

View File

@@ -8,7 +8,7 @@ zlib
* Test basic function of gzencode
*/
include(__DIR__ . '/data.inc');
include(__DIR__ . '/data/data.inc');
echo "*** Testing gzencode() : basic functionality ***\n";
@@ -23,24 +23,24 @@ $smallstring = "A small string to compress\n";
for($i = -1; $i < 10; $i++) {
echo "-- Compression level $i --\n";
$output = gzencode($data, $i);
var_dump(strcmp(gzdecode($output), $data)===0);
var_dump(gzdecode($output) === $data);
}
// Compressing a smaller string
for($i = -1; $i < 10; $i++) {
echo "-- Compression level $i --\n";
$output = gzencode($smallstring, $i);
var_dump(strcmp(gzdecode($output), $smallstring)===0);
var_dump(gzdecode($output) === $smallstring);
}
// Calling gzencode() with mandatory arguments
echo "\n-- Testing with no specified compression level --\n";
$output = gzencode($smallstring);
var_dump(strcmp(gzdecode($output), $smallstring)===0);
var_dump(gzdecode($output) === $smallstring);
echo "\n-- Testing gzencode with mode specified --\n";
$outupt = gzencode($smallstring, -1, FORCE_GZIP);
var_dump(strcmp(gzdecode($output), $smallstring)===0);
var_dump(gzdecode($output) === $smallstring);
?>
--EXPECTF--
*** Testing gzencode() : basic functionality ***

View File

@@ -11,7 +11,7 @@ if (substr(PHP_OS, 0, 3) != "WIN") {
--FILE--
<?php
include(__DIR__ . '/data.inc');
include(__DIR__ . '/data/data.inc');
echo "*** Testing gzencode() : variation ***\n";

View File

@@ -9,15 +9,13 @@ if( substr(PHP_OS, 0, 3) == "WIN" ) {
die("skip.. Do not run on Windows");
}
if (PHP_OS == "Darwin") {
print "skip - OS is encoded in headers, tested header is non Darwin";
}
?>
--FILE--
<?php
include(__DIR__ . '/data.inc');
include(__DIR__ . '/data/data.inc');
echo "*** Testing gzencode() : variation ***\n";

View File

@@ -4,14 +4,10 @@ Test gzencode() function : variation - verify header contents with all encoding
zlib
--SKIPIF--
<?php
if( substr(PHP_OS, 0, 3) != "WIN" ) {
die("skip.. only for Windows");
}
include 'func.inc';
include 'data/func.inc';
if (version_compare(get_zlib_version(), "1.2.11") < 0) {
die("skip - at least zlib 1.2.11 required, got " . get_zlib_version());
}

View File

@@ -4,13 +4,9 @@ Test gzencode() function : variation - verify header contents with all encoding
zlib
--SKIPIF--
<?php
if( substr(PHP_OS, 0, 3) == "WIN" ) {
die("skip.. Do not run on Windows");
}
if (PHP_OS == "Darwin") {
print "skip - OS is encoded in headers, tested header is non Darwin";
}

View File

@@ -7,7 +7,7 @@ zlib
// note that gzeof is an alias to gzeof. parameter checking tests will be
// the same as gzeof
$f = __DIR__."/004.txt.gz";
$f = __DIR__."/data/test.txt.gz";
echo "-- test 1 --\n";
$h = gzopen($f, 'r');

View File

@@ -5,16 +5,12 @@ zlib
--FILE--
<?php
var_dump(gzfile("nonexistent_file_gzfile",1));
var_dump(gzfile(__DIR__."/004.txt.gz"));
var_dump(gzfile(__DIR__."/004.txt.gz", 1));
var_dump(gzfile(__DIR__."/gzfile-mb私はガラスを食べられます.txt.gz"));
var_dump(gzfile(__DIR__."/gzfile-mb私はガラスを食べられます.txt.gz", true));
echo "Done\n";
?>
--EXPECTF--
Warning: gzfile(nonexistent_file_gzfile): Failed to open stream: No such file or directory in %s on line %d
bool(false)
--EXPECT--
array(6) {
[0]=>
string(36) "When you're taught through feelings

View File

@@ -19,8 +19,13 @@ gzclose($h);
var_dump(gzfile( $filename ) );
unlink($filename);
rmdir($dirname);
?>
--CLEAN--
<?php
$dirname = 'gzfile_temp';
$filename = $dirname.'/gzfile_basic.txt.gz';
@unlink($filename);
@rmdir($dirname);
?>
--EXPECT--
array(3) {

View File

@@ -19,8 +19,13 @@ fclose($h);
var_dump(gzfile( $filename ) );
unlink($filename);
rmdir($dirname);
?>
--CLEAN--
<?php
$dirname = 'gzfile_temp2';
$filename = $dirname.'/gzfile_basic2.txt';
@unlink($filename);
@rmdir($dirname);
?>
--EXPECT--
array(3) {

View File

@@ -1,20 +1,16 @@
--TEST--
gzfile() with various invalid params
gzfile() with a proper gz file
--EXTENSIONS--
zlib
--FILE--
<?php
var_dump(gzfile("nonexistent_file_gzfile",1));
var_dump(gzfile(__DIR__."/004私はガラスを食べられます.txt.gz"));
var_dump(gzfile(__DIR__."/004私はガラスを食べられます.txt.gz", 1));
var_dump(gzfile(__DIR__."/data/test.txt.gz"));
var_dump(gzfile(__DIR__."/data/test.txt.gz", true));
echo "Done\n";
?>
--EXPECTF--
Warning: gzfile(nonexistent_file_gzfile): Failed to open stream: No such file or directory in %s on line %d
bool(false)
--EXPECT--
array(6) {
[0]=>
string(36) "When you're taught through feelings

View File

@@ -1,104 +0,0 @@
--TEST--
Test function gzfile() by substituting argument 2 with int values.
--EXTENSIONS--
zlib
--FILE--
<?php
$filename = __DIR__."/004.txt.gz";
$variation = array (
'int 0' => 0,
'int 1' => 1,
'int 12345' => 12345,
'int -12345' => -2345,
);
foreach ( $variation as $var ) {
var_dump(gzfile( $filename, $var ) );
}
?>
--EXPECT--
array(6) {
[0]=>
string(36) "When you're taught through feelings
"
[1]=>
string(26) "Destiny flying high above
"
[2]=>
string(38) "all I know is that you can realize it
"
[3]=>
string(18) "Destiny who cares
"
[4]=>
string(19) "as it turns around
"
[5]=>
string(39) "and I know that it descends down on me
"
}
array(6) {
[0]=>
string(36) "When you're taught through feelings
"
[1]=>
string(26) "Destiny flying high above
"
[2]=>
string(38) "all I know is that you can realize it
"
[3]=>
string(18) "Destiny who cares
"
[4]=>
string(19) "as it turns around
"
[5]=>
string(39) "and I know that it descends down on me
"
}
array(6) {
[0]=>
string(36) "When you're taught through feelings
"
[1]=>
string(26) "Destiny flying high above
"
[2]=>
string(38) "all I know is that you can realize it
"
[3]=>
string(18) "Destiny who cares
"
[4]=>
string(19) "as it turns around
"
[5]=>
string(39) "and I know that it descends down on me
"
}
array(6) {
[0]=>
string(36) "When you're taught through feelings
"
[1]=>
string(26) "Destiny flying high above
"
[2]=>
string(38) "all I know is that you can realize it
"
[3]=>
string(18) "Destiny who cares
"
[4]=>
string(19) "as it turns around
"
[5]=>
string(39) "and I know that it descends down on me
"
}

View File

@@ -1,39 +0,0 @@
--TEST--
Test function gzfile() by substituting argument 1 with float values.
--EXTENSIONS--
zlib
--FILE--
<?php
$use_include_path = false;
$variation = array(
'float 10.5' => 10.5,
'float -10.5' => -10.5,
'float 12.3456789000e10' => 12.3456789000e10,
'float -12.3456789000e10' => -12.3456789000e10,
'float .5' => .5,
);
foreach ( $variation as $var ) {
var_dump(gzfile( $var , $use_include_path ) );
}
?>
--EXPECTF--
Warning: gzfile(10.5): Failed to open stream: No such file or directory in %s on line %d
bool(false)
Warning: gzfile(-10.5): Failed to open stream: No such file or directory in %s on line %d
bool(false)
Warning: gzfile(123456789000): Failed to open stream: No such file or directory in %s on line %d
bool(false)
Warning: gzfile(-123456789000): Failed to open stream: No such file or directory in %s on line %d
bool(false)
Warning: gzfile(0.5): Failed to open stream: No such file or directory in %s on line %d
bool(false)

View File

@@ -1,35 +0,0 @@
--TEST--
Test function gzfile() by substituting argument 1 with int values.
--EXTENSIONS--
zlib
--FILE--
<?php
$use_include_path = false;
$variation = array (
'int 0' => 0,
'int 1' => 1,
'int 12345' => 12345,
'int -12345' => -2345,
);
foreach ( $variation as $var ) {
var_dump(gzfile( $var , $use_include_path ) );
}
?>
--EXPECTF--
Warning: gzfile(0): Failed to open stream: No such file or directory in %s on line %d
bool(false)
Warning: gzfile(1): Failed to open stream: No such file or directory in %s on line %d
bool(false)
Warning: gzfile(12345): Failed to open stream: No such file or directory in %s on line %d
bool(false)
Warning: gzfile(-2345): Failed to open stream: No such file or directory in %s on line %d
bool(false)

View File

@@ -1,39 +1,18 @@
--TEST--
Test function gzfile() by substituting argument 1 with string values.
gzfile() with unknown file
--EXTENSIONS--
zlib
--FILE--
<?php
$filename = "nonexistent_file_gzfile.txt.gz";
$use_include_path = false;
$heredoc = <<<EOT
hello world
EOT;
$variation_array = array(
'string DQ' => "string",
'string SQ' => 'string',
'mixed case string' => "sTrInG",
'heredoc' => $heredoc
);
foreach ( $variation_array as $var ) {
var_dump(gzfile( $var , $use_include_path ) );
}
var_dump(gzfile($filename, false));
var_dump(gzfile($filename, true));
?>
--EXPECTF--
Warning: gzfile(string): Failed to open stream: No such file or directory in %s on line %d
Warning: gzfile(nonexistent_file_gzfile.txt.gz): Failed to open stream: No such file or directory in %s on line %d
bool(false)
Warning: gzfile(string): Failed to open stream: No such file or directory in %s on line %d
bool(false)
Warning: gzfile(sTrInG): Failed to open stream: No such file or directory in %s on line %d
bool(false)
Warning: gzfile(hello world): Failed to open stream: No such file or directory in %s on line %d
Warning: gzfile(nonexistent_file_gzfile.txt.gz): Failed to open stream: No such file or directory in %s on line %d
bool(false)

View File

@@ -1,103 +0,0 @@
--TEST--
Test function gzfile() by substituting argument 2 with boolean values.
--EXTENSIONS--
zlib
--FILE--
<?php
$filename = __DIR__."/004.txt.gz";
$variation = array(
'lowercase true' => true,
'lowercase false' =>false,
'uppercase TRUE' =>TRUE,
'uppercase FALSE' =>FALSE,
);
foreach ( $variation as $var ) {
var_dump(gzfile( $filename, $var ) );
}
?>
--EXPECT--
array(6) {
[0]=>
string(36) "When you're taught through feelings
"
[1]=>
string(26) "Destiny flying high above
"
[2]=>
string(38) "all I know is that you can realize it
"
[3]=>
string(18) "Destiny who cares
"
[4]=>
string(19) "as it turns around
"
[5]=>
string(39) "and I know that it descends down on me
"
}
array(6) {
[0]=>
string(36) "When you're taught through feelings
"
[1]=>
string(26) "Destiny flying high above
"
[2]=>
string(38) "all I know is that you can realize it
"
[3]=>
string(18) "Destiny who cares
"
[4]=>
string(19) "as it turns around
"
[5]=>
string(39) "and I know that it descends down on me
"
}
array(6) {
[0]=>
string(36) "When you're taught through feelings
"
[1]=>
string(26) "Destiny flying high above
"
[2]=>
string(38) "all I know is that you can realize it
"
[3]=>
string(18) "Destiny who cares
"
[4]=>
string(19) "as it turns around
"
[5]=>
string(39) "and I know that it descends down on me
"
}
array(6) {
[0]=>
string(36) "When you're taught through feelings
"
[1]=>
string(26) "Destiny flying high above
"
[2]=>
string(38) "all I know is that you can realize it
"
[3]=>
string(18) "Destiny who cares
"
[4]=>
string(19) "as it turns around
"
[5]=>
string(39) "and I know that it descends down on me
"
}

View File

@@ -4,8 +4,7 @@ Test function gzgetc() by calling it with its expected arguments zlib 1.2.5
zlib
--SKIPIF--
<?php
include 'func.inc';
include 'data/func.inc';
if (version_compare(get_zlib_version(), '1.2.5') > 0) {
die('skip - only for zlib <= 1.2.5');
}
@@ -16,7 +15,7 @@ if (version_compare(get_zlib_version(), '1.2.5') > 0) {
// note that gzgets is an alias to fgets. parameter checking tests will be
// the same as gzgets
$f = __DIR__."/004.txt.gz";
$f = __DIR__."/data/test.txt.gz";
$h = gzopen($f, 'r');
$count = 0;

View File

@@ -5,7 +5,7 @@ zlib
--SKIPIF--
<?php
include 'func.inc';
include 'data/func.inc';
if (version_compare(get_zlib_version(), '1.2.7') < 0) {
die('skip - only for zlib >= 1.2.7');
}
@@ -16,7 +16,7 @@ if (version_compare(get_zlib_version(), '1.2.7') < 0) {
// note that gzgets is an alias to fgets. parameter checking tests will be
// the same as gzgets
$f = __DIR__."/004.txt.gz";
$f = __DIR__."/data/test.txt.gz";
$h = gzopen($f, 'r');
if ($h) {
$count = 0;

View File

@@ -8,7 +8,7 @@ zlib
// note that gzgets is an alias to fgets. parameter checking tests will be
// the same as fgets
$f = __DIR__."/004.txt.gz";
$f = __DIR__."/data/test.txt.gz";
$h = gzopen($f, 'r');
$lengths = array(10, 14, 7, 99);
foreach ($lengths as $length) {

View File

@@ -4,7 +4,7 @@ Test gzinflate() function : error conditions
zlib
--FILE--
<?php
include(__DIR__ . '/data.inc');
include(__DIR__ . '/data/data.inc');
echo "*** Testing gzinflate() : error conditions ***\n";

View File

@@ -8,10 +8,10 @@ $original = 'aaaaaaaaaaaaaaa';
$packed=gzdeflate($original);
echo strlen($packed)." ".strlen($original)."\n";
$unpacked=gzinflate($packed, strlen($original));
if (strcmp($original,$unpacked)==0) echo "Strings are equal\n";
if ($original === $unpacked) echo "Strings are equal\n";
$unpacked=gzinflate($packed, strlen($original)*10);
if (strcmp($original,$unpacked)==0) echo "Strings are equal\n";
if ($original === $unpacked) echo "Strings are equal\n";
$unpacked=gzinflate($packed, 1);
if ($unpacked === false) echo "Failed (as expected)\n";

View File

@@ -8,7 +8,7 @@ echo "*** Testing gzopen() : basic functionality ***\n";
// Initialise all required variables
$filename = __DIR__."/004.txt.gz";
$filename = __DIR__."/data/test.txt.gz";
$mode = 'r';
$use_include_path = false;

View File

@@ -5,7 +5,7 @@ zlib
--FILE--
<?php
$f = __DIR__."/004.txt.gz";
$f = __DIR__."/data/test.txt.gz";
$h1 = gzopen($f, 'r');
$h2 = gzopen($f, 'r');

View File

@@ -8,7 +8,7 @@ echo "*** Testing gzopen() : variation ***\n";
$modes = array('r+', 'rf', 'w+' , 'e');
$file = __DIR__."/004.txt.gz";
$file = __DIR__."/data/test.txt.gz";
foreach ($modes as $mode) {
echo "mode=$mode\n";
@@ -38,6 +38,6 @@ gzopen=bool(false)
mode=e
Warning: gzopen(%s/004.txt.gz): Failed to open stream: %s in %s on line %d
Warning: gzopen(%s/test.txt.gz): Failed to open stream: %s in %s on line %d
gzopen=bool(false)

View File

@@ -8,7 +8,7 @@ zlib
// note that gzpassthru is an alias to fpassthru. parameter checking tests will be
// the same as fpassthru
$f = __DIR__."/004.txt.gz";
$f = __DIR__."/data/test.txt.gz";
$h = gzopen($f, 'r');
var_dump(gzpassthru($h));
var_dump(gzpassthru($h));

View File

@@ -7,7 +7,7 @@ zlib
// note that gzread is an alias to fread. parameter checking tests will be
// the same as fread
$f = __DIR__."/004.txt.gz";
$f = __DIR__."/data/test.txt.gz";
$h = gzopen($f, 'r');
$lengths = array(10, 14, 7, 99, 2000);

View File

@@ -4,7 +4,7 @@ Test function gzread() by calling it invalid lengths
zlib
--FILE--
<?php
$f = __DIR__."/004.txt.gz";
$f = __DIR__."/data/test.txt.gz";
$h = gzopen($f, 'r');
var_dump(gzread($h, 10));
try {

View File

@@ -4,7 +4,7 @@ Test function gzrewind() by calling it with its expected arguments when reading
zlib
--FILE--
<?php
$f = __DIR__."/004.txt.gz";
$f = __DIR__."/data/test.txt.gz";
$h = gzopen($f, 'r');
echo "test rewind before doing anything\n";
var_dump(gzrewind($h));

View File

@@ -4,7 +4,7 @@ Test function gzrewind() by calling it with its expected arguments when reading
zlib
--FILE--
<?php
$f = __DIR__."/004.txt.gz";
$f = __DIR__."/data/test.txt.gz";
$h = gzopen($f, 'r');
// read to the end of the file

View File

@@ -4,7 +4,7 @@ Test function gzseek() by calling it with its expected arguments when reading
zlib
--FILE--
<?php
$f = __DIR__."/004.txt.gz";
$f = __DIR__."/data/test.txt.gz";
$h = gzopen($f, 'r');
echo "move to the 50th byte\n";

View File

@@ -4,7 +4,7 @@ Test function gzseek() by calling it with SEEK_SET when reading
zlib
--FILE--
<?php
$f = __DIR__."/004.txt.gz";
$f = __DIR__."/data/test.txt.gz";
$h = gzopen($f, 'r');
echo "move to the 50th byte\n";

View File

@@ -4,7 +4,7 @@ Test function gzseek() by calling it with SEEK_CUR when reading
zlib
--FILE--
<?php
$f = __DIR__."/004.txt.gz";
$f = __DIR__."/data/test.txt.gz";
$h = gzopen($f, 'r');
echo "move to the 50th byte\n";

View File

@@ -4,7 +4,7 @@ Test function gzseek() by calling it with SEEK_END when reading
zlib
--FILE--
<?php
$f = __DIR__."/004.txt.gz";
$f = __DIR__."/data/test.txt.gz";
$h = gzopen($f, 'r');
// move 40 bytes
echo "move 40 bytes\n";

View File

@@ -4,7 +4,7 @@ Test function gztell() by calling it with its expected arguments when reading
zlib
--FILE--
<?php
$f = __DIR__."/004.txt.gz";
$f = __DIR__."/data/test.txt.gz";
$h = gzopen($f, 'r');
$intervals = array(7, 22, 54, 17, 27, 15, 1000);
// tell should be 7, 29, 83, 100, 127, 142, 176 (176 is length of uncompressed file)

View File

@@ -4,7 +4,7 @@ Test gzuncompress() function : basic functionality
zlib
--FILE--
<?php
include(__DIR__ . '/data.inc');
include(__DIR__ . '/data/data.inc');
echo "*** Testing gzuncompress() : basic functionality ***\n";

View File

@@ -5,7 +5,7 @@ zlib
--FILE--
<?php
$filename = __DIR__."/004.txt.gz";
$filename = __DIR__."/data/test.txt.gz";
$h = gzopen($filename, 'r');
$str = "Here is the string to be written. ";
$length = 10;

View File

@@ -3,9 +3,7 @@ zlib.output_compression
--EXTENSIONS--
zlib
--SKIPIF--
<?php
if (false === stristr(PHP_SAPI, "cgi")) die("skip need sapi/cgi");
?>
--CGI--
--GET--
a=b
--INI--

View File

@@ -3,9 +3,7 @@ zlib.output_compression
--EXTENSIONS--
zlib
--SKIPIF--
<?php
if (false === stristr(PHP_SAPI, "cgi")) die("skip need sapi/cgi");
?>
--CGI--
--INI--
zlib.output_compression=0
--ENV--

View File

@@ -3,9 +3,7 @@ ob_gzhandler
--EXTENSIONS--
zlib
--SKIPIF--
<?php
if (false === stristr(PHP_SAPI, "cgi")) die("skip need sapi/cgi");
?>
--CGI--
--INI--
zlib.output_compression=0
--ENV--

View File

@@ -2,10 +2,7 @@
ob_gzhandler
--EXTENSIONS--
zlib
--SKIPIF--
<?php
if (false === stristr(PHP_SAPI, "cgi")) die("skip need sapi/cgi");
?>
--CGI-
--INI--
zlib.output_compression=0
--ENV--

View File

@@ -2,10 +2,7 @@
ob_gzhandler legacy
--EXTENSIONS--
zlib
--SKIPIF--
<?php
if (false === stristr(PHP_SAPI, "cgi")) die("skip need sapi/cgi");
?>
--CGI--
--INI--
zlib.output_compression=0
--ENV--

View File

@@ -1,52 +0,0 @@
--TEST--
Test function readgzfile() by substituting argument 2 with int values.
--EXTENSIONS--
zlib
--FILE--
<?php
$filename = __DIR__."/004.txt.gz";
$variation = array (
'int 0' => 0,
'int 1' => 1,
'int 12345' => 12345,
'int -12345' => -2345,
);
foreach ( $variation as $var ) {
var_dump(readgzfile( $filename, $var ) );
}
?>
--EXPECT--
When you're taught through feelings
Destiny flying high above
all I know is that you can realize it
Destiny who cares
as it turns around
and I know that it descends down on me
int(176)
When you're taught through feelings
Destiny flying high above
all I know is that you can realize it
Destiny who cares
as it turns around
and I know that it descends down on me
int(176)
When you're taught through feelings
Destiny flying high above
all I know is that you can realize it
Destiny who cares
as it turns around
and I know that it descends down on me
int(176)
When you're taught through feelings
Destiny flying high above
all I know is that you can realize it
Destiny who cares
as it turns around
and I know that it descends down on me
int(176)

View File

@@ -1,39 +0,0 @@
--TEST--
Test function readgzfile() by substituting argument 1 with float values.
--EXTENSIONS--
zlib
--FILE--
<?php
$use_include_path = false;
$variation = array(
'float 10.5' => 10.5,
'float -10.5' => -10.5,
'float 12.3456789000e10' => 12.3456789000e10,
'float -12.3456789000e10' => -12.3456789000e10,
'float .5' => .5,
);
foreach ( $variation as $var ) {
var_dump(readgzfile( $var , $use_include_path ) );
}
?>
--EXPECTF--
Warning: readgzfile(10.5): Failed to open stream: No such file or directory in %s on line %d
bool(false)
Warning: readgzfile(-10.5): Failed to open stream: No such file or directory in %s on line %d
bool(false)
Warning: readgzfile(123456789000): Failed to open stream: No such file or directory in %s on line %d
bool(false)
Warning: readgzfile(-123456789000): Failed to open stream: No such file or directory in %s on line %d
bool(false)
Warning: readgzfile(0.5): Failed to open stream: No such file or directory in %s on line %d
bool(false)

View File

@@ -1,35 +0,0 @@
--TEST--
Test function readgzfile() by substituting argument 1 with int values.
--EXTENSIONS--
zlib
--FILE--
<?php
$use_include_path = false;
$variation = array (
'int 0' => 0,
'int 1' => 1,
'int 12345' => 12345,
'int -12345' => -2345,
);
foreach ( $variation as $var ) {
var_dump(readgzfile( $var , $use_include_path ) );
}
?>
--EXPECTF--
Warning: readgzfile(0): Failed to open stream: No such file or directory in %s on line %d
bool(false)
Warning: readgzfile(1): Failed to open stream: No such file or directory in %s on line %d
bool(false)
Warning: readgzfile(12345): Failed to open stream: No such file or directory in %s on line %d
bool(false)
Warning: readgzfile(-2345): Failed to open stream: No such file or directory in %s on line %d
bool(false)

View File

@@ -1,39 +1,17 @@
--TEST--
Test function readgzfile() by substituting argument 1 with string values.
readgzfile() with unknown file
--EXTENSIONS--
zlib
--FILE--
<?php
$use_include_path = false;
$heredoc = <<<EOT
hello world
EOT;
$variation_array = array(
'string DQ' => "string",
'string SQ' => 'string',
'mixed case string' => "sTrInG",
'heredoc' => $heredoc
);
foreach ( $variation_array as $var ) {
var_dump(readgzfile( $var , $use_include_path ) );
}
$file = "unknown_file.txt.gz";
var_dump(readgzfile($file, false));
var_dump(readgzfile($file, true));
?>
--EXPECTF--
Warning: readgzfile(string): Failed to open stream: No such file or directory in %s on line %d
Warning: readgzfile(unknown_file.txt.gz): Failed to open stream: No such file or directory in %s on line %d
bool(false)
Warning: readgzfile(string): Failed to open stream: No such file or directory in %s on line %d
bool(false)
Warning: readgzfile(sTrInG): Failed to open stream: No such file or directory in %s on line %d
bool(false)
Warning: readgzfile(hello world): Failed to open stream: No such file or directory in %s on line %d
Warning: readgzfile(unknown_file.txt.gz): Failed to open stream: No such file or directory in %s on line %d
bool(false)

View File

@@ -1,51 +0,0 @@
--TEST--
Test function readgzfile() by substituting argument 2 with boolean values.
--EXTENSIONS--
zlib
--FILE--
<?php
$filename = __DIR__."/004.txt.gz";
$variation = array(
'lowercase true' => true,
'lowercase false' =>false,
'uppercase TRUE' =>TRUE,
'uppercase FALSE' =>FALSE,
);
foreach ( $variation as $var ) {
var_dump(readgzfile( $filename, $var ) );
}
?>
--EXPECT--
When you're taught through feelings
Destiny flying high above
all I know is that you can realize it
Destiny who cares
as it turns around
and I know that it descends down on me
int(176)
When you're taught through feelings
Destiny flying high above
all I know is that you can realize it
Destiny who cares
as it turns around
and I know that it descends down on me
int(176)
When you're taught through feelings
Destiny flying high above
all I know is that you can realize it
Destiny who cares
as it turns around
and I know that it descends down on me
int(176)
When you're taught through feelings
Destiny flying high above
all I know is that you can realize it
Destiny who cares
as it turns around
and I know that it descends down on me
int(176)

View File

@@ -10,7 +10,7 @@ if (PHP_OS_FAMILY !== "Windows") die("skip Only for Windows because it has manda
<?php
echo "without wrapper\n";
$f = __DIR__."/005.txt.gz";
$f = __DIR__."/data/windows-test.txt.gz";
$h = gzopen($f,'r');
$h2 = gzopen($f, 'r');
stream_set_chunk_size($h2,1);
@@ -23,9 +23,9 @@ gzclose($h);
gzclose($h2);
echo "\nwith wrapper\n";
$f = "compress.zlib://".__DIR__."/005.txt.gz";
$h = fopen($f,'r');
$h2 = fopen($f, 'r');
$f2 = "compress.zlib://".$f;
$h = fopen($f2,'r');
$h2 = fopen($f2, 'r');
stream_set_chunk_size($h2, 1);
var_dump(flock($h, LOCK_EX));

View File

@@ -4,7 +4,7 @@ Test compress.zlib:// scheme with the copy function: compressed to compressed
zlib
--FILE--
<?php
$inputFileName = __DIR__."/004.txt.gz";
$inputFileName = __DIR__."/data/test.txt.gz";
$outputFileName = __FILE__.'.tmp';
$srcFile = "compress.zlib://$inputFileName";

View File

@@ -4,7 +4,7 @@ Test compress.zlib:// scheme with the copy function: compressed to uncompressed
zlib
--FILE--
<?php
$inputFileName = __DIR__."/004.txt.gz";
$inputFileName = __DIR__."/data/test.txt.gz";
$outputFileName = __FILE__.'.tmp';
$srcFile = "compress.zlib://$inputFileName";

View File

@@ -4,7 +4,7 @@ Test compress.zlib:// scheme with the file
zlib
--FILE--
<?php
$inputFileName = __DIR__."/004.txt.gz";
$inputFileName = __DIR__."/data/test.txt.gz";
$srcFile = "compress.zlib://$inputFileName";
$contents = file($srcFile);
var_dump($contents);

View File

@@ -4,7 +4,7 @@ Test compress.zlib:// scheme with the file_get_contents
zlib
--FILE--
<?php
$inputFileName = __DIR__."/004.txt.gz";
$inputFileName = __DIR__."/data/test.txt.gz";
$srcFile = "compress.zlib://$inputFileName";
$contents = file_get_contents($srcFile);
echo $contents;

View File

@@ -4,7 +4,7 @@ Test compress.zlib:// scheme with the file_get_contents
zlib
--FILE--
<?php
$inputFileName = __DIR__."/004.txt.gz";
$inputFileName = __DIR__."/data/test.txt.gz";
$srcFile = "compress.zlib://$inputFileName";
readfile($srcFile);
?>

View File

@@ -4,7 +4,7 @@ Test compress.zlib:// scheme with the fopen
zlib
--FILE--
<?php
$inputFileName = __DIR__."/004.txt.gz";
$inputFileName = __DIR__."/data/test.txt.gz";
$srcFile = "compress.zlib://$inputFileName";
$h = fopen($srcFile, 'r');
fpassthru($h);

View File

@@ -4,7 +4,7 @@ Test compress.zlib:// scheme with the fopen on a file scheme
zlib
--FILE--
<?php
$inputFileName = __DIR__."/004.txt.gz";
$inputFileName = __DIR__."/data/test.txt.gz";
$srcFile = "file://$inputFileName";
$compressedFile = "compress.zlib://$srcFile";
@@ -14,7 +14,7 @@ fpassthru($h);
fclose($h);
?>
--EXPECTF--
file=compress.zlib://file://%s/004.txt.gz
file=compress.zlib://file://%s/test.txt.gz
When you're taught through feelings
Destiny flying high above

View File

@@ -4,7 +4,7 @@ Test compress.zlib:// scheme with the unlink function
zlib
--FILE--
<?php
$inputFileName = __DIR__."/004.txt.gz";
$inputFileName = __DIR__."/data/test.txt.gz";
$srcFile = "compress.zlib://$inputFileName";
rename($srcFile, 'something.tmp');
var_dump(file_exists($inputFileName));

View File

@@ -4,7 +4,7 @@ Test compress.zlib:// scheme with the unlink function
zlib
--FILE--
<?php
$inputFileName = __DIR__."/004.txt.gz";
$inputFileName = __DIR__."/data/test.txt.gz";
$srcFile = "compress.zlib://$inputFileName";
echo "file_exists=";
var_dump(file_exists($srcFile));
@@ -30,11 +30,11 @@ is_dir=bool(false)
is_readable=bool(false)
filesize=
Warning: filesize(): stat failed for compress.zlib://%s004.txt.gz in %s on line %d
Warning: filesize(): stat failed for compress.zlib://%stest.txt.gz in %s on line %d
bool(false)
filetype=
Warning: filetype(): Lstat failed for compress.zlib://%s004.txt.gz in %s on line %d
Warning: filetype(): Lstat failed for compress.zlib://%stest.txt.gz in %s on line %d
bool(false)
fileatime=
Warning: fileatime(): stat failed for compress.zlib://%s004.txt.gz in %s on line %d
Warning: fileatime(): stat failed for compress.zlib://%stest.txt.gz in %s on line %d
bool(false)

View File

@@ -4,7 +4,7 @@ Test compress.zlib:// scheme with the unlink function
zlib
--FILE--
<?php
$inputFileName = __DIR__."/004.txt.gz";
$inputFileName = __DIR__."/data/test.txt.gz";
$srcFile = "compress.zlib://$inputFileName";
unlink($srcFile);
var_dump(file_exists($inputFileName));

View File

@@ -4,7 +4,7 @@ Test function flock on a zlib stream
zlib
--FILE--
<?php
$f = __DIR__."/004.txt.gz";
$f = __DIR__."/data/test.txt.gz";
$h = gzopen($f,'r');
var_dump(flock($h, LOCK_EX));
gzclose($h);

View File

@@ -4,7 +4,7 @@ Test function fstat() on zlib wrapper
zlib
--FILE--
<?php
$f = __DIR__."/004.txt.gz";
$f = __DIR__."/data/test.txt.gz";
$h = gzopen($f, "r");
var_dump(fstat($h));
fclose($h);

View File

@@ -4,7 +4,7 @@ Test function ftruncate() on zlib wrapper by calling it with its expected argume
zlib
--FILE--
<?php
$f = __DIR__."/004.txt.gz";
$f = __DIR__."/data/test.txt.gz";
$f2 = "zlib_wrapper_ftruncate_basic.txt.gz";
copy($f, $f2);

View File

@@ -4,7 +4,7 @@ compress.zlib:// wrapper with compression level
zlib
--SKIPIF--
<?php
in_array('compress.zlib', stream_get_wrappers()) || print 'skip No zlib wrapper';
in_array('compress.zlib', stream_get_wrappers()) || die('skip No zlib wrapper');
?>
--FILE--
<?php declare(strict_types=1);

View File

@@ -5,13 +5,13 @@ zlib
--FILE--
<?php
echo "no wrapper\n";
$f = __DIR__."/004.txt.gz";
$f = __DIR__."/data/test.txt.gz";
$h = gzopen($f,'r');
var_dump(stream_get_meta_data($h));
gzclose($h);
echo "\nwith wrapper\n";
$f = "compress.zlib://".__DIR__."/004.txt.gz";
$h = fopen($f,'r');
$f2 = "compress.zlib://" . $f;
$h = fopen($f2,'r');
var_dump(stream_get_meta_data($h));
gzclose($h);
@@ -55,5 +55,5 @@ array(9) {
["seekable"]=>
bool(true)
["uri"]=>
string(%d) "compress.zlib://%s/004.txt.gz"
string(%d) "compress.zlib://%s/test.txt.gz"
}