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