File:
[ELWIX - Embedded LightWeight unIX -] /
embedaddon /
php /
ext /
standard /
tests /
filters /
filter_errors_user.phpt
Revision
1.1.1.1 (vendor branch):
download - view:
text,
annotated -
select for diffs -
revision graph
Tue Feb 21 23:48:04 2012 UTC (12 years, 6 months ago) by
misho
Branches:
php,
MAIN
CVS tags:
v5_4_3elwix,
v5_4_29p0,
v5_4_29,
v5_4_20p0,
v5_4_20,
v5_4_17p0,
v5_4_17,
v5_3_10,
HEAD
php
--TEST--
Filter errors: user filter
--FILE--
<?php
require 'filter_errors.inc';
class test_filter0 extends php_user_filter {
function filter($in, $out, &$consumed, $closing) {
return PSFS_ERR_FATAL;
}
}
class test_filter1 extends php_user_filter {
function filter($in, $out, &$consumed, $closing) {
$bucket = stream_bucket_make_writeable($in);
return PSFS_ERR_FATAL;
}
}
class test_filter2 extends php_user_filter {
function filter($in, $out, &$consumed, $closing) {
while ($bucket = stream_bucket_make_writeable($in)) {
$consumed += $bucket->datalen;
stream_bucket_append($out, $bucket);
}
return PSFS_ERR_FATAL;
}
}
class test_filter3 extends php_user_filter {
function filter($in, $out, &$consumed, $closing) {
if (!$closing) {
$bucket = stream_bucket_new($this->stream, "42");
stream_bucket_append($out, $bucket);
}
return PSFS_ERR_FATAL;
}
}
class test_filter4 extends php_user_filter {
function filter($in, $out, &$consumed, $closing) {
if (!$closing) {
$bucket = stream_bucket_new($this->stream, "42");
}
return PSFS_ERR_FATAL;
}
}
for($i = 0; $i < 5; ++$i) {
echo "test_filter$i\n";
var_dump(stream_filter_register("test_filter$i", "test_filter$i"));
filter_errors_test("test_filter$i", "42");
}
echo "test append / read / remove\n";
for($i = 0; $i < 5; ++$i) {
echo "test_filter$i\n";
$stream = fopen('php://memory', 'wb+');
fwrite($stream, b"42");
fseek($stream, 0, SEEK_SET);
$f = stream_filter_append($stream, "test_filter$i");
stream_get_contents($stream);
stream_filter_remove($f);
}
echo "test append all / read / remove all\n";
$stream = fopen('php://memory', 'wb+');
fwrite($stream, b"42");
fseek($stream, 0, SEEK_SET);
$filters = array();
for($i = 0; $i < 5; ++$i) {
echo "test_filter$i\n";
$filters[] = stream_filter_append($stream, "test_filter$i");
}
stream_get_contents($stream);
foreach($filters as $filter) {
stream_filter_remove($filter);
}
echo "test append all / read / close\n";
$stream = fopen('php://memory', 'wb+');
fwrite($stream, b"42");
fseek($stream, 0, SEEK_SET);
$filters = array();
for($i = 0; $i < 5; ++$i) {
echo "test_filter$i\n";
$filters[] = stream_filter_append($stream, "test_filter$i");
}
stream_get_contents($stream);
fclose($stream);
?>
--EXPECTF--
test_filter0
bool(true)
test filtering of buffered data
Warning: stream_filter_append(): Unprocessed filter buckets remaining on input brigade in %s
Warning: stream_filter_append(): Filter failed to process pre-buffered data in %s
test filtering of non buffered data
Warning: stream_get_contents(): Unprocessed filter buckets remaining on input brigade in %s
test_filter1
bool(true)
test filtering of buffered data
Warning: stream_filter_append(): Filter failed to process pre-buffered data in %s
test filtering of non buffered data
test_filter2
bool(true)
test filtering of buffered data
Warning: stream_filter_append(): Filter failed to process pre-buffered data in %s
test filtering of non buffered data
test_filter3
bool(true)
test filtering of buffered data
Warning: stream_filter_append(): Unprocessed filter buckets remaining on input brigade in %s
Warning: stream_filter_append(): Filter failed to process pre-buffered data in %s
test filtering of non buffered data
Warning: stream_get_contents(): Unprocessed filter buckets remaining on input brigade in %s
test_filter4
bool(true)
test filtering of buffered data
Warning: stream_filter_append(): Unprocessed filter buckets remaining on input brigade in %s
Warning: stream_filter_append(): Filter failed to process pre-buffered data in %s
test filtering of non buffered data
Warning: stream_get_contents(): Unprocessed filter buckets remaining on input brigade in %s
test append / read / remove
test_filter0
Warning: stream_get_contents(): Unprocessed filter buckets remaining on input brigade in %s
Warning: stream_filter_remove(): Unable to flush filter, not removing in %s
test_filter1
Warning: stream_filter_remove(): Unable to flush filter, not removing in %s
test_filter2
Warning: stream_filter_remove(): Unable to flush filter, not removing in %s
test_filter3
Warning: stream_get_contents(): Unprocessed filter buckets remaining on input brigade in %s
Warning: stream_filter_remove(): Unable to flush filter, not removing in %s
test_filter4
Warning: stream_get_contents(): Unprocessed filter buckets remaining on input brigade in %s
Warning: stream_filter_remove(): Unable to flush filter, not removing in %s
test append all / read / remove all
test_filter0
test_filter1
test_filter2
test_filter3
test_filter4
Warning: stream_get_contents(): Unprocessed filter buckets remaining on input brigade in %s
Warning: stream_filter_remove(): Unable to flush filter, not removing in %s
Warning: stream_filter_remove(): Unable to flush filter, not removing in %s
Warning: stream_filter_remove(): Unable to flush filter, not removing in %s
Warning: stream_filter_remove(): Unable to flush filter, not removing in %s
Warning: stream_filter_remove(): Unable to flush filter, not removing in %s
test append all / read / close
test_filter0
test_filter1
test_filter2
test_filter3
test_filter4
Warning: stream_get_contents(): Unprocessed filter buckets remaining on input brigade in %s
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>