9 $deflate = StreamFilter\fun(
'zlib.deflate');
11 $data = $deflate(
'hello') . $deflate(
' ') . $deflate(
'world') . $deflate();
13 $this->assertEquals(gzdeflate(
'hello world'), $data);
18 if (PHP_VERSION >= 7) $this->markTestSkipped(
'Not supported on PHP7 (empty string does not invoke filter)');
20 $deflate = StreamFilter\fun(
'zlib.deflate');
25 $this->assertEquals(
"\x03\x00", $data);
30 $deflate = StreamFilter\fun(
'zlib.deflate');
33 $expected = str_repeat(
'hello', $n);
36 for ($i = 0; $i < $n; ++$i) {
37 $bytes .= $deflate(
'hello');
41 $this->assertEquals($expected, gzinflate($bytes));
46 $inflate = StreamFilter\fun(
'zlib.inflate');
48 $data = $inflate(gzdeflate(
'hello world')) . $inflate();
50 $this->assertEquals(
'hello world', $data);
55 $inflate = StreamFilter\fun(
'zlib.inflate');
57 $data = $inflate(
"\x03\x00") . $inflate();
59 $this->assertEquals(
'', $data);
64 if (defined(
'HHVM_VERSION')) $this->markTestSkipped(
'Not supported on HHVM (final chunk will not be emitted)');
66 $inflate = StreamFilter\fun(
'zlib.inflate');
68 $expected = str_repeat(
'hello', 10);
69 $bytes = gzdeflate($expected);
72 foreach (str_split($bytes, 2) as $chunk) {
73 $ret .= $inflate($chunk);
77 $this->assertEquals($expected, $ret);