Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 107 additions & 0 deletions ext/zlib/tests/zlib_filter_deflate_param_errors.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
--TEST--
zlib.deflate filter param errors
--EXTENSIONS--
zlib
--FILE--
<?php
$fp = fopen('php://stdout', 'w');

$param = 'not an array or int';
var_dump(stream_filter_append($fp, 'zlib.deflate', STREAM_FILTER_WRITE, $param));

$param = -2;
var_dump(stream_filter_append($fp, 'zlib.deflate', STREAM_FILTER_WRITE, $param));

$param = 10;
var_dump(stream_filter_append($fp, 'zlib.deflate', STREAM_FILTER_WRITE, $param));

$param = ['memory' => 'not an int'];
var_dump(stream_filter_append($fp, 'zlib.deflate', STREAM_FILTER_WRITE, $param));

$param = ['memory' => 0];
var_dump(stream_filter_append($fp, 'zlib.deflate', STREAM_FILTER_WRITE, $param));

$param = ['memory' => 10];
var_dump(stream_filter_append($fp, 'zlib.deflate', STREAM_FILTER_WRITE, $param));

$param = ['window' => 'not an int'];
var_dump(stream_filter_append($fp, 'zlib.deflate', STREAM_FILTER_WRITE, $param));

$param = ['window' => -16];
var_dump(stream_filter_append($fp, 'zlib.deflate', STREAM_FILTER_WRITE, $param));

$param = ['window' => 32];
var_dump(stream_filter_append($fp, 'zlib.deflate', STREAM_FILTER_WRITE, $param));

$param = ['level' => 'not an int'];
var_dump(stream_filter_append($fp, 'zlib.deflate', STREAM_FILTER_WRITE, $param));

$param = ['level' => -2];
var_dump(stream_filter_append($fp, 'zlib.deflate', STREAM_FILTER_WRITE, $param));

$param = ['level' => 10];
var_dump(stream_filter_append($fp, 'zlib.deflate', STREAM_FILTER_WRITE, $param));

fclose($fp);

?>
--EXPECTF--
Warning: stream_filter_append(): Filter parameters for zlib.deflate filter must be of type array|int, string given in %s on line %d

Warning: stream_filter_append(): Unable to create or locate filter "zlib.deflate" in %s on line %d
bool(false)

Warning: stream_filter_append(): Compression level must be between -1 and 9, -2 given in %s on line %d

Warning: stream_filter_append(): Unable to create or locate filter "zlib.deflate" in %s on line %d
bool(false)

Warning: stream_filter_append(): Compression level must be between -1 and 9, 10 given in %s on line %d

Warning: stream_filter_append(): Unable to create or locate filter "zlib.deflate" in %s on line %d
bool(false)

Warning: stream_filter_append(): Window size must be of type int, string given in %s on line %d

Warning: stream_filter_append(): Unable to create or locate filter "zlib.deflate" in %s on line %d
bool(false)

Warning: stream_filter_append(): Memory level must be between 1 and 9, 0 given in %s on line %d

Warning: stream_filter_append(): Unable to create or locate filter "zlib.deflate" in %s on line %d
bool(false)

Warning: stream_filter_append(): Memory level must be between 1 and 9, 10 given in %s on line %d

Warning: stream_filter_append(): Unable to create or locate filter "zlib.deflate" in %s on line %d
bool(false)

Warning: stream_filter_append(): Window size must be of type int, string given in %s on line %d

Warning: stream_filter_append(): Unable to create or locate filter "zlib.deflate" in %s on line %d
bool(false)

Warning: stream_filter_append(): Window size must be between -15 and 31, -16 given in %s on line %d

Warning: stream_filter_append(): Unable to create or locate filter "zlib.deflate" in %s on line %d
bool(false)

Warning: stream_filter_append(): Window size must be between -15 and 31, 32 given in %s on line %d

Warning: stream_filter_append(): Unable to create or locate filter "zlib.deflate" in %s on line %d
bool(false)

Warning: stream_filter_append(): Compression level must be of type int, string given in %s on line %d

Warning: stream_filter_append(): Unable to create or locate filter "zlib.deflate" in %s on line %d
bool(false)

Warning: stream_filter_append(): Compression level must be between -1 and 9, -2 given in %s on line %d

Warning: stream_filter_append(): Unable to create or locate filter "zlib.deflate" in %s on line %d
bool(false)

Warning: stream_filter_append(): Compression level must be between -1 and 9, 10 given in %s on line %d

Warning: stream_filter_append(): Unable to create or locate filter "zlib.deflate" in %s on line %d
bool(false)
43 changes: 43 additions & 0 deletions ext/zlib/tests/zlib_filter_inflate_param_errors.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
--TEST--
zlib.inflate filter param errors
--EXTENSIONS--
zlib
--FILE--
<?php
$fp = fopen('php://stdout', 'w');

$param = 'not an array';
var_dump(stream_filter_append($fp, 'zlib.inflate', STREAM_FILTER_WRITE, $param));

$param = ['window' => 'not an int'];
var_dump(stream_filter_append($fp, 'zlib.inflate', STREAM_FILTER_WRITE, $param));

$param = ['window' => -16];
var_dump(stream_filter_append($fp, 'zlib.inflate', STREAM_FILTER_WRITE, $param));

$param = ['window' => 48];
var_dump(stream_filter_append($fp, 'zlib.inflate', STREAM_FILTER_WRITE, $param));

fclose($fp);

?>
--EXPECTF--
Warning: stream_filter_append(): Filter parameters for zlib.inflate filter must be of type array, string given in %s on line %d

Warning: stream_filter_append(): Unable to create or locate filter "zlib.inflate" in %s on line %d
bool(false)

Warning: stream_filter_append(): Window size must be of type int, string given in %s on line %d

Warning: stream_filter_append(): Unable to create or locate filter "zlib.inflate" in %s on line %d
bool(false)

Warning: stream_filter_append(): Window size must be between -15 and 47, -16 given in %s on line %d

Warning: stream_filter_append(): Unable to create or locate filter "zlib.inflate" in %s on line %d
bool(false)

Warning: stream_filter_append(): Window size must be between -15 and 47, 48 given in %s on line %d

Warning: stream_filter_append(): Unable to create or locate filter "zlib.inflate" in %s on line %d
bool(false)
16 changes: 16 additions & 0 deletions ext/zlib/tests/zlib_filter_unknown_errors.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--TEST--
zlib.deflate filter param errors
--EXTENSIONS--
zlib
--FILE--
<?php
$fp = fopen('php://stdout', 'w');

var_dump(stream_filter_append($fp, 'zlib.unknown', STREAM_FILTER_WRITE));

fclose($fp);

?>
--EXPECTF--
Warning: stream_filter_append(): Unable to create or locate filter "zlib.unknown" in %s on line %d
bool(false)
Loading
Loading