php-src/ext/standard/tests/filters/bug22538.phpt

45 lines
1.1 KiB
Plaintext
Raw Normal View History

2003-04-01 19:10:04 +00:00
--TEST--
Bug #22538 (filtered stream doesn't update file pointer)
--FILE--
<?php
2003-04-01 19:47:33 +00:00
function my_stream_copy_to_stream($fin, $fout) {
while (!feof($fin)) {
fwrite($fout, fread($fin, 4096));
}
}
$size = 65536;
do {
$path1 = sprintf("%s/%s%da", dirname(__FILE__), uniqid(), time());
$path2 = sprintf("%s/%s%db", dirname(__FILE__), uniqid(), time());
} while ($path1 == $path2);
2004-11-23 17:21:33 +00:00
$fp = fopen($path1, "w") or die("Can not open $path1\n");
2003-04-01 19:47:33 +00:00
$str = "abcdefghijklmnopqrstuvwxyz\n";
$str_len = strlen($str);
$cnt = $size;
while (($cnt -= $str_len) > 0) {
fwrite($fp, $str);
}
$cnt = $size - ($str_len + $cnt);
fclose($fp);
2004-11-23 17:21:33 +00:00
$fin = fopen($path1, "r") or die("Can not open $path1\n");;
$fout = fopen($path2, "w") or die("Can not open $path2\n");;
2003-04-01 19:47:33 +00:00
stream_filter_append($fout, "string.rot13");
my_stream_copy_to_stream($fin, $fout);
fclose($fout);
2003-04-01 19:10:04 +00:00
fclose($fin);
2003-04-01 19:47:33 +00:00
var_dump($cnt);
var_dump(filesize($path2));
var_dump(md5_file($path1));
var_dump(md5_file($path2));
unlink($path1);
unlink($path2);
2003-04-01 19:10:04 +00:00
?>
--EXPECT--
2003-04-01 19:47:33 +00:00
int(65529)
int(65529)
string(32) "e10e3d1ae81b084b822e8592d019b57a"
string(32) "931f0fbf8a72312e3bab9965b1d1081c"