php-src/ext/zlib/tests/deflate_add_block_v123.phpt
Daniel Lowrey c488172975 Improve ZBLOCK handling with zlib < 1.2.4
The original commit for this issue (62b1293) assumed Z_BLOCK was
only defined in < 1.2.4. However, this flush type *is* defined but
is only unavailable for use with deflate().

This new commit correctly checks the ZLIB_VERNUM constant to
determine if Z_BLOCK flush is available for the current deflate()
operation and triggers an appropriate error as needed.

New ZLIB_VERSION and ZLIB_VERNUM constants are also exposed in
userland to allow testing this behavior in environments running
zlib < 1.2.4 (ZLIB_VERNUM check is needed).
2015-05-07 10:31:41 -04:00

25 lines
539 B
PHP

--TEST--
Test deflate_add() errors with ZLIB_BLOCK in zlib < 1.2.4
--SKIPIF--
<?php
if (!extension_loaded("zlib")) {
print "skip - ZLIB extension not loaded";
}
if (ZLIB_VERNUM >= 0x1240) {
print "skip - ZLIB < 1.2.4 required for test";
}
?>
--FILE--
<?php
$resource = deflate_init(ZLIB_ENCODING_GZIP);
var_dump(deflate_add($resource, "aaaaaaaaaaaaaaaaaaaaaa", ZLIB_BLOCK));
?>
===DONE===
--EXPECTF--
Warning: deflate_add(): zlib >= 1.2.4 required for BLOCK deflate; current version: %s in %s on line %d
bool(false)
===DONE===