Skip to content

Commit 5bd18e3

Browse files
authored
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
1 parent 89be689 commit 5bd18e3

File tree

83 files changed

+171
-698
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+171
-698
lines changed

ext/zlib/tests/002.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ $original = str_repeat("hallo php",4096);
88
$packed=gzcompress($original);
99
echo strlen($packed)." ".strlen($original)."\n";
1010
$unpacked=gzuncompress($packed);
11-
if (strcmp($original,$unpacked)==0) echo "Strings are equal\n";
11+
if ($original === $unpacked) echo "Strings are equal\n";
1212

1313
/* with explicit compression level, length */
1414
$original = str_repeat("hallo php",4096);
1515
$packed=gzcompress($original, 9);
1616
echo strlen($packed)." ".strlen($original)."\n";
1717
$unpacked=gzuncompress($packed, 40000);
18-
if (strcmp($original,$unpacked)==0) echo "Strings are equal\n";
18+
if ($original === $unpacked) echo "Strings are equal\n";
1919
?>
2020
--EXPECT--
2121
106 36864

ext/zlib/tests/003.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ zlib
77
$original = str_repeat("hallo php",4096);
88
$packed = gzencode($original);
99
echo strlen($packed)." ".strlen($original). "\n";
10-
if (strcmp($original, gzdecode($packed)) == 0) echo "Strings are equal";
10+
if ($original === gzdecode($packed)) echo "Strings are equal\n";
1111
?>
1212
--EXPECT--
1313
118 36864

ext/zlib/tests/bug55544-win.phpt

5 Bytes
Binary file not shown.

ext/zlib/tests/bug60761.phpt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22
checks zlib compression output size is always the same
33
--EXTENSIONS--
44
zlib
5+
--INI--
6+
zlib.output_compression=4096
7+
zlib.output_compression_level=9
58
--CGI--
69
--FILE--
710
<?php
811

9-
// the INI directives from bug #60761 report
10-
ini_set('zlib.output_compression', '4096');
11-
ini_set('zlib.output_compression_level', '9');
12-
1312
// try to duplicate the original bug by running this as a CGI
1413
// test using ob_start and zlib.output_compression(or ob_gzhandler)
1514
// so it follows more of the original code-path than just calling

ext/zlib/tests/bug61139.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ gzopen('someFile', 'c');
99
?>
1010
--CLEAN--
1111
<?php
12-
unlink('someFile');
12+
unlink('someFile');
1313
?>
1414
--EXPECTF--
1515
Warning: gzopen(): gzopen failed in %s on line %d

ext/zlib/tests/bug71417.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function test($case) {
4545
// The gzdecode() function applied to the corrupted compressed data always
4646
// detects the error:
4747
// --> gzdecode(): PHP Fatal error: Uncaught ErrorException: gzdecode(): data error in ...
48-
echo "gzdecode(): ", rawurldecode(gzdecode($compressed)), "\n";
48+
echo "gzdecode(): ", rawurldecode((string) gzdecode($compressed)), "\n";
4949

5050
file_put_contents($fn, $compressed);
5151

ext/zlib/tests/bug74240.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
Bug #74240 (deflate_add can allocate too much memory)
33
--EXTENSIONS--
44
zlib
5+
--INI--
6+
memory_limit=64M
57
--FILE--
68
<?php
79

8-
ini_set('memory_limit', '64M');
9-
1010
$deflator = deflate_init(ZLIB_ENCODING_RAW);
1111

1212
$bytes = str_repeat("*", 65536);

ext/zlib/tests/compress_zlib_wrapper.phpt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,14 @@ compress.zlib:// wrapper
44
zlib
55
--FILE--
66
<?php
7-
chdir(__DIR__. "/../../..");
8-
9-
$pfx = str_repeat('../', substr_count($_SERVER['PHP_SELF'], '../'));
7+
chdir(__DIR__. "/data");
108

119
// Relative path
12-
$fp = fopen("compress.zlib://{$pfx}ext/xsl/tests/xslt.xsl.gz", "rb");
10+
$fp = fopen("compress.zlib://test.txt.gz", "rb");
1311
fclose($fp);
1412

1513
// Absolute path
16-
$fp = fopen("compress.zlib://". __DIR__. "/../../../ext/xsl/tests/xslt.xsl.gz", "rb");
14+
$fp = fopen("compress.zlib://". __DIR__. "/data/test.txt.gz", "rb");
1715
fclose($fp);
1816

1917
echo "ok\n";
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)