summaryrefslogtreecommitdiff
path: root/ext/zlib/tests/deflate_add_error.phpt
blob: 4a467d39bfe983f8ae37c418e571ffc979b7fc2c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
--TEST--
Test incremental deflate_add() error functionality
--SKIPIF--
<?php
if (!extension_loaded("zlib")) {
    print "skip - ZLIB extension not loaded";
}
?>
--FILE--
<?php
$badResource = fopen("php://memory", "r+");

try {
    var_dump(deflate_add($badResource, "test"));
} catch (\TypeError $e) {
    echo $e->getMessage() . \PHP_EOL;
}

$resource = deflate_init(ZLIB_ENCODING_DEFLATE);
$badFlushType = 6789;

try {
    var_dump(deflate_add($resource, "test", $badFlushType));
} catch (\ValueError $e) {
    echo $e->getMessage() . \PHP_EOL;
}

?>
--EXPECT--
deflate_add(): Argument #1 ($context) must be of type DeflateContext, resource given
deflate_add(): Argument #3 ($flush_behavior) must be one of ZLIB_NO_FLUSH, ZLIB_PARTIAL_FLUSH, ZLIB_SYNC_FLUSH, ZLIB_FULL_FLUSH, ZLIB_BLOCK, or ZLIB_FINISH