Annotation of embedaddon/php/ext/standard/tests/filters/bug22538.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Bug #22538 (filtered stream doesn't update file pointer)
3: --FILE--
4: <?php
5: function my_stream_copy_to_stream($fin, $fout) {
6: while (!feof($fin)) {
7: fwrite($fout, fread($fin, 4096));
8: }
9: }
10:
11: $size = 65536;
12:
13: do {
14: $path1 = sprintf("%s/%s%da", dirname(__FILE__), uniqid(), time());
15: $path2 = sprintf("%s/%s%db", dirname(__FILE__), uniqid(), time());
16: } while ($path1 == $path2);
17:
18: $fp = fopen($path1, "w") or die("Can not open $path1\n");
19: $str = "abcdefghijklmnopqrstuvwxyz\n";
20: $str_len = strlen($str);
21: $cnt = $size;
22: while (($cnt -= $str_len) > 0) {
23: fwrite($fp, $str);
24: }
25: $cnt = $size - ($str_len + $cnt);
26: fclose($fp);
27: $fin = fopen($path1, "r") or die("Can not open $path1\n");;
28: $fout = fopen($path2, "w") or die("Can not open $path2\n");;
29: stream_filter_append($fout, "string.rot13");
30: my_stream_copy_to_stream($fin, $fout);
31: fclose($fout);
32: fclose($fin);
33: var_dump($cnt);
34: var_dump(filesize($path2));
35: var_dump(md5_file($path1));
36: var_dump(md5_file($path2));
37: unlink($path1);
38: unlink($path2);
39: ?>
40: --EXPECT--
41: int(65529)
42: int(65529)
43: string(32) "e10e3d1ae81b084b822e8592d019b57a"
44: string(32) "931f0fbf8a72312e3bab9965b1d1081c"
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>