1
0
mirror of https://github.com/php/php-src.git synced 2026-04-22 23:48:14 +02:00
Files
archived-php-src/ext/standard/tests/streams/user_streams_consumed_bug.phpt
T
Gabriel Caruso ded3d984c6 Use EXPECT instead of EXPECTF when possible
EXPECTF logic in run-tests.php is considerable, so let's avoid it.
2018-02-20 21:53:48 +01:00

33 lines
690 B
PHP

--TEST--
Testing user filter on streams
--FILE--
<?php
class Intercept extends php_user_filter
{
public static $cache = '';
public function filter($in, $out, &$consumed, $closing)
{
while ($bucket = stream_bucket_make_writeable($in)) {
self::$cache .= $bucket->data;
$consumed += $bucket->datalen;
stream_bucket_append($out, $bucket);
}
return PSFS_PASS_ON;
}
}
$out = fwrite(STDOUT, "Hello\n");
var_dump($out);
stream_filter_register("intercept_filter", "Intercept");
stream_filter_append(STDOUT, "intercept_filter");
$out = fwrite(STDOUT, "Goodbye\n");
var_dump($out);
--EXPECT--
Hello
int(6)
Goodbye
int(8)