xref: /PHP-8.3/ext/zlib/tests/bug60761.phpt (revision 74859783)
1--TEST--
2checks zlib compression output size is always the same
3--EXTENSIONS--
4zlib
5--CGI--
6--FILE--
7<?php
8
9// the INI directives from bug #60761 report
10ini_set('zlib.output_compression', '4096');
11ini_set('zlib.output_compression_level', '9');
12
13// try to duplicate the original bug by running this as a CGI
14// test using ob_start and zlib.output_compression(or ob_gzhandler)
15// so it follows more of the original code-path than just calling
16// gzcompress on CLI or CGI
17
18$lens = array();
19
20for ( $i=0 ; $i < 100 ; $i++ ) {
21
22    // can't use ob_gzhandler with zlib.output_compression
23    ob_start();//"ob_gzhandler");
24    phpinfo();
25    $html = ob_get_clean();
26
27    $len = strlen($html);
28
29    $lens[$len] = $len;
30}
31
32$lens = array_values($lens);
33
34echo "Compressed Lengths\n";
35
36// pass == only ONE length for all iterations
37//         (length didn't change during run)
38//
39// hard to anticipate what 'correct' length should be since
40// return value of phpinfo() will vary between installations...
41// just check that there is only one length
42//
43var_dump($lens); // show lengths to help triage in case of failure
44
45// expected headers since its CGI
46
47?>
48--EXPECTF--
49%s
50array(1) {
51  [0]=>
52  int(%d)
53}
54