1--TEST-- 2stream_copy_to_stream() tests 3--FILE-- 4<?php 5define('WIN', substr(PHP_OS, 0, 3) == 'WIN'); 6 7$initial_file = dirname(__FILE__).'/bug38086.txt'; 8$new_file = dirname(__FILE__).'/bug38086_1.txt'; 9 10$src = fopen($initial_file, 'r'); 11stream_filter_append($src, "string.rot13", STREAM_FILTER_READ); 12 13$dest = fopen($new_file, 'w'); 14var_dump(stream_copy_to_stream($src, $dest, 0)); 15fclose($src); fclose($dest); 16 17var_dump(file_get_contents($new_file)); 18unlink($new_file); 19 20/* --- */ 21 22$src = fopen($initial_file, 'r'); 23stream_filter_append($src, "string.rot13", STREAM_FILTER_READ); 24 25$dest = fopen($new_file, 'w'); 26var_dump(stream_copy_to_stream($src, $dest, -1)); 27fclose($src); fclose($dest); 28if (WIN) { 29 var_dump(str_replace("\r\n","\n", file_get_contents($new_file))); 30} else { 31 var_dump(file_get_contents($new_file)); 32} 33unlink($new_file); 34 35/* --- */ 36 37$src = fopen($initial_file, 'r'); 38stream_filter_append($src, "string.rot13", STREAM_FILTER_READ); 39 40$dest = fopen($new_file, 'w'); 41var_dump(stream_copy_to_stream($src, $dest)); 42fclose($src); fclose($dest); 43 44if (WIN) { 45 var_dump(str_replace("\r\n","\n", file_get_contents($new_file))); 46} else { 47 var_dump(file_get_contents($new_file)); 48} 49unlink($new_file); 50 51/* --- */ 52 53$src = fopen($initial_file, 'r'); 54 55$dest = fopen($new_file, 'w'); 56var_dump(stream_copy_to_stream($src, $dest)); 57fclose($src); fclose($dest); 58 59if (WIN) { 60 var_dump(str_replace("\r\n","\n", file_get_contents($new_file))); 61} else { 62 var_dump(file_get_contents($new_file)); 63} 64unlink($new_file); 65 66/* --- */ 67 68$src = fopen($initial_file, 'r'); 69 70$dest = fopen($new_file, 'w'); 71var_dump(stream_copy_to_stream($src, $dest, 1000000)); 72fclose($src); fclose($dest); 73 74if (WIN) { 75 var_dump(str_replace("\r\n","\n", file_get_contents($new_file))); 76} else { 77 var_dump(file_get_contents($new_file)); 78} 79 80unlink($new_file); 81 82/* --- */ 83 84$src = fopen($initial_file, 'r'); 85 86$dest = fopen($new_file, 'w'); 87var_dump(stream_copy_to_stream($src, $dest, 10)); 88fclose($src); fclose($dest); 89 90if (WIN) { 91 var_dump(str_replace("\r\n","\n", file_get_contents($new_file))); 92} else { 93 var_dump(file_get_contents($new_file)); 94} 95unlink($new_file); 96 97/* --- */ 98 99$src = fopen($initial_file, 'r'); 100 101$dest = fopen($new_file, 'w'); 102var_dump(stream_copy_to_stream($src, $dest, -1)); 103fclose($src); fclose($dest); 104 105if (WIN) { 106 var_dump(str_replace("\r\n","\n", file_get_contents($new_file))); 107} else { 108 var_dump(file_get_contents($new_file)); 109} 110unlink($new_file); 111 112echo "Done\n"; 113?> 114--EXPECTF-- 115int(0) 116string(0) "" 117int(%d) 118string(134) "Nabgure qnl 119Jura gur cnvaf bs yvsr jba'g one zl jnl 120V'yy oernx gurfr punvaf 121Gung ubyq zr qbja 122V'yy grne lbh qbja vagb zl cevingr uryy 123" 124int(%d) 125string(134) "Nabgure qnl 126Jura gur cnvaf bs yvsr jba'g one zl jnl 127V'yy oernx gurfr punvaf 128Gung ubyq zr qbja 129V'yy grne lbh qbja vagb zl cevingr uryy 130" 131int(%d) 132string(134) "Another day 133When the pains of life won't bar my way 134I'll break these chains 135That hold me down 136I'll tear you down into my private hell 137" 138int(%d) 139string(134) "Another day 140When the pains of life won't bar my way 141I'll break these chains 142That hold me down 143I'll tear you down into my private hell 144" 145int(%d) 146string(10) "Another da" 147int(%d) 148string(134) "Another day 149When the pains of life won't bar my way 150I'll break these chains 151That hold me down 152I'll tear you down into my private hell 153" 154Done 155